Topic: Asking for help on P0237: input and output with facets
Author: Vincent Reverdy <vince.rev@gmail.com>
Date: Sun, 20 Nov 2016 19:54:38 -0800 (PST)
Raw View
------=_Part_7300_365752448.1479700478242
Content-Type: multipart/alternative;
boundary="----=_Part_7301_846325687.1479700478243"
------=_Part_7301_846325687.1479700478243
Content-Type: text/plain; charset=UTF-8
Hello.
During the Issaquah meeting, I got feedback on P0237R3
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0237r3.html>
(fundamental bit utilities) and I am facing a problem with facets. Here is
a simpler version of the problem. Consider the following code:
//
==========================================================================
//
// Preamble
#include <bitset>
#include <sstream>
#include <iostream>
// Bit wrapper (simplified version of bit_value in P0237R3)
class bit
{
// Public members
public:
explicit constexpr bit(bool value) noexcept: _value(value) {}
explicit constexpr operator bool() const noexcept {return _value;}
bit& assign(bool value) noexcept {_value = value; return *this;}
void set() noexcept {_value = true;}
void reset() noexcept {_value = false;}
void flip() noexcept {_value = !_value;}
// Data members
private:
bool _value;
};
// Output
template <class CharT, class Traits>
std::basic_ostream<CharT, Traits>& operator<<(
std::basic_ostream<CharT, Traits>& os,
bit b
)
{
std::bitset<1> bs(static_cast<bool>(b));
return os << bs;
}
// Input
template <class CharT, class Traits>
std::basic_istream<CharT, Traits>& operator>>(
std::basic_istream<CharT, Traits>& is,
bit& b
)
{
std::bitset<1> bs;
is >> bs;
b.assign(bs[0]);
return is;
}
// Main function
int main(int argc, char* argv[])
{
bit b0(false);
bit b1(true);
std::stringstream stream;
std::cout<<b0<<b1<<std::endl;
stream<<" "<<b0<<b1;
stream>>b1>>b0;
std::cout<<b0<<b1<<std::endl;
return 0;
}
//
==========================================================================
//
The bit class is just a simplified version of the classes introduced in
P0237R3 to illustrate my problem. My question is the following: how should
the output operator<< and the input operator>> be formally specified for
bits and what a conforming implementation should look like? In the feedback
I received, using numeric facet was suggested, but as it's not at all my
area of expertise (I basically never used facets), I am asking for help
(should a numeric facet specialization/overload be created to deal with
bits, or should I use the existing ones, I don't even know). Could people
with experience with input/output and facets clarify what the wording
should look like and what the implementation should be like?
Thank you very much,
Vincent Reverdy
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ffa1a664-51ae-4cd3-8058-d184b85743f0%40isocpp.org.
------=_Part_7301_846325687.1479700478243
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hello.<br><br>During the Issaquah meeting, I got feedback =
on <a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0237=
r3.html">P0237R3</a> (fundamental bit utilities) and I am facing a problem =
with facets. Here is a simpler version of the problem. Consider the followi=
ng code:<br><div style=3D"background-color: rgb(250, 250, 250); border-colo=
r: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflow-wra=
p: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div clas=
s=3D"subprettyprint"><span style=3D"color: #800;" class=3D"styled-by-pretti=
fy">// =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D //</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: #800;" class=3D"styled-by-prettify">// Prea=
mble</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span><span style=3D"color: #800;" class=3D"styled-by-prettify">#include</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #080;" class=3D"styled-by-prettify"><bitset></span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #800;" class=3D"styled-by-prettify">#include</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #080;" class=3D"styled-by-prettify"><sstream></span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">#include</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" cl=
ass=3D"styled-by-prettify"><iostream></span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">// Bit wrapper (simplified version of bit_va=
lue in P0237R3)</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">c=
lass</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> bit<b=
r></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0=
</span><span style=3D"color: #800;" class=3D"styled-by-prettify">// Public=
members</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">public</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">explicit</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">constexpr</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> bit</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> value</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> noexcept</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> _value</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">value</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>{}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">explicit</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">constexpr</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">operat=
or</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">const</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> noexcept </span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">{</span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> _value</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">;}</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 bit</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> assign</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">bool</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> value</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> noe=
xcept </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">_value </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> value</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">*</span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">this</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">set</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> noexcept </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">_value </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">true</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">;}</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> reset</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> noexcept </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">_value </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">fal=
se</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;}</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">void</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> flip</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> noexcept <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">_value </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">!</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">_value</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">;}</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #800;" clas=
s=3D"styled-by-prettify">// Data members</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">private</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> _value</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br><br></span><span style=3D"color: #800;" class=3D"styled=
-by-prettify">// Output</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">template</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #606;" class=3D"styled-by-prettify">CharT</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">class</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">Traits</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">></span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>std</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">basic_=
ostream</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><=
;</span><span style=3D"color: #606;" class=3D"styled-by-prettify">CharT</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #606;" class=3D"styled-by-prettify">Traits</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">>&</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">operator</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify"><<(</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 std</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">basic_ostream</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify"><</span><span style=3D"color: #606;" cla=
ss=3D"styled-by-prettify">CharT</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">Traits</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;&</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> o=
s</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
bit b<br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">)=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <br></spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 std</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">bitset</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">1</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">></span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> bs</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">static_cast</span><span style=3D"color: #080;" class=3D"styl=
ed-by-prettify"><bool></span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
));</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>return</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> os=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> bs</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">// Input</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">class</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">CharT=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">class</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #60=
6;" class=3D"styled-by-prettify">Traits</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">></span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>std</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">basic_istream</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify"><</span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">CharT</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #606;" class=3D"styled-by-prettify">Traits</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">>&</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">>>(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 std</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">basic_istream</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">CharT</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">Traits</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">>&</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">is</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 bit</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">&</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
b<br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> <br></span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 std</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">bitset</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"co=
lor: #066;" class=3D"styled-by-prettify">1</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">></span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> bs</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">is</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>>></span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
bs</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0=
b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">assign</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">bs</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #066;"=
class=3D"styled-by-prettify">0</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">]);</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">is</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span =
style=3D"color: #800;" class=3D"styled-by-prettify">// Main function</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> main</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> argc</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">char</span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> argv</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">[])</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 bit b0</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">false</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 bit b1</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">true</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>=C2=A0 =C2=A0 std</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">stringstream stream</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 std</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">cout</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify"><<</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">b0</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify"><<</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">b1</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
><<</span><span style=3D"color: #000;" class=3D"styled-by-prettify">s=
td</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">endl</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 stream</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify"><<</span><s=
pan style=3D"color: #080;" class=3D"styled-by-prettify">" =C2=A0 =C2=
=A0"</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;<</span><span style=3D"color: #000;" class=3D"styled-by-prettify">b0<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">b1</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 stream</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">>></span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">b1</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">>></span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">b0</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 std</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">cout</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">b0</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify"><<</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">b1</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify"><<</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">endl</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br></span><br><code class=3D"prettyprint"><span style=3D"co=
lor: #800;" class=3D"styled-by-prettify">// =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D //</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"></span></code><br></div></code></div>The=
bit class is just a simplified version of the classes introduced in P0237R=
3 to illustrate my problem. My question is the following: how should the ou=
tput <span style=3D"font-family: courier new,monospace;">operator<<</=
span> and the input <span style=3D"font-family: courier new,monospace;">ope=
rator>></span> be formally specified for bits and what a conforming i=
mplementation should look like? In the feedback I received, using numeric f=
acet was suggested, but as it's not at all my area of expertise (I basi=
cally never used facets), I am asking for help (should a numeric facet spec=
ialization/overload be created to deal with bits, or should I use the exist=
ing ones, I don't even know). Could people with experience with input/o=
utput and facets clarify what the wording should look like and what the imp=
lementation should be like?<br><br>Thank you very much,<br>Vincent Reverdy<=
br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/ffa1a664-51ae-4cd3-8058-d184b85743f0%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/ffa1a664-51ae-4cd3-8058-d184b85743f0=
%40isocpp.org</a>.<br />
------=_Part_7301_846325687.1479700478243--
------=_Part_7300_365752448.1479700478242--
.
Author: Patrice Roy <patricer@gmail.com>
Date: Mon, 21 Nov 2016 05:48:51 -0500
Raw View
--001a11438e2acabd110541cd664a
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Curiosity : what is the expectation with respect to locale-related bit I/O?
I would have expected a =C2=ABuniversal=C2=BB 0/1 representation, which wou=
ld
simplify things a lot in your case, but that might be my
less-than-sufficient understanding of per-locale bit representation rules
showing.
Having a better idea as to what the expectations are would be useful in
assisting you, in any case. Cheers!
2016-11-20 22:54 GMT-05:00 Vincent Reverdy <vince.rev@gmail.com>:
> Hello.
>
> During the Issaquah meeting, I got feedback on P0237R3
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0237r3.html>
> (fundamental bit utilities) and I am facing a problem with facets. Here i=
s
> a simpler version of the problem. Consider the following code:
> // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
> //
> // Preamble
> #include <bitset>
> #include <sstream>
> #include <iostream>
>
> // Bit wrapper (simplified version of bit_value in P0237R3)
> class bit
> {
> // Public members
> public:
> explicit constexpr bit(bool value) noexcept: _value(value) {}
> explicit constexpr operator bool() const noexcept {return _value;=
}
> bit& assign(bool value) noexcept {_value =3D value; return *this;=
}
> void set() noexcept {_value =3D true;}
> void reset() noexcept {_value =3D false;}
> void flip() noexcept {_value =3D !_value;}
> // Data members
> private:
> bool _value;
> };
>
> // Output
> template <class CharT, class Traits>
> std::basic_ostream<CharT, Traits>& operator<<(
> std::basic_ostream<CharT, Traits>& os,
> bit b
> )
> {
> std::bitset<1> bs(static_cast<bool>(b));
> return os << bs;
> }
>
> // Input
> template <class CharT, class Traits>
> std::basic_istream<CharT, Traits>& operator>>(
> std::basic_istream<CharT, Traits>& is,
> bit& b
> )
> {
> std::bitset<1> bs;
> is >> bs;
> b.assign(bs[0]);
> return is;
> }
>
> // Main function
> int main(int argc, char* argv[])
> {
> bit b0(false);
> bit b1(true);
> std::stringstream stream;
> std::cout<<b0<<b1<<std::endl;
> stream<<" "<<b0<<b1;
> stream>>b1>>b0;
> std::cout<<b0<<b1<<std::endl;
> return 0;
> }
>
> // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
> //
> The bit class is just a simplified version of the classes introduced in
> P0237R3 to illustrate my problem. My question is the following: how shoul=
d
> the output operator<< and the input operator>> be formally specified for
> bits and what a conforming implementation should look like? In the feedba=
ck
> I received, using numeric facet was suggested, but as it's not at all my
> area of expertise (I basically never used facets), I am asking for help
> (should a numeric facet specialization/overload be created to deal with
> bits, or should I use the existing ones, I don't even know). Could people
> with experience with input/output and facets clarify what the wording
> should look like and what the implementation should be like?
>
> Thank you very much,
> Vincent Reverdy
>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit https://groups.google.com/a/
> isocpp.org/d/msgid/std-proposals/ffa1a664-51ae-4cd3-
> 8058-d184b85743f0%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ffa1a664-51=
ae-4cd3-8058-d184b85743f0%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAKiZDp0Z_i7i_r9QXMVXow29y78CFnxqNmRjFfso31Xu0C1=
5Fg%40mail.gmail.com.
--001a11438e2acabd110541cd664a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Curiosity : what is the expectation with respect to l=
ocale-related bit I/O? I would have expected a =C2=ABuniversal=C2=BB 0/1 re=
presentation, which would simplify things a lot in your case, but that migh=
t be my less-than-sufficient understanding of per-locale bit representation=
rules showing.<br><br></div>Having a better idea as to what the expectatio=
ns are would be useful in assisting you, in any case. Cheers!<br></div><div=
class=3D"gmail_extra"><br><div class=3D"gmail_quote">2016-11-20 22:54 GMT-=
05:00 Vincent Reverdy <span dir=3D"ltr"><<a href=3D"mailto:vince.rev@gma=
il.com" target=3D"_blank">vince.rev@gmail.com</a>></span>:<br><blockquot=
e class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc sol=
id;padding-left:1ex"><div dir=3D"ltr">Hello.<br><br>During the Issaquah mee=
ting, I got feedback on <a href=3D"http://www.open-std.org/jtc1/sc22/wg21/d=
ocs/papers/2016/p0237r3.html" target=3D"_blank">P0237R3</a> (fundamental bi=
t utilities) and I am facing a problem with facets. Here is a simpler versi=
on of the problem. Consider the following code:<br><div style=3D"background=
-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bo=
rder-width:1px" class=3D"m_4483421180951815324prettyprint"><code class=3D"m=
_4483421180951815324prettyprint"><div class=3D"m_4483421180951815324subpret=
typrint"><span style=3D"color:#800" class=3D"m_4483421180951815324styled-by=
-prettify">// =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<wbr>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<wbr>=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D //</span><span style=3D"color:#000" class=3D"m_448=
3421180951815324styled-by-prettify"><br></span><span style=3D"color:#800" c=
lass=3D"m_4483421180951815324styled-by-prettify">// Preamble</span><span st=
yle=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"><br></=
span><span style=3D"color:#800" class=3D"m_4483421180951815324styled-by-pre=
ttify">#include</span><span style=3D"color:#000" class=3D"m_448342118095181=
5324styled-by-prettify"> </span><span style=3D"color:#080" class=3D"m_44834=
21180951815324styled-by-prettify"><bitset></span><span style=3D"color=
:#000" class=3D"m_4483421180951815324styled-by-prettify"><br></span><span s=
tyle=3D"color:#800" class=3D"m_4483421180951815324styled-by-prettify">#incl=
ude</span><span style=3D"color:#000" class=3D"m_4483421180951815324styled-b=
y-prettify"> </span><span style=3D"color:#080" class=3D"m_44834211809518153=
24styled-by-prettify"><sstream></span><span style=3D"color:#000" clas=
s=3D"m_4483421180951815324styled-by-prettify"><br></span><span style=3D"col=
or:#800" class=3D"m_4483421180951815324styled-by-prettify">#include</span><=
span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"=
> </span><span style=3D"color:#080" class=3D"m_4483421180951815324styled-by=
-prettify"><iostream></span><span style=3D"color:#000" class=3D"m_448=
3421180951815324styled-by-prettify"><br><br></span><span style=3D"color:#80=
0" class=3D"m_4483421180951815324styled-by-prettify">// Bit wrapper (simpli=
fied version of bit_value in P0237R3)</span><span style=3D"color:#000" clas=
s=3D"m_4483421180951815324styled-by-prettify"><br></span><span style=3D"col=
or:#008" class=3D"m_4483421180951815324styled-by-prettify">class</span><spa=
n style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"> b=
it<br></span><span style=3D"color:#660" class=3D"m_4483421180951815324style=
d-by-prettify">{</span><span style=3D"color:#000" class=3D"m_44834211809518=
15324styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#800=
" class=3D"m_4483421180951815324styled-by-prettify">// Public members</span=
><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettif=
y"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008" class=3D"m_448342118=
0951815324styled-by-prettify">public</span><span style=3D"color:#660" class=
=3D"m_4483421180951815324styled-by-prettify">:</span><span style=3D"color:#=
000" class=3D"m_4483421180951815324styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 </span><span style=3D"color:#008" class=3D"m_4483421180951815=
324styled-by-prettify">explicit</span><span style=3D"color:#000" class=3D"m=
_4483421180951815324styled-by-prettify"> </span><span style=3D"color:#008" =
class=3D"m_4483421180951815324styled-by-prettify">constexpr</span><span sty=
le=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"> bit</s=
pan><span style=3D"color:#660" class=3D"m_4483421180951815324styled-by-pret=
tify">(</span><span style=3D"color:#008" class=3D"m_4483421180951815324styl=
ed-by-prettify">bool</span><span style=3D"color:#000" class=3D"m_4483421180=
951815324styled-by-prettify"> value</span><span style=3D"color:#660" class=
=3D"m_4483421180951815324styled-by-prettify">)</span><span style=3D"color:#=
000" class=3D"m_4483421180951815324styled-by-prettify"> noexcept</span><spa=
n style=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">:<=
/span><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-pr=
ettify"> _value</span><span style=3D"color:#660" class=3D"m_448342118095181=
5324styled-by-prettify">(</span><span style=3D"color:#000" class=3D"m_44834=
21180951815324styled-by-prettify">value</span><span style=3D"color:#660" cl=
ass=3D"m_4483421180951815324styled-by-prettify">)</span><span style=3D"colo=
r:#000" class=3D"m_4483421180951815324styled-by-prettify"> </span><span sty=
le=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">{}</spa=
n><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-pretti=
fy"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008" class=
=3D"m_4483421180951815324styled-by-prettify">explicit</span><span style=3D"=
color:#000" class=3D"m_4483421180951815324styled-by-prettify"> </span><span=
style=3D"color:#008" class=3D"m_4483421180951815324styled-by-prettify">con=
stexpr</span><span style=3D"color:#000" class=3D"m_4483421180951815324style=
d-by-prettify"> </span><span style=3D"color:#008" class=3D"m_44834211809518=
15324styled-by-prettify">operator</span><span style=3D"color:#000" class=3D=
"m_4483421180951815324styled-by-prettify"> </span><span style=3D"color:#008=
" class=3D"m_4483421180951815324styled-by-prettify">bool</span><span style=
=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">()</span>=
<span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify=
"> </span><span style=3D"color:#008" class=3D"m_4483421180951815324styled-b=
y-prettify">const</span><span style=3D"color:#000" class=3D"m_4483421180951=
815324styled-by-prettify"> noexcept </span><span style=3D"color:#660" class=
=3D"m_4483421180951815324styled-by-prettify">{</span><span style=3D"color:#=
008" class=3D"m_4483421180951815324styled-by-prettify">return</span><span s=
tyle=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"> _val=
ue</span><span style=3D"color:#660" class=3D"m_4483421180951815324styled-by=
-prettify">;}</span><span style=3D"color:#000" class=3D"m_44834211809518153=
24styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 bit</span><span style=
=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">&</sp=
an><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prett=
ify"> assign</span><span style=3D"color:#660" class=3D"m_448342118095181532=
4styled-by-prettify">(</span><span style=3D"color:#008" class=3D"m_44834211=
80951815324styled-by-prettify">bool</span><span style=3D"color:#000" class=
=3D"m_4483421180951815324styled-by-prettify"> value</span><span style=3D"co=
lor:#660" class=3D"m_4483421180951815324styled-by-prettify">)</span><span s=
tyle=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"> noex=
cept </span><span style=3D"color:#660" class=3D"m_4483421180951815324styled=
-by-prettify">{</span><span style=3D"color:#000" class=3D"m_448342118095181=
5324styled-by-prettify">_value </span><span style=3D"color:#660" class=3D"m=
_4483421180951815324styled-by-prettify">=3D</span><span style=3D"color:#000=
" class=3D"m_4483421180951815324styled-by-prettify"> value</span><span styl=
e=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">;</span>=
<span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify=
"> </span><span style=3D"color:#008" class=3D"m_4483421180951815324styled-b=
y-prettify">return</span><span style=3D"color:#000" class=3D"m_448342118095=
1815324styled-by-prettify"> </span><span style=3D"color:#660" class=3D"m_44=
83421180951815324styled-by-prettify">*</span><span style=3D"color:#008" cla=
ss=3D"m_4483421180951815324styled-by-prettify">this</span><span style=3D"co=
lor:#660" class=3D"m_4483421180951815324styled-by-prettify">;}</span><span =
style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008" class=3D"m_44=
83421180951815324styled-by-prettify">void</span><span style=3D"color:#000" =
class=3D"m_4483421180951815324styled-by-prettify"> </span><span style=3D"co=
lor:#008" class=3D"m_4483421180951815324styled-by-prettify">set</span><span=
style=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">()<=
/span><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-pr=
ettify"> noexcept </span><span style=3D"color:#660" class=3D"m_448342118095=
1815324styled-by-prettify">{</span><span style=3D"color:#000" class=3D"m_44=
83421180951815324styled-by-prettify">_value </span><span style=3D"color:#66=
0" class=3D"m_4483421180951815324styled-by-prettify">=3D</span><span style=
=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"> </span><=
span style=3D"color:#008" class=3D"m_4483421180951815324styled-by-prettify"=
>true</span><span style=3D"color:#660" class=3D"m_4483421180951815324styled=
-by-prettify">;}</span><span style=3D"color:#000" class=3D"m_44834211809518=
15324styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=
=3D"color:#008" class=3D"m_4483421180951815324styled-by-prettify">void</spa=
n><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-pretti=
fy"> reset</span><span style=3D"color:#660" class=3D"m_4483421180951815324s=
tyled-by-prettify">()</span><span style=3D"color:#000" class=3D"m_448342118=
0951815324styled-by-prettify"> noexcept </span><span style=3D"color:#660" c=
lass=3D"m_4483421180951815324styled-by-prettify">{</span><span style=3D"col=
or:#000" class=3D"m_4483421180951815324styled-by-prettify">_value </span><s=
pan style=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">=
=3D</span><span style=3D"color:#000" class=3D"m_4483421180951815324styled-b=
y-prettify"> </span><span style=3D"color:#008" class=3D"m_44834211809518153=
24styled-by-prettify">false</span><span style=3D"color:#660" class=3D"m_448=
3421180951815324styled-by-prettify">;}</span><span style=3D"color:#000" cla=
ss=3D"m_4483421180951815324styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 </span><span style=3D"color:#008" class=3D"m_4483421180951815324styled-=
by-prettify">void</span><span style=3D"color:#000" class=3D"m_4483421180951=
815324styled-by-prettify"> flip</span><span style=3D"color:#660" class=3D"m=
_4483421180951815324styled-by-prettify">()</span><span style=3D"color:#000"=
class=3D"m_4483421180951815324styled-by-prettify"> noexcept </span><span s=
tyle=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">{</sp=
an><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prett=
ify">_value </span><span style=3D"color:#660" class=3D"m_448342118095181532=
4styled-by-prettify">=3D</span><span style=3D"color:#000" class=3D"m_448342=
1180951815324styled-by-prettify"> </span><span style=3D"color:#660" class=
=3D"m_4483421180951815324styled-by-prettify">!</span><span style=3D"color:#=
000" class=3D"m_4483421180951815324styled-by-prettify">_value</span><span s=
tyle=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">;}</s=
pan><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-pret=
tify"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#800" class=3D"m_448342=
1180951815324styled-by-prettify">// Data members</span><span style=3D"color=
:#000" class=3D"m_4483421180951815324styled-by-prettify"><br>=C2=A0 =C2=A0 =
</span><span style=3D"color:#008" class=3D"m_4483421180951815324styled-by-p=
rettify">private</span><span style=3D"color:#660" class=3D"m_44834211809518=
15324styled-by-prettify">:</span><span style=3D"color:#000" class=3D"m_4483=
421180951815324styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><=
span style=3D"color:#008" class=3D"m_4483421180951815324styled-by-prettify"=
>bool</span><span style=3D"color:#000" class=3D"m_4483421180951815324styled=
-by-prettify"> _value</span><span style=3D"color:#660" class=3D"m_448342118=
0951815324styled-by-prettify">;</span><span style=3D"color:#000" class=3D"m=
_4483421180951815324styled-by-prettify"><br></span><span style=3D"color:#66=
0" class=3D"m_4483421180951815324styled-by-prettify">};</span><span style=
=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"><br><br><=
/span><span style=3D"color:#800" class=3D"m_4483421180951815324styled-by-pr=
ettify">// Output</span><span style=3D"color:#000" class=3D"m_4483421180951=
815324styled-by-prettify"><br></span><span style=3D"color:#008" class=3D"m_=
4483421180951815324styled-by-prettify">template</span><span style=3D"color:=
#000" class=3D"m_4483421180951815324styled-by-prettify"> </span><span style=
=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify"><</spa=
n><span style=3D"color:#008" class=3D"m_4483421180951815324styled-by-pretti=
fy">class</span><span style=3D"color:#000" class=3D"m_4483421180951815324st=
yled-by-prettify"> </span><span style=3D"color:#606" class=3D"m_44834211809=
51815324styled-by-prettify">CharT</span><span style=3D"color:#660" class=3D=
"m_4483421180951815324styled-by-prettify">,</span><span style=3D"color:#000=
" class=3D"m_4483421180951815324styled-by-prettify"> </span><span style=3D"=
color:#008" class=3D"m_4483421180951815324styled-by-prettify">class</span><=
span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"=
> </span><span style=3D"color:#606" class=3D"m_4483421180951815324styled-by=
-prettify">Traits</span><span style=3D"color:#660" class=3D"m_4483421180951=
815324styled-by-prettify">></span><span style=3D"color:#000" class=3D"m_=
4483421180951815324styled-by-prettify"><br>std</span><span style=3D"color:#=
660" class=3D"m_4483421180951815324styled-by-prettify">::</span><span style=
=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify">basic_ost=
ream</span><span style=3D"color:#660" class=3D"m_4483421180951815324styled-=
by-prettify"><</span><span style=3D"color:#606" class=3D"m_4483421180951=
815324styled-by-prettify">CharT</span><span style=3D"color:#660" class=3D"m=
_4483421180951815324styled-by-prettify">,</span><span style=3D"color:#000" =
class=3D"m_4483421180951815324styled-by-prettify"> </span><span style=3D"co=
lor:#606" class=3D"m_4483421180951815324styled-by-prettify">Traits</span><s=
pan style=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">=
>&</span><span style=3D"color:#000" class=3D"m_4483421180951815324st=
yled-by-prettify"> </span><span style=3D"color:#008" class=3D"m_44834211809=
51815324styled-by-prettify">operator</span><span style=3D"color:#660" class=
=3D"m_4483421180951815324styled-by-prettify"><<(</span><span style=3D=
"color:#000" class=3D"m_4483421180951815324styled-by-prettify"><br>=C2=A0 =
=C2=A0 std</span><span style=3D"color:#660" class=3D"m_4483421180951815324s=
tyled-by-prettify">::</span><span style=3D"color:#000" class=3D"m_448342118=
0951815324styled-by-prettify">basic_ostream</span><span style=3D"color:#660=
" class=3D"m_4483421180951815324styled-by-prettify"><</span><span style=
=3D"color:#606" class=3D"m_4483421180951815324styled-by-prettify">CharT</sp=
an><span style=3D"color:#660" class=3D"m_4483421180951815324styled-by-prett=
ify">,</span><span style=3D"color:#000" class=3D"m_4483421180951815324style=
d-by-prettify"> </span><span style=3D"color:#606" class=3D"m_44834211809518=
15324styled-by-prettify">Traits</span><span style=3D"color:#660" class=3D"m=
_4483421180951815324styled-by-prettify">>&</span><span style=3D"colo=
r:#000" class=3D"m_4483421180951815324styled-by-prettify"> os</span><span s=
tyle=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">,</sp=
an><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prett=
ify"><br>=C2=A0 =C2=A0 bit b<br></span><span style=3D"color:#660" class=3D"=
m_4483421180951815324styled-by-prettify">)</span><span style=3D"color:#000"=
class=3D"m_4483421180951815324styled-by-prettify"> <br></span><span style=
=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">{</span><=
span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"=
><br>=C2=A0 =C2=A0 std</span><span style=3D"color:#660" class=3D"m_44834211=
80951815324styled-by-prettify">::</span><span style=3D"color:#000" class=3D=
"m_4483421180951815324styled-by-prettify">bitset</span><span style=3D"color=
:#660" class=3D"m_4483421180951815324styled-by-prettify"><</span><span s=
tyle=3D"color:#066" class=3D"m_4483421180951815324styled-by-prettify">1</sp=
an><span style=3D"color:#660" class=3D"m_4483421180951815324styled-by-prett=
ify">></span><span style=3D"color:#000" class=3D"m_4483421180951815324st=
yled-by-prettify"> bs</span><span style=3D"color:#660" class=3D"m_448342118=
0951815324styled-by-prettify">(</span><span style=3D"color:#008" class=3D"m=
_4483421180951815324styled-by-prettify">static_cast</span><span style=3D"co=
lor:#080" class=3D"m_4483421180951815324styled-by-prettify"><bool></s=
pan><span style=3D"color:#660" class=3D"m_4483421180951815324styled-by-pret=
tify">(</span><span style=3D"color:#000" class=3D"m_4483421180951815324styl=
ed-by-prettify">b</span><span style=3D"color:#660" class=3D"m_4483421180951=
815324styled-by-prettify">));</span><span style=3D"color:#000" class=3D"m_4=
483421180951815324styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#008" class=3D"m_4483421180951815324styled-by-prettify">return</s=
pan><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-pret=
tify"> os </span><span style=3D"color:#660" class=3D"m_4483421180951815324s=
tyled-by-prettify"><<</span><span style=3D"color:#000" class=3D"m_448=
3421180951815324styled-by-prettify"> bs</span><span style=3D"color:#660" cl=
ass=3D"m_4483421180951815324styled-by-prettify">;</span><span style=3D"colo=
r:#000" class=3D"m_4483421180951815324styled-by-prettify"><br></span><span =
style=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">}</s=
pan><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-pret=
tify"><br><br></span><span style=3D"color:#800" class=3D"m_4483421180951815=
324styled-by-prettify">// Input</span><span style=3D"color:#000" class=3D"m=
_4483421180951815324styled-by-prettify"><br></span><span style=3D"color:#00=
8" class=3D"m_4483421180951815324styled-by-prettify">template</span><span s=
tyle=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"> </sp=
an><span style=3D"color:#660" class=3D"m_4483421180951815324styled-by-prett=
ify"><</span><span style=3D"color:#008" class=3D"m_4483421180951815324st=
yled-by-prettify">class</span><span style=3D"color:#000" class=3D"m_4483421=
180951815324styled-by-prettify"> </span><span style=3D"color:#606" class=3D=
"m_4483421180951815324styled-by-prettify">CharT</span><span style=3D"color:=
#660" class=3D"m_4483421180951815324styled-by-prettify">,</span><span style=
=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"> </span><=
span style=3D"color:#008" class=3D"m_4483421180951815324styled-by-prettify"=
>class</span><span style=3D"color:#000" class=3D"m_4483421180951815324style=
d-by-prettify"> </span><span style=3D"color:#606" class=3D"m_44834211809518=
15324styled-by-prettify">Traits</span><span style=3D"color:#660" class=3D"m=
_4483421180951815324styled-by-prettify">></span><span style=3D"color:#00=
0" class=3D"m_4483421180951815324styled-by-prettify"><br>std</span><span st=
yle=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">::</sp=
an><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prett=
ify">basic_istream</span><span style=3D"color:#660" class=3D"m_448342118095=
1815324styled-by-prettify"><</span><span style=3D"color:#606" class=3D"m=
_4483421180951815324styled-by-prettify">CharT</span><span style=3D"color:#6=
60" class=3D"m_4483421180951815324styled-by-prettify">,</span><span style=
=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"> </span><=
span style=3D"color:#606" class=3D"m_4483421180951815324styled-by-prettify"=
>Traits</span><span style=3D"color:#660" class=3D"m_4483421180951815324styl=
ed-by-prettify">>&</span><span style=3D"color:#000" class=3D"m_44834=
21180951815324styled-by-prettify"> </span><span style=3D"color:#008" class=
=3D"m_4483421180951815324styled-by-prettify">operator</span><span style=3D"=
color:#660" class=3D"m_4483421180951815324styled-by-prettify">>>(</sp=
an><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prett=
ify"><br>=C2=A0 =C2=A0 std</span><span style=3D"color:#660" class=3D"m_4483=
421180951815324styled-by-prettify">::</span><span style=3D"color:#000" clas=
s=3D"m_4483421180951815324styled-by-prettify">basic_istream</span><span sty=
le=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify"><</s=
pan><span style=3D"color:#606" class=3D"m_4483421180951815324styled-by-pret=
tify">CharT</span><span style=3D"color:#660" class=3D"m_4483421180951815324=
styled-by-prettify">,</span><span style=3D"color:#000" class=3D"m_448342118=
0951815324styled-by-prettify"> </span><span style=3D"color:#606" class=3D"m=
_4483421180951815324styled-by-prettify">Traits</span><span style=3D"color:#=
660" class=3D"m_4483421180951815324styled-by-prettify">>&</span><spa=
n style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"> <=
/span><span style=3D"color:#008" class=3D"m_4483421180951815324styled-by-pr=
ettify">is</span><span style=3D"color:#660" class=3D"m_4483421180951815324s=
tyled-by-prettify">,</span><span style=3D"color:#000" class=3D"m_4483421180=
951815324styled-by-prettify"><br>=C2=A0 =C2=A0 bit</span><span style=3D"col=
or:#660" class=3D"m_4483421180951815324styled-by-prettify">&</span><spa=
n style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"> b=
<br></span><span style=3D"color:#660" class=3D"m_4483421180951815324styled-=
by-prettify">)</span><span style=3D"color:#000" class=3D"m_4483421180951815=
324styled-by-prettify"> <br></span><span style=3D"color:#660" class=3D"m_44=
83421180951815324styled-by-prettify">{</span><span style=3D"color:#000" cla=
ss=3D"m_4483421180951815324styled-by-prettify"><br>=C2=A0 =C2=A0 std</span>=
<span style=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify=
">::</span><span style=3D"color:#000" class=3D"m_4483421180951815324styled-=
by-prettify">bitset</span><span style=3D"color:#660" class=3D"m_44834211809=
51815324styled-by-prettify"><</span><span style=3D"color:#066" class=3D"=
m_4483421180951815324styled-by-prettify">1</span><span style=3D"color:#660"=
class=3D"m_4483421180951815324styled-by-prettify">></span><span style=
=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"> bs</span=
><span style=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettif=
y">;</span><span style=3D"color:#000" class=3D"m_4483421180951815324styled-=
by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008" class=3D"m=
_4483421180951815324styled-by-prettify">is</span><span style=3D"color:#000"=
class=3D"m_4483421180951815324styled-by-prettify"> </span><span style=3D"c=
olor:#660" class=3D"m_4483421180951815324styled-by-prettify">>></span=
><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettif=
y"> bs</span><span style=3D"color:#660" class=3D"m_4483421180951815324style=
d-by-prettify">;</span><span style=3D"color:#000" class=3D"m_44834211809518=
15324styled-by-prettify"><br>=C2=A0 =C2=A0 b</span><span style=3D"color:#66=
0" class=3D"m_4483421180951815324styled-by-prettify">.</span><span style=3D=
"color:#000" class=3D"m_4483421180951815324styled-by-prettify">assign</span=
><span style=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettif=
y">(</span><span style=3D"color:#000" class=3D"m_4483421180951815324styled-=
by-prettify">bs</span><span style=3D"color:#660" class=3D"m_448342118095181=
5324styled-by-prettify">[</span><span style=3D"color:#066" class=3D"m_44834=
21180951815324styled-by-prettify">0</span><span style=3D"color:#660" class=
=3D"m_4483421180951815324styled-by-prettify">]);</span><span style=3D"color=
:#000" class=3D"m_4483421180951815324styled-by-prettify"><br>=C2=A0 =C2=A0 =
</span><span style=3D"color:#008" class=3D"m_4483421180951815324styled-by-p=
rettify">return</span><span style=3D"color:#000" class=3D"m_448342118095181=
5324styled-by-prettify"> </span><span style=3D"color:#008" class=3D"m_44834=
21180951815324styled-by-prettify">is</span><span style=3D"color:#660" class=
=3D"m_4483421180951815324styled-by-prettify">;</span><span style=3D"color:#=
000" class=3D"m_4483421180951815324styled-by-prettify"><br></span><span sty=
le=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">}</span=
><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettif=
y"><br><br></span><span style=3D"color:#800" class=3D"m_4483421180951815324=
styled-by-prettify">// Main function</span><span style=3D"color:#000" class=
=3D"m_4483421180951815324styled-by-prettify"><br></span><span style=3D"colo=
r:#008" class=3D"m_4483421180951815324styled-by-prettify">int</span><span s=
tyle=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"> main=
</span><span style=3D"color:#660" class=3D"m_4483421180951815324styled-by-p=
rettify">(</span><span style=3D"color:#008" class=3D"m_4483421180951815324s=
tyled-by-prettify">int</span><span style=3D"color:#000" class=3D"m_44834211=
80951815324styled-by-prettify"> argc</span><span style=3D"color:#660" class=
=3D"m_4483421180951815324styled-by-prettify">,</span><span style=3D"color:#=
000" class=3D"m_4483421180951815324styled-by-prettify"> </span><span style=
=3D"color:#008" class=3D"m_4483421180951815324styled-by-prettify">char</spa=
n><span style=3D"color:#660" class=3D"m_4483421180951815324styled-by-pretti=
fy">*</span><span style=3D"color:#000" class=3D"m_4483421180951815324styled=
-by-prettify"> argv</span><span style=3D"color:#660" class=3D"m_44834211809=
51815324styled-by-prettify">[])</span><span style=3D"color:#000" class=3D"m=
_4483421180951815324styled-by-prettify"><br></span><span style=3D"color:#66=
0" class=3D"m_4483421180951815324styled-by-prettify">{</span><span style=3D=
"color:#000" class=3D"m_4483421180951815324styled-by-prettify"><br>=C2=A0 =
=C2=A0 bit b0</span><span style=3D"color:#660" class=3D"m_44834211809518153=
24styled-by-prettify">(</span><span style=3D"color:#008" class=3D"m_4483421=
180951815324styled-by-prettify">false</span><span style=3D"color:#660" clas=
s=3D"m_4483421180951815324styled-by-prettify">);</span><span style=3D"color=
:#000" class=3D"m_4483421180951815324styled-by-prettify"><br>=C2=A0 =C2=A0 =
bit b1</span><span style=3D"color:#660" class=3D"m_4483421180951815324style=
d-by-prettify">(</span><span style=3D"color:#008" class=3D"m_44834211809518=
15324styled-by-prettify">true</span><span style=3D"color:#660" class=3D"m_4=
483421180951815324styled-by-prettify">);</span><span style=3D"color:#000" c=
lass=3D"m_4483421180951815324styled-by-prettify"><br>=C2=A0 =C2=A0 std</spa=
n><span style=3D"color:#660" class=3D"m_4483421180951815324styled-by-pretti=
fy">::</span><span style=3D"color:#000" class=3D"m_4483421180951815324style=
d-by-prettify">stringstream stream</span><span style=3D"color:#660" class=
=3D"m_4483421180951815324styled-by-prettify">;</span><span style=3D"color:#=
000" class=3D"m_4483421180951815324styled-by-prettify"><br>=C2=A0 =C2=A0 st=
d</span><span style=3D"color:#660" class=3D"m_4483421180951815324styled-by-=
prettify">::</span><span style=3D"color:#000" class=3D"m_448342118095181532=
4styled-by-prettify">cout</span><span style=3D"color:#660" class=3D"m_44834=
21180951815324styled-by-prettify"><<</span><span style=3D"color:#000"=
class=3D"m_4483421180951815324styled-by-prettify">b0</span><span style=3D"=
color:#660" class=3D"m_4483421180951815324styled-by-prettify"><<</spa=
n><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-pretti=
fy">b1</span><span style=3D"color:#660" class=3D"m_4483421180951815324style=
d-by-prettify"><<</span><span style=3D"color:#000" class=3D"m_4483421=
180951815324styled-by-prettify">std</span><span style=3D"color:#660" class=
=3D"m_4483421180951815324styled-by-prettify">::</span><span style=3D"color:=
#000" class=3D"m_4483421180951815324styled-by-prettify">endl</span><span st=
yle=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">;</spa=
n><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-pretti=
fy"><br>=C2=A0 =C2=A0 stream</span><span style=3D"color:#660" class=3D"m_44=
83421180951815324styled-by-prettify"><<</span><span style=3D"color:#0=
80" class=3D"m_4483421180951815324styled-by-prettify">" =C2=A0 =C2=A0&=
quot;</span><span style=3D"color:#660" class=3D"m_4483421180951815324styled=
-by-prettify"><<</span><span style=3D"color:#000" class=3D"m_44834211=
80951815324styled-by-prettify">b0</span><span style=3D"color:#660" class=3D=
"m_4483421180951815324styled-by-prettify"><<</span><span style=3D"col=
or:#000" class=3D"m_4483421180951815324styled-by-prettify">b1</span><span s=
tyle=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">;</sp=
an><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prett=
ify"><br>=C2=A0 =C2=A0 stream</span><span style=3D"color:#660" class=3D"m_4=
483421180951815324styled-by-prettify">>></span><span style=3D"color:#=
000" class=3D"m_4483421180951815324styled-by-prettify">b1</span><span style=
=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">>><=
/span><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-pr=
ettify">b0</span><span style=3D"color:#660" class=3D"m_4483421180951815324s=
tyled-by-prettify">;</span><span style=3D"color:#000" class=3D"m_4483421180=
951815324styled-by-prettify"><br>=C2=A0 =C2=A0 std</span><span style=3D"col=
or:#660" class=3D"m_4483421180951815324styled-by-prettify">::</span><span s=
tyle=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify">cout<=
/span><span style=3D"color:#660" class=3D"m_4483421180951815324styled-by-pr=
ettify"><<</span><span style=3D"color:#000" class=3D"m_44834211809518=
15324styled-by-prettify">b0</span><span style=3D"color:#660" class=3D"m_448=
3421180951815324styled-by-prettify"><<</span><span style=3D"color:#00=
0" class=3D"m_4483421180951815324styled-by-prettify">b1</span><span style=
=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify"><<<=
/span><span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-pr=
ettify">std</span><span style=3D"color:#660" class=3D"m_4483421180951815324=
styled-by-prettify">::</span><span style=3D"color:#000" class=3D"m_44834211=
80951815324styled-by-prettify">endl</span><span style=3D"color:#660" class=
=3D"m_4483421180951815324styled-by-prettify">;</span><span style=3D"color:#=
000" class=3D"m_4483421180951815324styled-by-prettify"><br>=C2=A0 =C2=A0 </=
span><span style=3D"color:#008" class=3D"m_4483421180951815324styled-by-pre=
ttify">return</span><span style=3D"color:#000" class=3D"m_44834211809518153=
24styled-by-prettify"> </span><span style=3D"color:#066" class=3D"m_4483421=
180951815324styled-by-prettify">0</span><span style=3D"color:#660" class=3D=
"m_4483421180951815324styled-by-prettify">;</span><span style=3D"color:#000=
" class=3D"m_4483421180951815324styled-by-prettify"><br></span><span style=
=3D"color:#660" class=3D"m_4483421180951815324styled-by-prettify">}</span><=
span style=3D"color:#000" class=3D"m_4483421180951815324styled-by-prettify"=
><br></span><br><code class=3D"m_4483421180951815324prettyprint"><span styl=
e=3D"color:#800" class=3D"m_4483421180951815324styled-by-prettify">// =3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D<wbr>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<wbr>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D //</span><span style=3D"color:#000" class=3D"m_4483421180951815324st=
yled-by-prettify"></span></code><br></div></code></div>The bit class is jus=
t a simplified version of the classes introduced in P0237R3 to illustrate m=
y problem. My question is the following: how should the output <span style=
=3D"font-family:courier new,monospace">operator<<</span> and the inpu=
t <span style=3D"font-family:courier new,monospace">operator>></span>=
be formally specified for bits and what a conforming implementation should=
look like? In the feedback I received, using numeric facet was suggested, =
but as it's not at all my area of expertise (I basically never used fac=
ets), I am asking for help (should a numeric facet specialization/overload =
be created to deal with bits, or should I use the existing ones, I don'=
t even know). Could people with experience with input/output and facets cla=
rify what the wording should look like and what the implementation should b=
e like?<br><br>Thank you very much,<br>Vincent Reverdy<span class=3D"HOEnZb=
"><font color=3D"#888888"><br></font></span></div><span class=3D"HOEnZb"><f=
ont color=3D"#888888">
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/ffa1a664-51ae-4cd3-8058-d184b85743f0%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/ffa1=
a664-51ae-4cd3-<wbr>8058-d184b85743f0%40isocpp.org</a><wbr>.<br>
</font></span></blockquote></div><br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAKiZDp0Z_i7i_r9QXMVXow29y78CFnxqNmRj=
Ffso31Xu0C15Fg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAKiZDp0Z_i7i_r9Q=
XMVXow29y78CFnxqNmRjFfso31Xu0C15Fg%40mail.gmail.com</a>.<br />
--001a11438e2acabd110541cd664a--
.
Author: Vincent Reverdy <vince.rev@gmail.com>
Date: Mon, 21 Nov 2016 07:25:14 -0800 (PST)
Raw View
------=_Part_7658_1242330888.1479741914504
Content-Type: multipart/alternative;
boundary="----=_Part_7659_1150938015.1479741914505"
------=_Part_7659_1150938015.1479741914505
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
To be honest... I have no idea... because I am not a user of=20
locales/facets/special formatting, for me a universal 0/1 representation=20
would be ok.=20
I guess that if the result is the same as with std::bitset<1>, everyone=20
will be happy.
Le lundi 21 novembre 2016 04:48:54 UTC-6, Patrice Roy a =C3=A9crit :
>
> Curiosity : what is the expectation with respect to locale-related bit=20
> I/O? I would have expected a =C2=ABuniversal=C2=BB 0/1 representation, wh=
ich would=20
> simplify things a lot in your case, but that might be my=20
> less-than-sufficient understanding of per-locale bit representation rules=
=20
> showing.
>
> Having a better idea as to what the expectations are would be useful in=
=20
> assisting you, in any case. Cheers!
>
> 2016-11-20 22:54 GMT-05:00 Vincent Reverdy <vinc...@gmail.com=20
> <javascript:>>:
>
>> Hello.
>>
>> During the Issaquah meeting, I got feedback on P0237R3=20
>> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0237r3.html>=
=20
>> (fundamental bit utilities) and I am facing a problem with facets. Here =
is=20
>> a simpler version of the problem. Consider the following code:
>> //=20
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=20
>> //
>> // Preamble
>> #include <bitset>
>> #include <sstream>
>> #include <iostream>
>>
>> // Bit wrapper (simplified version of bit_value in P0237R3)
>> class bit
>> {
>> // Public members
>> public:
>> explicit constexpr bit(bool value) noexcept: _value(value) {}
>> explicit constexpr operator bool() const noexcept {return _value
>> ;}
>> bit& assign(bool value) noexcept {_value =3D value; return *this=
;}
>> void set() noexcept {_value =3D true;}
>> void reset() noexcept {_value =3D false;}
>> void flip() noexcept {_value =3D !_value;}
>> // Data members
>> private:
>> bool _value;
>> };
>>
>> // Output
>> template <class CharT, class Traits>
>> std::basic_ostream<CharT, Traits>& operator<<(
>> std::basic_ostream<CharT, Traits>& os,
>> bit b
>> )=20
>> {
>> std::bitset<1> bs(static_cast<bool>(b));
>> return os << bs;
>> }
>>
>> // Input
>> template <class CharT, class Traits>
>> std::basic_istream<CharT, Traits>& operator>>(
>> std::basic_istream<CharT, Traits>& is,
>> bit& b
>> )=20
>> {
>> std::bitset<1> bs;
>> is >> bs;
>> b.assign(bs[0]);
>> return is;
>> }
>>
>> // Main function
>> int main(int argc, char* argv[])
>> {
>> bit b0(false);
>> bit b1(true);
>> std::stringstream stream;
>> std::cout<<b0<<b1<<std::endl;
>> stream<<" "<<b0<<b1;
>> stream>>b1>>b0;
>> std::cout<<b0<<b1<<std::endl;
>> return 0;
>> }
>>
>> //=20
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=20
>> //
>> The bit class is just a simplified version of the classes introduced in=
=20
>> P0237R3 to illustrate my problem. My question is the following: how shou=
ld=20
>> the output operator<< and the input operator>> be formally specified for=
=20
>> bits and what a conforming implementation should look like? In the feedb=
ack=20
>> I received, using numeric facet was suggested, but as it's not at all my=
=20
>> area of expertise (I basically never used facets), I am asking for help=
=20
>> (should a numeric facet specialization/overload be created to deal with=
=20
>> bits, or should I use the existing ones, I don't even know). Could peopl=
e=20
>> with experience with input/output and facets clarify what the wording=20
>> should look like and what the implementation should be like?
>>
>> Thank you very much,
>> Vincent Reverdy
>>
>> --=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=20
>> email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> To view this discussion on the web visit=20
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ffa1a664-51=
ae-4cd3-8058-d184b85743f0%40isocpp.org=20
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ffa1a664-5=
1ae-4cd3-8058-d184b85743f0%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoo=
ter>
>> .
>>
>
>
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/d0769dfa-101f-41af-9abf-8aabc766700e%40isocpp.or=
g.
------=_Part_7659_1150938015.1479741914505
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">To be honest... I have no idea... because I am not a user =
of locales/facets/special formatting, for me a universal 0/1 representation=
would be ok. <br>I guess that if the result is the same as with std::bitse=
t<1>, everyone will be happy.<br><br>Le lundi 21 novembre 2016 04:48:=
54 UTC-6, Patrice Roy a =C3=A9crit=C2=A0:<blockquote class=3D"gmail_quote" =
style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-l=
eft: 1ex;"><div dir=3D"ltr"><div>Curiosity : what is the expectation with r=
espect to locale-related bit I/O? I would have expected a =C2=ABuniversal=
=C2=BB 0/1 representation, which would simplify things a lot in your case, =
but that might be my less-than-sufficient understanding of per-locale bit r=
epresentation rules showing.<br><br></div>Having a better idea as to what t=
he expectations are would be useful in assisting you, in any case. Cheers!<=
br></div><div><br><div class=3D"gmail_quote">2016-11-20 22:54 GMT-05:00 Vin=
cent Reverdy <span dir=3D"ltr"><<a href=3D"javascript:" target=3D"_blank=
" gdf-obfuscated-mailto=3D"VzNINfKvAgAJ" rel=3D"nofollow" onmousedown=3D"th=
is.href=3D'javascript:';return true;" onclick=3D"this.href=3D'j=
avascript:';return true;">vinc...@gmail.com</a>></span>:<br><blockqu=
ote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr">Hello.<br><br>During the Issaquah m=
eeting, I got feedback on <a href=3D"http://www.open-std.org/jtc1/sc22/wg21=
/docs/papers/2016/p0237r3.html" target=3D"_blank" rel=3D"nofollow" onmoused=
own=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.ope=
n-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2016%2Fp0237r3.html\x26sa\=
x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF6rN4TKslvgWUSfSF1dwaVdu-FNQ';return =
true;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2=
F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2016%2Fp0237r3.=
html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF6rN4TKslvgWUSfSF1dwaVdu-FNQ&#=
39;;return true;">P0237R3</a> (fundamental bit utilities) and I am facing a=
problem with facets. Here is a simpler version of the problem. Consider th=
e following code:<br><div style=3D"background-color:rgb(250,250,250);border=
-color:rgb(187,187,187);border-style:solid;border-width:1px"><code><div><sp=
an style=3D"color:#800">// =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<wbr>=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<wbr>=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D //</span><span style=3D"color:#000"><b=
r></span><span style=3D"color:#800">// Preamble</span><span style=3D"color:=
#000"><br></span><span style=3D"color:#800">#include</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#080"><bitset></span><span st=
yle=3D"color:#000"><br></span><span style=3D"color:#800">#include</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#080"><sstream><=
/span><span style=3D"color:#000"><br></span><span style=3D"color:#800">#inc=
lude</span><span style=3D"color:#000"> </span><span style=3D"color:#080">&l=
t;iostream></span><span style=3D"color:#000"><br><br></span><span style=
=3D"color:#800">// Bit wrapper (simplified version of bit_value in P0237R3)=
</span><span style=3D"color:#000"><br></span><span style=3D"color:#008">cla=
ss</span><span style=3D"color:#000"> bit<br></span><span style=3D"color:#66=
0">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#800">// Public members</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 </span><span style=3D"color:#008">public</span><span style=3D"co=
lor:#660">:</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 </span><span style=3D"color:#008">explicit</span><span style=3D"color:#=
000"> </span><span style=3D"color:#008">constexpr</span><span style=3D"colo=
r:#000"> bit</span><span style=3D"color:#660">(</span><span style=3D"color:=
#008">bool</span><span style=3D"color:#000"> value</span><span style=3D"col=
or:#660">)</span><span style=3D"color:#000"> noexcept</span><span style=3D"=
color:#660">:</span><span style=3D"color:#000"> _value</span><span style=3D=
"color:#660">(</span><span style=3D"color:#000">value</span><span style=3D"=
color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color=
:#660">{}</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
</span><span style=3D"color:#008">explicit</span><span style=3D"color:#000"=
> </span><span style=3D"color:#008">constexpr</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#008">operator</span><span style=3D"color:=
#000"> </span><span style=3D"color:#008">bool</span><span style=3D"color:#6=
60">()</span><span style=3D"color:#000"> </span><span style=3D"color:#008">=
const</span><span style=3D"color:#000"> noexcept </span><span style=3D"colo=
r:#660">{</span><span style=3D"color:#008">return</span><span style=3D"colo=
r:#000"> _value</span><span style=3D"color:#660">;}</span><span style=3D"co=
lor:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 bit</span><span style=3D"color:#6=
60">&</span><span style=3D"color:#000"> assign</span><span style=3D"col=
or:#660">(</span><span style=3D"color:#008">bool</span><span style=3D"color=
:#000"> value</span><span style=3D"color:#660">)</span><span style=3D"color=
:#000"> noexcept </span><span style=3D"color:#660">{</span><span style=3D"c=
olor:#000">_value </span><span style=3D"color:#660">=3D</span><span style=
=3D"color:#000"> value</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">return</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">*</span><span style=3D"c=
olor:#008">this</span><span style=3D"color:#660">;}</span><span style=3D"co=
lor:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008"=
>void</span><span style=3D"color:#000"> </span><span style=3D"color:#008">s=
et</span><span style=3D"color:#660">()</span><span style=3D"color:#000"> no=
except </span><span style=3D"color:#660">{</span><span style=3D"color:#000"=
>_value </span><span style=3D"color:#660">=3D</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#008">true</span><span style=3D"color:#660=
">;}</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </spa=
n><span style=3D"color:#008">void</span><span style=3D"color:#000"> reset</=
span><span style=3D"color:#660">()</span><span style=3D"color:#000"> noexce=
pt </span><span style=3D"color:#660">{</span><span style=3D"color:#000">_va=
lue </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000">=
</span><span style=3D"color:#008">false</span><span style=3D"color:#660">;=
}</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><=
span style=3D"color:#008">void</span><span style=3D"color:#000"> flip</span=
><span style=3D"color:#660">()</span><span style=3D"color:#000"> noexcept <=
/span><span style=3D"color:#660">{</span><span style=3D"color:#000">_value =
</span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#660">!</span><span style=3D"color:#000">_value</s=
pan><span style=3D"color:#660">;}</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 </span><span style=3D"color:#800">// Data members</span><span st=
yle=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">priv=
ate</span><span style=3D"color:#660">:</span><span style=3D"color:#000"><br=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">bool</span><=
span style=3D"color:#000"> _value</span><span style=3D"color:#660">;</span>=
<span style=3D"color:#000"><br></span><span style=3D"color:#660">};</span><=
span style=3D"color:#000"><br><br></span><span style=3D"color:#800">// Outp=
ut</span><span style=3D"color:#000"><br></span><span style=3D"color:#008">t=
emplate</span><span style=3D"color:#000"> </span><span style=3D"color:#660"=
><</span><span style=3D"color:#008">class</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#606">CharT</span><span style=3D"color:#660=
">,</span><span style=3D"color:#000"> </span><span style=3D"color:#008">cla=
ss</span><span style=3D"color:#000"> </span><span style=3D"color:#606">Trai=
ts</span><span style=3D"color:#660">></span><span style=3D"color:#000"><=
br>std</span><span style=3D"color:#660">::</span><span style=3D"color:#000"=
>basic_ostream</span><span style=3D"color:#660"><</span><span style=3D"c=
olor:#606">CharT</span><span style=3D"color:#660">,</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#606">Traits</span><span style=3D"co=
lor:#660">>&</span><span style=3D"color:#000"> </span><span style=3D=
"color:#008">operator</span><span style=3D"color:#660"><<(</span><spa=
n style=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><span style=3D"color:#66=
0">::</span><span style=3D"color:#000">basic_ostream</span><span style=3D"c=
olor:#660"><</span><span style=3D"color:#606">CharT</span><span style=3D=
"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#606">Traits</span><span style=3D"color:#660">>&</span><span style=
=3D"color:#000"> os</span><span style=3D"color:#660">,</span><span style=3D=
"color:#000"><br>=C2=A0 =C2=A0 bit b<br></span><span style=3D"color:#660">)=
</span><span style=3D"color:#000"> <br></span><span style=3D"color:#660">{<=
/span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><span style=3D=
"color:#660">::</span><span style=3D"color:#000">bitset</span><span style=
=3D"color:#660"><</span><span style=3D"color:#066">1</span><span style=
=3D"color:#660">></span><span style=3D"color:#000"> bs</span><span style=
=3D"color:#660">(</span><span style=3D"color:#008">static_cast</span><span =
style=3D"color:#080"><bool></span><span style=3D"color:#660">(</span>=
<span style=3D"color:#000">b</span><span style=3D"color:#660">));</span><sp=
an style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008"=
>return</span><span style=3D"color:#000"> os </span><span style=3D"color:#6=
60"><<</span><span style=3D"color:#000"> bs</span><span style=3D"colo=
r:#660">;</span><span style=3D"color:#000"><br></span><span style=3D"color:=
#660">}</span><span style=3D"color:#000"><br><br></span><span style=3D"colo=
r:#800">// Input</span><span style=3D"color:#000"><br></span><span style=3D=
"color:#008">template</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660"><</span><span style=3D"color:#008">class</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#606">CharT</span><span styl=
e=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"=
color:#008">class</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#606">Traits</span><span style=3D"color:#660">></span><span style=
=3D"color:#000"><br>std</span><span style=3D"color:#660">::</span><span sty=
le=3D"color:#000">basic_istream</span><span style=3D"color:#660"><</span=
><span style=3D"color:#606">CharT</span><span style=3D"color:#660">,</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#606">Traits</span>=
<span style=3D"color:#660">>&</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#008">operator</span><span style=3D"color:#660">>=
;>(</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><span s=
tyle=3D"color:#660">::</span><span style=3D"color:#000">basic_istream</span=
><span style=3D"color:#660"><</span><span style=3D"color:#606">CharT</sp=
an><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#606">Traits</span><span style=3D"color:#660">>&<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#008">is</spa=
n><span style=3D"color:#660">,</span><span style=3D"color:#000"><br>=C2=A0 =
=C2=A0 bit</span><span style=3D"color:#660">&</span><span style=3D"colo=
r:#000"> b<br></span><span style=3D"color:#660">)</span><span style=3D"colo=
r:#000"> <br></span><span style=3D"color:#660">{</span><span style=3D"color=
:#000"><br>=C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><spa=
n style=3D"color:#000">bitset</span><span style=3D"color:#660"><</span><=
span style=3D"color:#066">1</span><span style=3D"color:#660">></span><sp=
an style=3D"color:#000"> bs</span><span style=3D"color:#660">;</span><span =
style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">is=
</span><span style=3D"color:#000"> </span><span style=3D"color:#660">>&g=
t;</span><span style=3D"color:#000"> bs</span><span style=3D"color:#660">;<=
/span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 b</span><span style=3D"c=
olor:#660">.</span><span style=3D"color:#000">assign</span><span style=3D"c=
olor:#660">(</span><span style=3D"color:#000">bs</span><span style=3D"color=
:#660">[</span><span style=3D"color:#066">0</span><span style=3D"color:#660=
">]);</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#008">return</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">is</span><span style=3D"color:#660">;</span><span style=3D"=
color:#000"><br></span><span style=3D"color:#660">}</span><span style=3D"co=
lor:#000"><br><br></span><span style=3D"color:#800">// Main function</span>=
<span style=3D"color:#000"><br></span><span style=3D"color:#008">int</span>=
<span style=3D"color:#000"> main</span><span style=3D"color:#660">(</span><=
span style=3D"color:#008">int</span><span style=3D"color:#000"> argc</span>=
<span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span=
style=3D"color:#008">char</span><span style=3D"color:#660">*</span><span s=
tyle=3D"color:#000"> argv</span><span style=3D"color:#660">[])</span><span =
style=3D"color:#000"><br></span><span style=3D"color:#660">{</span><span st=
yle=3D"color:#000"><br>=C2=A0 =C2=A0 bit b0</span><span style=3D"color:#660=
">(</span><span style=3D"color:#008">false</span><span style=3D"color:#660"=
>);</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 bit b1</span><span s=
tyle=3D"color:#660">(</span><span style=3D"color:#008">true</span><span sty=
le=3D"color:#660">);</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std=
</span><span style=3D"color:#660">::</span><span style=3D"color:#000">strin=
gstream stream</span><span style=3D"color:#660">;</span><span style=3D"colo=
r:#000"><br>=C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><sp=
an style=3D"color:#000">cout</span><span style=3D"color:#660"><<</spa=
n><span style=3D"color:#000">b0</span><span style=3D"color:#660"><<</=
span><span style=3D"color:#000">b1</span><span style=3D"color:#660"><<=
;</span><span style=3D"color:#000">std</span><span style=3D"color:#660">::<=
/span><span style=3D"color:#000">endl</span><span style=3D"color:#660">;</s=
pan><span style=3D"color:#000"><br>=C2=A0 =C2=A0 stream</span><span style=
=3D"color:#660"><<</span><span style=3D"color:#080">" =C2=A0 =C2=
=A0"</span><span style=3D"color:#660"><<</span><span style=3D"co=
lor:#000">b0</span><span style=3D"color:#660"><<</span><span style=3D=
"color:#000">b1</span><span style=3D"color:#660">;</span><span style=3D"col=
or:#000"><br>=C2=A0 =C2=A0 stream</span><span style=3D"color:#660">>>=
</span><span style=3D"color:#000">b1</span><span style=3D"color:#660">>&=
gt;</span><span style=3D"color:#000">b0</span><span style=3D"color:#660">;<=
/span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 std</span><span style=3D=
"color:#660">::</span><span style=3D"color:#000">cout</span><span style=3D"=
color:#660"><<</span><span style=3D"color:#000">b0</span><span style=
=3D"color:#660"><<</span><span style=3D"color:#000">b1</span><span st=
yle=3D"color:#660"><<</span><span style=3D"color:#000">std</span><spa=
n style=3D"color:#660">::</span><span style=3D"color:#000">endl</span><span=
style=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =
</span><span style=3D"color:#008">return</span><span style=3D"color:#000"> =
</span><span style=3D"color:#066">0</span><span style=3D"color:#660">;</spa=
n><span style=3D"color:#000"><br></span><span style=3D"color:#660">}</span>=
<span style=3D"color:#000"><br></span><br><code><span style=3D"color:#800">=
// =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D<wbr>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<wbr>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D //</span><span style=3D"color:#000"></span></code><br></div></=
code></div>The bit class is just a simplified version of the classes introd=
uced in P0237R3 to illustrate my problem. My question is the following: how=
should the output <span style=3D"font-family:courier new,monospace">operat=
or<<</span> and the input <span style=3D"font-family:courier new,mono=
space">operator>></span> be formally specified for bits and what a co=
nforming implementation should look like? In the feedback I received, using=
numeric facet was suggested, but as it's not at all my area of experti=
se (I basically never used facets), I am asking for help (should a numeric =
facet specialization/overload be created to deal with bits, or should I use=
the existing ones, I don't even know). Could people with experience wi=
th input/output and facets clarify what the wording should look like and wh=
at the implementation should be like?<br><br>Thank you very much,<br>Vincen=
t Reverdy<span><font color=3D"#888888"><br></font></span></div><span><font =
color=3D"#888888">
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
VzNINfKvAgAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:&=
#39;;return true;" onclick=3D"this.href=3D'javascript:';return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"VzNINfKvAgAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'=
;javascript:';return true;">std-pr...@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/ffa1a664-51ae-4cd3-8058-d184b85743f0%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D'https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/ffa1a664-51ae-4cd3-8058-d184b85743f0%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter';return true;" on=
click=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/ffa1a664-51ae-4cd3-8058-d184b85743f0%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter';return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/ffa1a664-51ae-4cd3-<wbr>8058-=
d184b85743f0%40isocpp.org</a><wbr>.<br>
</font></span></blockquote></div><br></div>
</blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/d0769dfa-101f-41af-9abf-8aabc766700e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d0769dfa-101f-41af-9abf-8aabc766700e=
%40isocpp.org</a>.<br />
------=_Part_7659_1150938015.1479741914505--
------=_Part_7658_1242330888.1479741914504--
.
Author: David Krauss <potswa@gmail.com>
Date: Tue, 22 Nov 2016 00:22:08 +0800
Raw View
--Apple-Mail=_1FEC679C-C86F-4BFE-8703-89ED66CB255B
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
What is the facet supposed to add?
There=E2=80=99s a definitely a design decision to be made about how to rend=
er bit:
as a bool (which already has a customization point in std::numpunct)
as an int
always as a binary digit (=E2=80=980=E2=80=99 or =E2=80=981=E2=80=99) regar=
dless of the ios::showbase and ios::boolalpha flags
something more complicated: a new facet which returns =E2=80=9C0=E2=80=9D a=
nd =E2=80=9C1=E2=80=9D from virtual calls but the user can subclass it to s=
pecify custom strings.
Since the user can already cast to bool or to int, (1) and (2) seem redunda=
nt. (3) is like what bitset does, which is how you coded your example. (4) =
is a headache that nobody will ever use, and it adds runtime overhead to th=
e common case.
Extending existing facets is not an option because it would break ABIs.
My 2=C2=A2, your current solution is the simplest and best one.
> On 2016=E2=80=9311=E2=80=9321, at 11:54 AM, Vincent Reverdy <vince.rev@gm=
ail.com> wrote:
>=20
> Hello.
>=20
> During the Issaquah meeting, I got feedback on P0237R3 <http://www.open-s=
td.org/jtc1/sc22/wg21/docs/papers/2016/p0237r3.html> (fundamental bit utili=
ties) and I am facing a problem with facets. Here is a simpler version of t=
he problem. Consider the following code:
> // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D //
> // Preamble
> #include <bitset>
> #include <sstream>
> #include <iostream>
>=20
> // Bit wrapper (simplified version of bit_value in P0237R3)
> class bit
> {
> // Public members
> public:
> explicit constexpr bit(bool value) noexcept: _value(value) {}
> explicit constexpr operator bool() const noexcept {return _value;=
}
> bit& assign(bool value) noexcept {_value =3D value; return *this;=
}
> void set() noexcept {_value =3D true;}
> void reset() noexcept {_value =3D false;}
> void flip() noexcept {_value =3D !_value;}
> // Data members
> private:
> bool _value;
> };
>=20
> // Output
> template <class CharT, class Traits>
> std::basic_ostream<CharT, Traits>& operator<<(
> std::basic_ostream<CharT, Traits>& os,
> bit b
> )=20
> {
> std::bitset<1> bs(static_cast<bool>(b));
> return os << bs;
> }
>=20
> // Input
> template <class CharT, class Traits>
> std::basic_istream<CharT, Traits>& operator>>(
> std::basic_istream<CharT, Traits>& is,
> bit& b
> )=20
> {
> std::bitset<1> bs;
> is >> bs;
> b.assign(bs[0]);
> return is;
> }
>=20
> // Main function
> int main(int argc, char* argv[])
> {
> bit b0(false);
> bit b1(true);
> std::stringstream stream;
> std::cout<<b0<<b1<<std::endl;
> stream<<" "<<b0<<b1;
> stream>>b1>>b0;
> std::cout<<b0<<b1<<std::endl;
> return 0;
> }
>=20
> // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D //
> The bit class is just a simplified version of the classes introduced in P=
0237R3 to illustrate my problem. My question is the following: how should t=
he output operator<< and the input operator>> be formally specified for bit=
s and what a conforming implementation should look like? In the feedback I =
received, using numeric facet was suggested, but as it's not at all my area=
of expertise (I basically never used facets), I am asking for help (should=
a numeric facet specialization/overload be created to deal with bits, or s=
hould I use the existing ones, I don't even know). Could people with experi=
ence with input/output and facets clarify what the wording should look like=
and what the implementation should be like?
>=20
> Thank you very much,
> Vincent Reverdy
>=20
> --=20
> You received this message because you are subscribed to the Google Groups=
"ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an=
email to std-proposals+unsubscribe@isocpp.org <mailto:std-proposals+unsubs=
cribe@isocpp.org>.
> To post to this group, send email to std-proposals@isocpp.org <mailto:std=
-proposals@isocpp.org>.
> To view this discussion on the web visit https://groups.google.com/a/isoc=
pp.org/d/msgid/std-proposals/ffa1a664-51ae-4cd3-8058-d184b85743f0%40isocpp.=
org <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ffa1a664-=
51ae-4cd3-8058-d184b85743f0%40isocpp.org?utm_medium=3Demail&utm_source=3Dfo=
oter>.
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/173650C3-00A6-4B4A-A6A8-A572CF0CC1C1%40gmail.com=
..
--Apple-Mail=_1FEC679C-C86F-4BFE-8703-89ED66CB255B
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D"">What is the facet =
supposed to add?<div class=3D""><br class=3D""></div><div class=3D"">There=
=E2=80=99s a definitely a design decision to be made about how to render <f=
ont face=3D"Courier" class=3D"">bit</font>:</div><div class=3D""><br class=
=3D""></div><div class=3D""><ol class=3D"MailOutline"><li class=3D"">as a <=
font face=3D"Courier" class=3D"">bool</font> (which already has a cust=
omization point in <font face=3D"Courier" class=3D"">std::numpunct</font>)<=
/li><li class=3D"">as an <font face=3D"Courier" class=3D"">int</font></li><=
li class=3D"">always as a binary digit (=E2=80=980=E2=80=99 or =E2=80=981=
=E2=80=99) regardless of the <font face=3D"Courier" class=3D"">ios::showbas=
e</font> and <span style=3D"font-family: Courier;" class=3D"">ios=
::boolalpha</span> flags</li><li class=3D"">something more complicated=
: a new facet which returns =E2=80=9C0=E2=80=9D and =E2=80=9C1=E2=80=9D fro=
m virtual calls but the user can subclass it to specify custom strings.</li=
></ol></div><div class=3D""><br class=3D""></div><div class=3D"">Since the =
user can already cast to <span style=3D"font-family: Courier;" class=
=3D"">bool</span> or to <span style=3D"font-family: Courier;" cla=
ss=3D"">int</span>, (1) and (2) seem redundant. (3) is like what <font face=
=3D"Courier" class=3D"">bitset</font> does, which is how you coded your exa=
mple. (4) is a headache that nobody will ever use, and it adds runtime over=
head to the common case.</div><div class=3D""><br class=3D""></div><div cla=
ss=3D"">Extending existing facets is not an option because it would break A=
BIs.<br class=3D""><div class=3D""><br class=3D""></div><div class=3D"">My =
2=C2=A2, your current solution is the simplest and best one.</div><div clas=
s=3D""><br class=3D""><div class=3D""><br class=3D""><div><blockquote type=
=3D"cite" class=3D""><div class=3D"">On 2016=E2=80=9311=E2=80=9321, at 11:5=
4 AM, Vincent Reverdy <<a href=3D"mailto:vince.rev@gmail.com" class=3D""=
>vince.rev@gmail.com</a>> wrote:</div><br class=3D"Apple-interchange-new=
line"><div class=3D""><div dir=3D"ltr" class=3D"">Hello.<br class=3D""><br =
class=3D"">During the Issaquah meeting, I got feedback on <a href=3D"http:/=
/www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0237r3.html" class=3D"">=
P0237R3</a> (fundamental bit utilities) and I am facing a problem with face=
ts. Here is a simpler version of the problem. Consider the following code:<=
br class=3D""><div style=3D"background-color: rgb(250, 250, 250); border-co=
lor: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflow-w=
rap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div cl=
ass=3D"subprettyprint"><span style=3D"color: #800;" class=3D"styled-by-pret=
tify">// =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D //</span><span style=3D"" class=3D"styled-by-prettify"><br class=3D"=
"></span><span style=3D"color: #800;" class=3D"styled-by-prettify">// Pream=
ble</span><span style=3D"" class=3D"styled-by-prettify"><br class=3D""></sp=
an><span style=3D"color: #800;" class=3D"styled-by-prettify">#include</span=
><span style=3D"" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #080;" class=3D"styled-by-prettify"><bitset></span><span style=3D""=
class=3D"styled-by-prettify"><br class=3D""></span><span style=3D"color: #=
800;" class=3D"styled-by-prettify">#include</span><span style=3D"" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-b=
y-prettify"><sstream></span><span style=3D"" class=3D"styled-by-prett=
ify"><br class=3D""></span><span style=3D"color: #800;" class=3D"styled-by-=
prettify">#include</span><span style=3D"" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #080;" class=3D"styled-by-prettify"><iostream&=
gt;</span><span style=3D"" class=3D"styled-by-prettify"><br class=3D""><br =
class=3D""></span><span style=3D"color: #800;" class=3D"styled-by-prettify"=
>// Bit wrapper (simplified version of bit_value in P0237R3)</span><span st=
yle=3D"" class=3D"styled-by-prettify"><br class=3D""></span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">class</span><span style=3D"" cla=
ss=3D"styled-by-prettify"> bit<br class=3D""></span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">{</span><span style=3D"" class=3D"styled=
-by-prettify"><br class=3D""> </span><span style=3D"color: #80=
0;" class=3D"styled-by-prettify">// Public members</span><span style=3D"" c=
lass=3D"styled-by-prettify"><br class=3D""> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">public</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"" class=
=3D"styled-by-prettify"><br class=3D""> </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">explicit</span><sp=
an style=3D"" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">constexpr</span><span style=3D"" class=3D=
"styled-by-prettify"> bit</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">bool</span><span style=3D"" class=3D"styled-by-prettify"> value</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span st=
yle=3D"" class=3D"styled-by-prettify"> noexcept</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">:</span><span style=3D"" class=3D"styl=
ed-by-prettify"> _value</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(</span><span style=3D"" class=3D"styled-by-prettify">value</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span=
style=3D"" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">{}</span><span style=3D"" class=3D"styled-b=
y-prettify"><br class=3D""> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">explicit</span><span style=
=3D"" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">constexpr</span><span style=3D"" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">operator</span><span style=3D"" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D""=
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">const</span><span style=3D"" class=3D"styled-by-pretti=
fy"> noexcept </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">{</span><span style=3D"color: #008;" class=3D"styled-by-prettify">retur=
n</span><span style=3D"" class=3D"styled-by-prettify"> _value</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">;}</span><span style=3D"=
" class=3D"styled-by-prettify"><br class=3D""> b=
it</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&</s=
pan><span style=3D"" class=3D"styled-by-prettify"> assign</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">bool</span><span style=3D"" class=3D"=
styled-by-prettify"> value</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">)</span><span style=3D"" class=3D"styled-by-prettify"> noex=
cept </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span style=3D"" class=3D"styled-by-prettify">_value </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"" c=
lass=3D"styled-by-prettify"> value</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">return=
</span><span style=3D"" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">this</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">;}</span><span style=3D"" class=3D"styled-by-p=
rettify"><br class=3D""> </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">void</span><span style=3D"" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">set</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">()</span><span style=3D"" class=3D"styled-by-prettify"> noexcept </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><spa=
n style=3D"" class=3D"styled-by-prettify">_value </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">true</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">;}</span><span style=3D"" class=3D"styled-by-prettify"><br class=3D"">=
</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">void</span><span style=3D"" class=3D"styled-by-prettify">=
reset</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</=
span><span style=3D"" class=3D"styled-by-prettify"> noexcept </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D""=
class=3D"styled-by-prettify">_value </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">=3D</span><span style=3D"" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">f=
alse</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;}</sp=
an><span style=3D"" class=3D"styled-by-prettify"><br class=3D""> &nbs=
p; </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">void</span><span style=3D"" class=3D"styled-by-prettify"> flip</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span s=
tyle=3D"" class=3D"styled-by-prettify"> noexcept </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">{</span><span style=3D"" class=3D"st=
yled-by-prettify">_value </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">=3D</span><span style=3D"" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">!</span><span=
style=3D"" class=3D"styled-by-prettify">_value</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">;}</span><span style=3D"" class=3D"sty=
led-by-prettify"><br class=3D""> </span><span style=3D"color: =
#800;" class=3D"styled-by-prettify">// Data members</span><span style=3D"" =
class=3D"styled-by-prettify"><br class=3D""> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">private</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"" cla=
ss=3D"styled-by-prettify"><br class=3D""> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span=
style=3D"" class=3D"styled-by-prettify"> _value</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">;</span><span style=3D"" class=3D"sty=
led-by-prettify"><br class=3D""></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">};</span><span style=3D"" class=3D"styled-by-pretti=
fy"><br class=3D""><br class=3D""></span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">// Output</span><span style=3D"" class=3D"styled-by=
-prettify"><br class=3D""></span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">template</span><span style=3D"" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><=
span style=3D"" class=3D"styled-by-prettify"> </span><span style=3D"color: =
#606;" class=3D"styled-by-prettify">CharT</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">,</span><span style=3D"" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>class</span><span style=3D"" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #606;" class=3D"styled-by-prettify">Traits</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">></span><span style=3D"" =
class=3D"styled-by-prettify"><br class=3D"">std</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">::</span><span style=3D"" class=3D"sty=
led-by-prettify">basic_ostream</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify"><</span><span style=3D"color: #606;" class=3D"styled=
-by-prettify">CharT</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">,</span><span style=3D"" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">Traits</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">>&</span><span sty=
le=3D"" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">operator</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify"><<(</span><span style=3D"" class=3D"styled-=
by-prettify"><br class=3D""> std</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">::</span><span style=3D"" class=3D"style=
d-by-prettify">basic_ostream</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify"><</span><span style=3D"color: #606;" class=3D"styled-b=
y-prettify">CharT</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #606;" class=3D"styled-by-prettify">Traits</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">>&</span><span style=
=3D"" class=3D"styled-by-prettify"> os</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">,</span><span style=3D"" class=3D"styled-by-pre=
ttify"><br class=3D""> bit b<br class=3D""></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"" cla=
ss=3D"styled-by-prettify"> <br class=3D""></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">{</span><span style=3D"" class=3D"styled-by=
-prettify"><br class=3D""> std</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">::</span><span style=3D"" class=3D"styled-=
by-prettify">bitset</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify"><</span><span style=3D"color: #066;" class=3D"styled-by-prettif=
y">1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">></=
span><span style=3D"" class=3D"styled-by-prettify"> bs</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">static_cast</span><span style=3D"color: =
#080;" class=3D"styled-by-prettify"><bool></span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">(</span><span style=3D"" class=3D"sty=
led-by-prettify">b</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">));</span><span style=3D"" class=3D"styled-by-prettify"><br class=
=3D""> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">return</span><span style=3D"" class=3D"styled-by-prettify"> os </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<</sp=
an><span style=3D"" class=3D"styled-by-prettify"> bs</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"" class=3D=
"styled-by-prettify"><br class=3D""></span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">}</span><span style=3D"" class=3D"styled-by-prett=
ify"><br class=3D""><br class=3D""></span><span style=3D"color: #800;" clas=
s=3D"styled-by-prettify">// Input</span><span style=3D"" class=3D"styled-by=
-prettify"><br class=3D""></span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">template</span><span style=3D"" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><=
span style=3D"" class=3D"styled-by-prettify"> </span><span style=3D"color: =
#606;" class=3D"styled-by-prettify">CharT</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">,</span><span style=3D"" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>class</span><span style=3D"" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #606;" class=3D"styled-by-prettify">Traits</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">></span><span style=3D"" =
class=3D"styled-by-prettify"><br class=3D"">std</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">::</span><span style=3D"" class=3D"sty=
led-by-prettify">basic_istream</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify"><</span><span style=3D"color: #606;" class=3D"styled=
-by-prettify">CharT</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">,</span><span style=3D"" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">Traits</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">>&</span><span sty=
le=3D"" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">operator</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">>>(</span><span style=3D"" class=3D"styled-=
by-prettify"><br class=3D""> std</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">::</span><span style=3D"" class=3D"style=
d-by-prettify">basic_istream</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify"><</span><span style=3D"color: #606;" class=3D"styled-b=
y-prettify">CharT</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #606;" class=3D"styled-by-prettify">Traits</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">>&</span><span style=
=3D"" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">is</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"" class=3D"styled-by-prettify"><br=
class=3D""> bit</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">&</span><span style=3D"" class=3D"styled-by-prettify=
"> b<br class=3D""></span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">)</span><span style=3D"" class=3D"styled-by-prettify"> <br class=
=3D""></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</s=
pan><span style=3D"" class=3D"styled-by-prettify"><br class=3D""> &nb=
sp; std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::<=
/span><span style=3D"" class=3D"styled-by-prettify">bitset</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"c=
olor: #066;" class=3D"styled-by-prettify">1</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">></span><span style=3D"" class=3D"style=
d-by-prettify"> bs</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span><span style=3D"" class=3D"styled-by-prettify"><br class=3D"=
"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">is</span><span style=3D"" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">>></span><span st=
yle=3D"" class=3D"styled-by-prettify"> bs</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">;</span><span style=3D"" class=3D"styled-by-=
prettify"><br class=3D""> b</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">.</span><span style=3D"" class=3D"styled-by-p=
rettify">assign</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"" class=3D"styled-by-prettify">bs</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"c=
olor: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">]);</span><span style=3D"" class=3D"styled=
-by-prettify"><br class=3D""> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">return</span><span style=3D"" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">is</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
;</span><span style=3D"" class=3D"styled-by-prettify"><br class=3D""></span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span st=
yle=3D"" class=3D"styled-by-prettify"><br class=3D""><br class=3D""></span>=
<span style=3D"color: #800;" class=3D"styled-by-prettify">// Main function<=
/span><span style=3D"" class=3D"styled-by-prettify"><br class=3D""></span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span st=
yle=3D"" class=3D"styled-by-prettify"> main</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">int</span><span style=3D"" class=3D"styled-by-prett=
ify"> argc</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
,</span><span style=3D"" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">char</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">*</span><span style=3D"" class=3D"=
styled-by-prettify"> argv</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">[])</span><span style=3D"" class=3D"styled-by-prettify"><br =
class=3D""></span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>{</span><span style=3D"" class=3D"styled-by-prettify"><br class=3D""> =
; bit b0</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">fals=
e</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span>=
<span style=3D"" class=3D"styled-by-prettify"><br class=3D""> =
bit b1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">true</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span styl=
e=3D"" class=3D"styled-by-prettify"><br class=3D""> std</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span st=
yle=3D"" class=3D"styled-by-prettify">stringstream stream</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"" cla=
ss=3D"styled-by-prettify"><br class=3D""> std</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"" c=
lass=3D"styled-by-prettify">cout</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><<</span><span style=3D"" class=3D"styled-by-=
prettify">b0</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
"><<</span><span style=3D"" class=3D"styled-by-prettify">b1</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify"><<</span><span=
style=3D"" class=3D"styled-by-prettify">std</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">::</span><span style=3D"" class=3D"styled=
-by-prettify">endl</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span><span style=3D"" class=3D"styled-by-prettify"><br class=3D"=
"> stream</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify"><<</span><span style=3D"color: #080;" class=3D"styled-by-=
prettify">" "</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify"><<</span><span style=3D"" class=3D"styled-by-prettify=
">b0</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><&l=
t;</span><span style=3D"" class=3D"styled-by-prettify">b1</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"" cla=
ss=3D"styled-by-prettify"><br class=3D""> stream</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">>></span><span sty=
le=3D"" class=3D"styled-by-prettify">b1</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">>></span><span style=3D"" class=3D"style=
d-by-prettify">b0</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">;</span><span style=3D"" class=3D"styled-by-prettify"><br class=3D""=
> std</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">::</span><span style=3D"" class=3D"styled-by-prettify">cout</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify"><<</span><sp=
an style=3D"" class=3D"styled-by-prettify">b0</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify"><<</span><span style=3D"" class=3D=
"styled-by-prettify">b1</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify"><<</span><span style=3D"" class=3D"styled-by-prettify">s=
td</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span=
><span style=3D"" class=3D"styled-by-prettify">endl</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"" class=3D"=
styled-by-prettify"><br class=3D""> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">return</span><span style=3D"" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"" class=3D"styled-by-prettify"><br class=3D"">=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><s=
pan style=3D"" class=3D"styled-by-prettify"><br class=3D""></span><br class=
=3D""><code class=3D"prettyprint"><span style=3D"color: #800;" class=3D"sty=
led-by-prettify">// =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D //</span><span style=3D"" class=3D"styled-by-prettify"><=
/span></code><br class=3D""></div></code></div>The bit class is just a simp=
lified version of the classes introduced in P0237R3 to illustrate my proble=
m. My question is the following: how should the output <span style=3D"font-=
family: courier new,monospace;" class=3D"">operator<<</span> and the =
input <span style=3D"font-family: courier new,monospace;" class=3D"">operat=
or>></span> be formally specified for bits and what a conforming impl=
ementation should look like? In the feedback I received, using numeric face=
t was suggested, but as it's not at all my area of expertise (I basically n=
ever used facets), I am asking for help (should a numeric facet specializat=
ion/overload be created to deal with bits, or should I use the existing one=
s, I don't even know). Could people with experience with input/output and f=
acets clarify what the wording should look like and what the implementation=
should be like?<br class=3D""><br class=3D"">Thank you very much,<br class=
=3D"">Vincent Reverdy<br class=3D""></div><div class=3D""><br class=3D"webk=
it-block-placeholder"></div>
-- <br class=3D"">
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br class=3D"">
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" class=3D"">=
std-proposals+unsubscribe@isocpp.org</a>.<br class=3D"">
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" class=3D"">std-proposals@isocpp.org</a>.<br class=3D"">
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/ffa1a664-51ae-4cd3-8058-d184b85743f0%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" class=3D"">https:/=
/groups.google.com/a/isocpp.org/d/msgid/std-proposals/ffa1a664-51ae-4cd3-80=
58-d184b85743f0%40isocpp.org</a>.<br class=3D"">
</div></blockquote></div><br class=3D""></div></div></div></body></html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/173650C3-00A6-4B4A-A6A8-A572CF0CC1C1%=
40gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/173650C3-00A6-4B4A-A6A8-A572CF0CC1C1%=
40gmail.com</a>.<br />
--Apple-Mail=_1FEC679C-C86F-4BFE-8703-89ED66CB255B--
.
Author: Vincent Reverdy <vince.rev@gmail.com>
Date: Mon, 21 Nov 2016 08:45:43 -0800 (PST)
Raw View
------=_Part_7907_636567068.1479746743455
Content-Type: multipart/alternative;
boundary="----=_Part_7908_313052632.1479746743455"
------=_Part_7908_313052632.1479746743455
Content-Type: text/plain; charset=UTF-8
Thanks David!
I just looked at the stdlibc++ implementation of std::bitset
<https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/std/bitset>
..
Does anyone know what are those:
// In operator>>
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 303. Bitset input operator underspecified
// In operator<<
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 396. what are characters zero and one.
?
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/9b9ce54f-1250-4567-a985-74a65659dc65%40isocpp.org.
------=_Part_7908_313052632.1479746743455
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Thanks David!<br><br>I just looked at the stdlibc++ implem=
entation of <a href=3D"https://github.com/gcc-mirror/gcc/blob/master/libstd=
c%2B%2B-v3/include/std/bitset">std::bitset</a>.<br><br>Does anyone know wha=
t are those:<br><span style=3D"font-family: courier new,monospace;">// In o=
perator>><br></span><table class=3D"highlight tab-size js-file-line-c=
ontainer" data-tab-size=3D"8"><tbody><tr><td id=3D"LC1471" class=3D"blob-co=
de blob-code-inner js-file-line"> <span style=3D"font-family: courier =
new,monospace;"><span class=3D"pl-c">// _GLIBCXX_RESOLVE_LIB_DEFECTS</span>=
</span></td>
</tr>
<tr>
</tr></tbody></table><span style=3D"font-family: courier new,monosp=
ace;"> <span class=3D"pl-c">// 303. Bitset input operator underspecifi=
ed<br>// In operator<<<br></span></span><table class=3D"highlight tab=
-size js-file-line-container" data-tab-size=3D"8"><tbody><tr><td id=3D"LC15=
35" class=3D"blob-code blob-code-inner js-file-line"> <span style=3D"f=
ont-family: courier new,monospace;"><span class=3D"pl-c">// _GLIBCXX_RESOLV=
E_LIB_DEFECTS</span></span></td>
</tr>
<tr>
</tr></tbody></table><span style=3D"font-family: courier new,monosp=
ace;"> </span><span class=3D"pl-c"><span style=3D"font-family: courier=
new,monospace;">// 396. what are characters zero and one.</span><br>?<br><=
/span></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/9b9ce54f-1250-4567-a985-74a65659dc65%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/9b9ce54f-1250-4567-a985-74a65659dc65=
%40isocpp.org</a>.<br />
------=_Part_7908_313052632.1479746743455--
------=_Part_7907_636567068.1479746743455--
.
Author: Jens Maurer <Jens.Maurer@gmx.net>
Date: Mon, 21 Nov 2016 18:30:55 +0100
Raw View
On 2016-11-21 17:45, Vincent Reverdy wrote:
> Thanks David!
>
> I just looked at the stdlibc++ implementation of std::bitset
> <https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/std/bitset>.
>
> Does anyone know what are those:
> // In operator>>
> // _GLIBCXX_RESOLVE_LIB_DEFECTS
>
> // 303. Bitset input operator underspecified
> // In operator<<
> // _GLIBCXX_RESOLVE_LIB_DEFECTS
>
> // 396. what are characters zero and one.
> ?
These are library issues.
http://wg21.link/lwg303
http://wg21.link/lwg396
Jens
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/16b51a61-2dfc-4407-a9bc-497b4ba1e062%40gmx.net.
.