Topic: Proposal: Strongly Typed Bitset
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Tue, 30 Sep 2014 16:58:01 -0700 (PDT)
Raw View
------=_Part_2052_1451320517.1412121481746
Content-Type: text/plain; charset=UTF-8
Continued from this thread:
https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/UjNcLLrGwv8
Here is the first draft of the proposal:
https://github.com/fmatthew5876/stdcxx-bitset
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_2052_1451320517.1412121481746
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Continued from this thread:<div>https://groups.google.com/=
a/isocpp.org/forum/#!topic/std-proposals/UjNcLLrGwv8<br></div><div><br></di=
v><div>Here is the first draft of the proposal:</div><div>https://github.co=
m/fmatthew5876/stdcxx-bitset<br></div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_2052_1451320517.1412121481746--
.
Author: ricky.65@hotmail.com
Date: Wed, 1 Oct 2014 06:17:36 -0700 (PDT)
Raw View
------=_Part_433_1632799244.1412169456650
Content-Type: text/plain; charset=UTF-8
I welcome this proposal as I feel that it is useful to be able to specify
the underlying integral type used for std::bitset.
However, I am dubious about the implementator guide of optimizing for speed
over size. In contrast, some may prefer to optimize for size over speed.
Incidentally, this proposal would make std::bitset consistent with
boost::dynamic_bitset which has an analogous template parameter to specify
the unsigned integer type in which the bits are stored. It uses "unsigned
long" as a default.
- Riccardo
On Wednesday, October 1, 2014 12:58:01 AM UTC+1, Matthew Fioravante wrote:
>
> Continued from this thread:
>
> https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/UjNcLLrGwv8
>
> Here is the first draft of the proposal:
> https://github.com/fmatthew5876/stdcxx-bitset
>
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_433_1632799244.1412169456650
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>I welcome this proposal as I feel that it is useful t=
o be able to specify the underlying integral type used for std::bitset.</di=
v><div><br></div><div>However, I am dubious about the implementator guide o=
f optimizing for speed over size. <span style=3D"font-size:11.0pt;line=
-height:115%;
font-family:"Calibri","sans-serif";mso-ascii-theme-font=
:minor-latin;mso-fareast-font-family:
Calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin=
;
mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-=
bidi;
mso-ansi-language:EN-GB;mso-fareast-language:EN-US;mso-bidi-language:AR-SA"=
>In contrast</span>, some may prefer to optimize for size over speed.</div>=
<div><br></div><div>Incidentally, this proposal would make std::bitset cons=
istent with boost::dynamic_bitset which has an analogous template parameter=
to specify the unsigned integer type in which the bits are stored. It uses=
"unsigned long" as a default.</div><div><br></div><div>- Riccardo </d=
iv><br>On Wednesday, October 1, 2014 12:58:01 AM UTC+1, Matthew Fioravante =
wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8=
ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Continu=
ed from this thread:<div><a href=3D"https://groups.google.com/a/isocpp.org/=
forum/#!topic/std-proposals/UjNcLLrGwv8" target=3D"_blank" onmousedown=3D"t=
his.href=3D'https://groups.google.com/a/isocpp.org/forum/#!topic/std-propos=
als/UjNcLLrGwv8';return true;" onclick=3D"this.href=3D'https://groups.googl=
e.com/a/isocpp.org/forum/#!topic/std-proposals/UjNcLLrGwv8';return true;">h=
ttps://groups.google.com/a/<wbr>isocpp.org/forum/#!topic/std-<wbr>proposals=
/UjNcLLrGwv8</a><br></div><div><br></div><div>Here is the first draft of th=
e proposal:</div><div><a href=3D"https://github.com/fmatthew5876/stdcxx-bit=
set" target=3D"_blank" onmousedown=3D"this.href=3D'https://www.google.com/u=
rl?q\75https%3A%2F%2Fgithub.com%2Ffmatthew5876%2Fstdcxx-bitset\46sa\75D\46s=
ntz\0751\46usg\75AFQjCNHe7yx1OgkRdixUpV-jYB3xrRtOkQ';return true;" onclick=
=3D"this.href=3D'https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2F=
fmatthew5876%2Fstdcxx-bitset\46sa\75D\46sntz\0751\46usg\75AFQjCNHe7yx1OgkRd=
ixUpV-jYB3xrRtOkQ';return true;">https://github.com/<wbr>fmatthew5876/stdcx=
x-bitset</a><br></div></div></blockquote></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_433_1632799244.1412169456650--
.
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Wed, 1 Oct 2014 06:42:18 -0700 (PDT)
Raw View
------=_Part_5618_1454122010.1412170938686
Content-Type: text/plain; charset=UTF-8
On Wednesday, October 1, 2014 9:17:36 AM UTC-4, rick...@hotmail.com wrote:
>
>
> However, I am dubious about the implementator guide of optimizing for
> speed over size. In contrast, some may prefer to optimize for size over
> speed.
>
It's a suggestion, not a mandate. On embedded or other special platforms,
size may indeed rule. On most general systems such as x86_64 linux, speed
should be the default.
Speed is very hard for the user to optimize for because they need platform
specific knowledge. Size is easier because you can just choose the integer
type which fits your requirements.
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_5618_1454122010.1412170938686
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Wednesday, October 1, 2014 9:17:36 AM UTC-4, ri=
ck...@hotmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: =
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div d=
ir=3D"ltr"><div><br></div><div>However, I am dubious about the implementato=
r guide of optimizing for speed over size. <span style=3D"font-size:11=
..0pt;line-height:115%;font-family:"Calibri","sans-serif"=
;">In contrast</span>, some may prefer to optimize for size over speed.</di=
v></div></blockquote><div><br></div><div>It's a suggestion, not a mandate. =
On embedded or other special platforms, size may indeed rule. On most gener=
al systems such as x86_64 linux, speed should be the default. </div><d=
iv><br></div><div>Speed is very hard for the user to optimize for because t=
hey need platform specific knowledge. Size is easier because you can just c=
hoose the integer type which fits your requirements.</div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_5618_1454122010.1412170938686--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Wed, 1 Oct 2014 09:27:15 -0500
Raw View
--001a11c1b65a51244c05045d4e6c
Content-Type: text/plain; charset=UTF-8
On 1 October 2014 08:17, <ricky.65@hotmail.com> wrote:
> However, I am dubious about the implementator guide of optimizing for
> speed over size. In contrast, some may prefer to optimize for size over
> speed.
>
We really should have *two* different types (or possibly yet another
template parameter) to address this...
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--001a11c1b65a51244c05045d4e6c
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra">On 1 October 2014 08:17, <span=
dir=3D"ltr"><<a href=3D"mailto:ricky.65@hotmail.com" target=3D"_blank">=
ricky.65@hotmail.com</a>></span> wrote:<br><div class=3D"gmail_quote"><b=
lockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px =
#ccc solid;padding-left:1ex"><div>However, I am dubious about the implement=
ator guide of optimizing for speed over size.=C2=A0<span style=3D"font-size=
:11.0pt;line-height:115%;font-family:"Calibri","sans-serif&q=
uot;">In contrast</span>, some may prefer to optimize for size over speed.<=
/div><div></div></blockquote></div><br>We really should have *two* differen=
t types (or possibly yet another template parameter) to address this...<br>=
-- <br>=C2=A0Nevin ":-)" Liber=C2=A0 <mailto:<a href=3D"mailto=
:nevin@eviloverlord.com" target=3D"_blank">nevin@eviloverlord.com</a>>=
=C2=A0 (847) 691-1404
</div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--001a11c1b65a51244c05045d4e6c--
.
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Wed, 1 Oct 2014 08:03:14 -0700 (PDT)
Raw View
------=_Part_20_1582199149.1412175794805
Content-Type: text/plain; charset=UTF-8
On Wednesday, October 1, 2014 10:27:58 AM UTC-4, Nevin ":-)" Liber wrote:
>
> On 1 October 2014 08:17, <rick...@hotmail.com <javascript:>> wrote:
>
>> However, I am dubious about the implementator guide of optimizing for
>> speed over size. In contrast, some may prefer to optimize for size over
>> speed.
>>
>
> We really should have *two* different types (or possibly yet another
> template parameter) to address this...
>
A separate type would be better:
template <typename N> using fast_bitset = bitset<N, /* Implementation
defined */>
template <typename N> using small_bitset = bitset<N, /* Implementation
defined */>
The small variant is somewhat ambiguous. Does it only optimize for size or
also alignment? If it's the second one, then we probably end up with
bitset<N,uint8_t> which likely performs the worst. Maybe we only need a
fast_bitset and let the users optimize for size themselves.
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_20_1582199149.1412175794805
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Wednesday, October 1, 2014 10:27:58 AM UTC-4, N=
evin ":-)" Liber wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div di=
r=3D"ltr"><div>On 1 October 2014 08:17, <span dir=3D"ltr"><<a href=3D"j=
avascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"ISatF23ywSkJ" onmous=
edown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'ja=
vascript:';return true;">rick...@hotmail.com</a>></span> wrote:<br><div =
class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0=
0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>However, I am dub=
ious about the implementator guide of optimizing for speed over size. =
<span style=3D"font-size:11.0pt;line-height:115%;font-family:"Calibri&=
quot;,"sans-serif"">In contrast</span>, some may prefer to optimi=
ze for size over speed.</div><div></div></blockquote></div><br>We really sh=
ould have *two* different types (or possibly yet another template parameter=
) to address this...<br></div></div></blockquote><div><br>A separate type w=
ould be better:<br><br><div class=3D"prettyprint" style=3D"background-color=
: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid=
; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><d=
iv class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by=
-prettify">template</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
<</span><span style=3D"color: #008;" class=3D"styled-by-prettify">typena=
me</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> N</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">using</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> fast_bitset </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> bitset</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">N</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/=
* Implementation defined */</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">template</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> N</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">using</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> small_bitset </span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> bitset</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">N</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/* Imp=
lementation defined */</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">></span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br></span></div></code></div><br>The small variant is somewhat ambig=
uous. Does it only optimize for size or also alignment? If it's the second =
one, then we probably end up with bitset<N,uint8_t> which likely perf=
orms the worst. Maybe we only need a fast_bitset and let the users optimize=
for size themselves.<br><br><br><br></div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_20_1582199149.1412175794805--
.
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Wed, 1 Oct 2014 08:03:58 -0700 (PDT)
Raw View
------=_Part_5611_1934838219.1412175838234
Content-Type: text/plain; charset=UTF-8
typo here:
>
> template <size_t N> using fast_bitset = bitset<N, /* Implementation
> defined */>
> template <size_t N> using small_bitset = bitset<N, /* Implementation
> defined */>
>
>
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_5611_1934838219.1412175838234
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">typo here:<br><blockquote class=3D"gmail_quote" style=3D"m=
argin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"=
><div dir=3D"ltr"><div><br><div style=3D"background-color:rgb(250,250,250);=
border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap=
:break-word"><code><div><span style=3D"color:#008">template</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#660"><size_t</span><span=
style=3D"color:#008"></span><span style=3D"color:#000"> N</span><span styl=
e=3D"color:#660">></span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">using</span><span style=3D"color:#000"> fast_bitset </span>=
<span style=3D"color:#660">=3D</span><span style=3D"color:#000"> bitset</sp=
an><span style=3D"color:#660"><</span><span style=3D"color:#000">N</span=
><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#800">/* Implementation defined */</span><span style=3D"co=
lor:#660">></span><span style=3D"color:#000"><br></span><span style=3D"c=
olor:#008">template</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660"><size_t </span><span style=3D"color:#000">N</span><span sty=
le=3D"color:#660">></span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">using</span><span style=3D"color:#000"> small_bitset </span=
><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> bitset</s=
pan><span style=3D"color:#660"><</span><span style=3D"color:#000">N</spa=
n><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#800">/* Implementation defined */</span><span style=3D"c=
olor:#660">></span><span style=3D"color:#000"><br></span></div></code></=
div><br></div></div></blockquote></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_5611_1934838219.1412175838234--
.
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Wed, 1 Oct 2014 18:26:11 -0700 (PDT)
Raw View
------=_Part_6190_1238732653.1412213171801
Content-Type: text/plain; charset=UTF-8
I've updated the draft with fast_bitset and small_bitset.
https://github.com/fmatthew5876/stdcxx-bitset
I had some ideas for additional directions to go into. I've not put these
in the paper.
Some new public members:
template <size_t N, typename T> class bitset {
public:
using underlying_type = T[N / (sizeof(T) * CHAR_BIT) + 1];
array<T,sizeof(underlying_type) / sizeof(T)> get_underlying() const;
void set_underlying(array<T,sizeof(underlying_type) / sizeof(T)> a);
get_underlying() would return an array of T whose bits are identical to the
bits stored in the bitset. All of the bits > N would be 0.
set_underlying(a) would set the internal bits to the values of the bits in
a. All of the bits > N are ignored.
Alternatively, instead of value semantics we could do reference semantics:
template <size_t N, typename T> class bitset {
public:
using underlying_type = T[N / (sizeof(T) * CHAR_BIT) + 1];
array<T,sizeof(underlying_type) / sizeof(T)>& rep();
const array<T,sizeof(underlying_type) / sizeof(T)>& rep() const;
This is more dangerous as bitset is a value type which can be freely
copied, but it might be more efficient for large bitsets.
With either of these options, we could deprecate bitset::to_ulong() and
bitset::to_ullong().
Finally, (this might be a separate proposal) bitset::to_string() is really
an inefficient design. It returns a std::string which will require a memory
allocation.
Instead of that, to_string() could return std::array<char,N+1>, which holds
a null terminated bitstring.
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_6190_1238732653.1412213171801
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I've updated the draft with fast_bitset and small_bitset.<=
div><br></div><div>https://github.com/fmatthew5876/stdcxx-bitset<br></div><=
div><br></div><div>I had some ideas for additional directions to go into. I=
've not put these in the paper.</div><div><br></div><div>Some new public me=
mbers:</div><div><br></div><div><div class=3D"prettyprint" style=3D"backgro=
und-color: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-w=
rap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"=
><span style=3D"color: #008;" class=3D"styled-by-prettify">template</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">size_t N</span><span style=3D"col=
or: #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">typename</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><font color=3D"#000088"><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">class</span></font><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> bitset </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">public</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> <br> </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">using</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> underlying_type </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">[</span><span style=3D"color: #000;" class=3D"styled-by-prettify">N <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">/</span><sp=
an 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=
: #008;" class=3D"styled-by-prettify">sizeof</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">T</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">*<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> CHAR_BIT</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><spa=
n 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"> </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-b=
y-prettify"><br><br> array</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">T</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">sizeof</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">underly=
ing_type</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">/</span><font color=
=3D"#000000"><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">sizeof</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">)</span></font><span style=3D"color=
: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> get_underlying</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: #660;" class=3D"style=
d-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br> </span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> set_underlying</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">array</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><font co=
lor=3D"#000000"><span style=3D"color: #008;" class=3D"styled-by-prettify">s=
izeof</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">underlying_typ=
e</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: #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">sizeof</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">)></span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</s=
pan></font><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&n=
bsp; </span></div></code></div><br>get_underlying() would return an array o=
f T whose bits are identical to the bits stored in the bitset. All of the b=
its > N would be 0.</div><div>set_underlying(a) would set the internal b=
its to the values of the bits in a. All of the bits > N are ignored.</di=
v><div><br></div><div>Alternatively, instead of value semantics we could do=
reference semantics:</div><div><div class=3D"prettyprint" style=3D"backgro=
und-color: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-w=
rap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"=
><span style=3D"color: #008;" class=3D"styled-by-prettify">template</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">size_t N</span><span style=3D"col=
or: #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">typename</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">></span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><font color=3D"#000088"><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">class</span></font><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> bitset </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">public</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> <br> </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">using</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> underlying_type </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">[</span><span style=3D"color: #000;" class=3D"styled-by-prettify">N <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">/</span><sp=
an 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=
: #008;" class=3D"styled-by-prettify">sizeof</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">T</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">*<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> CHAR_BIT</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><spa=
n 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"> </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-b=
y-prettify"><br><br> array</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">T</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">sizeof</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">underly=
ing_type</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">/</span><font color=
=3D"#000000"><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">sizeof</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">)</span></font><span style=3D"color=
: #660;" class=3D"styled-by-prettify">>&</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> rep</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">()</span><font color=3D"#000000"><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span></font><span style=3D"colo=
r: #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"> array</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">T</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">,</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">sizeof</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">und=
erlying_type</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: #660;" class=3D"styled-by-prettify">/</span><font co=
lor=3D"#000000"><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">sizeof</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">)</span></font><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">>&</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> rep</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">const</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br><br></span></div></code></div><div><br></div>This is more dangerous =
as bitset is a value type which can be freely copied, but it might be more =
efficient for large bitsets.</div><div><br></div><div>With either of these =
options, we could deprecate bitset::to_ulong() and bitset::to_ullong().</di=
v><div><br></div><div>Finally, (this might be a separate proposal) bitset::=
to_string() is really an inefficient design. It returns a std::string which=
will require a memory allocation.</div><div><br></div><div>Instead of that=
, to_string() could return std::array<char,N+1>, which holds a null t=
erminated bitstring.<br><br></div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_6190_1238732653.1412213171801--
.
Author: Nicola Gigante <nicola.gigante@gmail.com>
Date: Thu, 2 Oct 2014 09:51:34 +0200
Raw View
--Apple-Mail=_C9433F83-B7B1-4B1D-A75B-6FFA9FCEE77B
Content-Type: text/plain; charset=ISO-8859-1
Hi
Il giorno 02/ott/2014, alle ore 03:26, Matthew Fioravante <fmatthew5876@gmail.com> ha scritto:
> I've updated the draft with fast_bitset and small_bitset.
>
> https://github.com/fmatthew5876/stdcxx-bitset
>
> I had some ideas for additional directions to go into. I've not put these in the paper.
>
> Some new public members:
>
> template <size_t N, typename T> class bitset {
> public:
> using underlying_type = T[N / (sizeof(T) * CHAR_BIT) + 1];
>
> array<T,sizeof(underlying_type) / sizeof(T)> get_underlying() const;
> void set_underlying(array<T,sizeof(underlying_type) / sizeof(T)> a);
>
>
> get_underlying() would return an array of T whose bits are identical to the bits stored in the bitset. All of the bits > N would be 0.
> set_underlying(a) would set the internal bits to the values of the bits in a. All of the bits > N are ignored.
>
> Alternatively, instead of value semantics we could do reference semantics:
> template <size_t N, typename T> class bitset {
> public:
> using underlying_type = T[N / (sizeof(T) * CHAR_BIT) + 1];
>
> array<T,sizeof(underlying_type) / sizeof(T)>& rep();
> const array<T,sizeof(underlying_type) / sizeof(T)>& rep() const;
>
>
> This is more dangerous as bitset is a value type which can be freely copied, but it might be more efficient for large bitsets.
>
In my opinion this is a very useful feature! A lot of times I've wanted to use bitset but I couldn't because
I also needed to directly access the underlying data. I think this is a fundamental flaw in the current std::bitset
design. I'd farther suggest to make it simple to tie a bitset to an already existing buffer. Would it be difficult
to standardize a "bitset_view" class that just adapts an existing random access container and expose the
bit access capabilities of bitset? Then the old bitset could be implemented by wrapping this view over
a std::array, while wrapping over an array_view would make it possible to access already existing buffers.
Wrapping it over an std::vector, we'll have boost::dynamic_bitset for free.
In this way you could make the old bitset a simple typedef (given that the current proposal would
break the ABI anyway, why not?), but you could also leave bitset alone, not breaking the ABI in any way,
and let users that need more power to use bitset_view over whichever container they like.
What do you think about this idea?
Bye,
Nicola
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--Apple-Mail=_C9433F83-B7B1-4B1D-A75B-6FFA9FCEE77B
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><div><br></div><div>Hi=
</div><br><div><div>Il giorno 02/ott/2014, alle ore 03:26, Matthew Fioravan=
te <<a href=3D"mailto:fmatthew5876@gmail.com">fmatthew5876@gmail.com</a>=
> ha scritto:</div><br class=3D"Apple-interchange-newline"><blockquote t=
ype=3D"cite"><div dir=3D"ltr">I've updated the draft with fast_bitset and s=
mall_bitset.<div><br></div><div><a href=3D"https://github.com/fmatthew5876/=
stdcxx-bitset">https://github.com/fmatthew5876/stdcxx-bitset</a><br></div><=
div><br></div><div>I had some ideas for additional directions to go into. I=
've not put these in the paper.</div><div><br></div><div>Some new public me=
mbers:</div><div><br></div><div><div class=3D"prettyprint" style=3D"backgro=
und-color: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-w=
rap: break-word; position: static; z-index: auto;"><code class=3D"prettypri=
nt"><span style=3D"color: #008;" class=3D"styled-by-prettify">template</spa=
n> <span style=3D"color: #660;" class=3D"styled-by-prettify"><</span>siz=
e_t N<span style=3D"color: #660;" class=3D"styled-by-prettify">,</span> <sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">typename</span> T<sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">></span> <font co=
lor=3D"#000088">class</font> bitset <span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">{</span><br> <span style=3D"color: #008;" class=3D=
"styled-by-prettify">public</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">:</span> <br> <span style=3D"color: #00=
8;" class=3D"styled-by-prettify">using</span> underlying_type <span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span> T<span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">[</span>N <span style=3D"color: #=
660;" class=3D"styled-by-prettify">/</span> <span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">sizeof</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">(</span>T<span style=3D"color: #660;" class=3D"styled-by-pret=
tify">)</span> <span style=3D"color: #660;" class=3D"styled-by-prettify">*<=
/span> CHAR_BIT<span style=3D"color: #660;" class=3D"styled-by-prettify">)<=
/span> <span style=3D"color: #660;" class=3D"styled-by-prettify">+</span> <=
span style=3D"color: #066;" class=3D"styled-by-prettify">1</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">];</span><br><br> &nb=
sp; array<span style=3D"color: #660;" class=3D"styled-by-prettify"><</sp=
an>T<span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">sizeof</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(</span>underlying_type<sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">)</span> <span style=
=3D"color: #660;" class=3D"styled-by-prettify">/</span><font><span style=3D=
"" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">sizeof</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"" class=3D"styled-by-prettify">T=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span></=
font><span style=3D"color: #660;" class=3D"styled-by-prettify">></span> =
get_underlying<span style=3D"color: #660;" class=3D"styled-by-prettify">()<=
/span> <span style=3D"color: #008;" class=3D"styled-by-prettify">const</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><br>&nb=
sp; <span style=3D"color: #008;" class=3D"styled-by-prettify">void</=
span> set_underlying<span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span>array<span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;</span>T<span style=3D"color: #660;" class=3D"styled-by-prettify">,</spa=
n><font><span style=3D"color: #008;" class=3D"styled-by-prettify">sizeof</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span=
style=3D"" class=3D"styled-by-prettify">underlying_type</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">/</span><span style=3D"" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">sizeof</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"" class=3D"styled-by-prettify">T</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">)></span><span style=3D"" class=3D"styled-by=
-prettify"> a</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">);</span></font><br> </code></div><br>get_underlying() would retur=
n an array of T whose bits are identical to the bits stored in the bitset. =
All of the bits > N would be 0.</div><div>set_underlying(a) would set th=
e internal bits to the values of the bits in a. All of the bits > N are =
ignored.</div><div><br></div><div>Alternatively, instead of value semantics=
we could do reference semantics:</div><div><div class=3D"prettyprint" styl=
e=3D"background-color: rgb(250, 250, 250); border: 1px solid rgb(187, 187, =
187); word-wrap: break-word; position: static; z-index: auto;"><code class=
=3D"prettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">=
template</span> <span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;</span>size_t N<span style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</span> <span style=3D"color: #008;" class=3D"styled-by-prettify">typenam=
e</span> T<span style=3D"color: #660;" class=3D"styled-by-prettify">></s=
pan> <font color=3D"#000088">class</font> bitset <span style=3D"color: #660=
;" class=3D"styled-by-prettify">{</span><br> <span style=3D"color: #0=
08;" class=3D"styled-by-prettify">public</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">:</span> <br> <span style=
=3D"color: #008;" class=3D"styled-by-prettify">using</span> underlying_type=
<span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span> T<spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">[</span>N <span style=
=3D"color: #660;" class=3D"styled-by-prettify">/</span> <span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">sizeof</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">(</span>T<span style=3D"color: #660;" class=3D"st=
yled-by-prettify">)</span> <span style=3D"color: #660;" class=3D"styled-by-=
prettify">*</span> CHAR_BIT<span style=3D"color: #660;" class=3D"styled-by-=
prettify">)</span> <span style=3D"color: #660;" class=3D"styled-by-prettify=
">+</span> <span style=3D"color: #066;" class=3D"styled-by-prettify">1</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">];</span><br><b=
r> array<span style=3D"color: #660;" class=3D"styled-by-pretti=
fy"><</span>T<span style=3D"color: #660;" class=3D"styled-by-prettify">,=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">sizeof</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span>underl=
ying_type<span style=3D"color: #660;" class=3D"styled-by-prettify">)</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">/</span><font><s=
pan style=3D"" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">sizeof</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(</span><span style=3D"" class=3D"styled-by-=
prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>)</span></font><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;&</span> rep<span style=3D"color: #660;" class=3D"styled-by-prettify=
">()</span><font><span style=3D"color: #660;" class=3D"styled-by-prettify">=
;</span><span style=3D"" class=3D"styled-by-prettify"><br></span></font>&nb=
sp; <span style=3D"color: #008;" class=3D"styled-by-prettify">const<=
/span> array<span style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span>T<span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">sizeof</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">(</span>underlying_type=
<span style=3D"color: #660;" class=3D"styled-by-prettify">)</span> <span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">/</span><font><span style=
=3D"" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">sizeof</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"" class=3D"styled-by-prettif=
y">T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</spa=
n></font><span style=3D"color: #660;" class=3D"styled-by-prettify">>&=
;</span> rep<span style=3D"color: #660;" class=3D"styled-by-prettify">()</s=
pan> <span style=3D"color: #008;" class=3D"styled-by-prettify">const</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><br><br><=
/code></div><div><br></div>This is more dangerous as bitset is a value type=
which can be freely copied, but it might be more efficient for large bitse=
ts.</div><div><br></div></div></blockquote><div><br></div><div>In my opinio=
n this is a very useful feature! A lot of times I’ve wanted to use bi=
tset but I couldn’t because</div><div>I also needed to directly acces=
s the underlying data. I think this is a fundamental flaw in the current st=
d::bitset</div><div>design. I’d farther suggest to make it simple to =
tie a bitset to an already existing buffer. Would it be difficult</div><div=
>to standardize a “bitset_view” class that just adapts an exist=
ing random access container and expose the</div><div>bit access capabilitie=
s of bitset? Then the old bitset could be implemented by wrapping this view=
over</div><div>a std::array, while wrapping over an array_view would make =
it possible to access already existing buffers.</div><div>Wrapping it over =
an std::vector, we’ll have boost::dynamic_bitset for free.</div><div>=
In this way you could make the old bitset a simple typedef (given that the =
current proposal would</div><div>break the ABI anyway, why not?), but you c=
ould also leave bitset alone, not breaking the ABI in any way, </div><=
div>and let users that need more power to use bitset_view over whichever co=
ntainer they like.</div><div><br></div><div>What do you think about this id=
ea?</div></div><br><div>Bye,</div><div>Nicola</div></body></html>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_C9433F83-B7B1-4B1D-A75B-6FFA9FCEE77B--
.
Author: Farid Mehrabi <farid.mehrabi@gmail.com>
Date: Thu, 2 Oct 2014 14:52:59 +0330
Raw View
--bcaec53d5b1ff0562a05046ed74d
Content-Type: text/plain; charset=UTF-8
2014-10-02 11:21 GMT+03:30 Nicola Gigante <nicola.gigante@gmail.com>:
>
> Hi
>
> Il giorno 02/ott/2014, alle ore 03:26, Matthew Fioravante <
> fmatthew5876@gmail.com> ha scritto:
>
> I've updated the draft with fast_bitset and small_bitset.
>
> https://github.com/fmatthew5876/stdcxx-bitset
>
> I had some ideas for additional directions to go into. I've not put these
> in the paper.
>
> Some new public members:
>
> template <size_t N, typename T> class bitset {
> public:
> using underlying_type = T[N / (sizeof(T) * CHAR_BIT) + 1];
>
> array<T,sizeof(underlying_type) / sizeof(T)> get_underlying() const;
> void set_underlying(array<T,sizeof(underlying_type) / sizeof(T)> a);
>
>
> I would rather :
template <size_t N, typename T> class bitset {
public:
static constexpr size_t word_size = sizeof(T) * CHAR_BIT ;
using underlying_type = T[ (N + word_size - 1) / word_size ];
that is more efficient; when (N % word_size) == 0, this
approach will save us one unused extra word per instance.
regards,
FM
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--bcaec53d5b1ff0562a05046ed74d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"rtl"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te"><div dir=3D"ltr">2014-10-02 11:21 GMT+03:30 Nicola Gigante <span dir=3D=
"ltr"><<a href=3D"mailto:nicola.gigante@gmail.com" target=3D"_blank">nic=
ola.gigante@gmail.com</a>></span>:</div><blockquote class=3D"gmail_quote=
" style=3D"margin:0px 0.8ex;border-left-width:1px;border-left-color:rgb(204=
,204,204);border-left-style:solid;border-right-width:1px;border-right-color=
:rgb(204,204,204);border-right-style:solid;padding-left:1ex;padding-right:1=
ex"><div style=3D"word-wrap:break-word"><div><br></div><div>Hi</div><br><di=
v><div>Il giorno 02/ott/2014, alle ore 03:26, Matthew Fioravante <<a hre=
f=3D"mailto:fmatthew5876@gmail.com" target=3D"_blank">fmatthew5876@gmail.co=
m</a>> ha scritto:</div><span class=3D""><br><blockquote type=3D"cite"><=
div dir=3D"ltr">I've updated the draft with fast_bitset and small_bitse=
t.<div><br></div><div><a href=3D"https://github.com/fmatthew5876/stdcxx-bit=
set" target=3D"_blank">https://github.com/fmatthew5876/stdcxx-bitset</a><br=
></div><div><br></div><div>I had some ideas for additional directions to go=
into. I've not put these in the paper.</div><div><br></div><div>Some n=
ew public members:</div><div><br></div><div><div style=3D"border:1px solid =
rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><c=
ode><span style=3D"color:rgb(0,0,136)">template</span> <span style=3D"color=
:rgb(102,102,0)"><</span>size_t N<span style=3D"color:rgb(102,102,0)">,<=
/span> <span style=3D"color:rgb(0,0,136)">typename</span> T<span style=3D"c=
olor:rgb(102,102,0)">></span> <font color=3D"#000088">class</font> bitse=
t <span style=3D"color:rgb(102,102,0)">{</span><br>=C2=A0 <span style=3D"co=
lor:rgb(0,0,136)">public</span><span style=3D"color:rgb(102,102,0)">:</span=
> =C2=A0<br>=C2=A0 =C2=A0 <span style=3D"color:rgb(0,0,136)">using</span> u=
nderlying_type <span style=3D"color:rgb(102,102,0)">=3D</span> T<span style=
=3D"color:rgb(102,102,0)">[</span>N <span style=3D"color:rgb(102,102,0)">/<=
/span> <span style=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rg=
b(0,0,136)">sizeof</span><span style=3D"color:rgb(102,102,0)">(</span>T<spa=
n style=3D"color:rgb(102,102,0)">)</span> <span style=3D"color:rgb(102,102,=
0)">*</span> CHAR_BIT<span style=3D"color:rgb(102,102,0)">)</span> <span st=
yle=3D"color:rgb(102,102,0)">+</span> <span style=3D"color:rgb(0,102,102)">=
1</span><span style=3D"color:rgb(102,102,0)">];</span><br><br>=C2=A0 =C2=A0=
array<span style=3D"color:rgb(102,102,0)"><</span>T<span style=3D"color=
:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,136)">sizeof</span><s=
pan style=3D"color:rgb(102,102,0)">(</span>underlying_type<span style=3D"co=
lor:rgb(102,102,0)">)</span> <span style=3D"color:rgb(102,102,0)">/</span><=
font><span> </span><span style=3D"color:rgb(0,0,136)">sizeof</span><span st=
yle=3D"color:rgb(102,102,0)">(</span><span>T</span><span style=3D"color:rgb=
(102,102,0)">)</span></font><span style=3D"color:rgb(102,102,0)">></span=
> get_underlying<span style=3D"color:rgb(102,102,0)">()</span> <span style=
=3D"color:rgb(0,0,136)">const</span><span style=3D"color:rgb(102,102,0)">;<=
/span><br>=C2=A0 =C2=A0 <span style=3D"color:rgb(0,0,136)">void</span> set_=
underlying<span style=3D"color:rgb(102,102,0)">(</span>array<span style=3D"=
color:rgb(102,102,0)"><</span>T<span style=3D"color:rgb(102,102,0)">,</s=
pan><font><span style=3D"color:rgb(0,0,136)">sizeof</span><span style=3D"co=
lor:rgb(102,102,0)">(</span><span>underlying_type</span><span style=3D"colo=
r:rgb(102,102,0)">)</span><span> </span><span style=3D"color:rgb(102,102,0)=
">/</span><span> </span><span style=3D"color:rgb(0,0,136)">sizeof</span><sp=
an style=3D"color:rgb(102,102,0)">(</span><span>T</span><span style=3D"colo=
r:rgb(102,102,0)">)></span><span> a</span><span style=3D"color:rgb(102,1=
02,0)">);</span></font><br>=C2=A0 </code></div></div></div></blockquote></s=
pan></div></div></blockquote><div style=3D"direction:ltr">=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 I would rather :</div><div style=3D"direction:ltr"=
><blockquote type=3D"cite"><div dir=3D"ltr"><div style=3D"border:1px solid =
rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><c=
ode><span style=3D"color:rgb(0,0,136)">template</span>=C2=A0<span style=3D"=
color:rgb(102,102,0)"><</span>size_t N<span style=3D"color:rgb(102,102,0=
)">,</span>=C2=A0<span style=3D"color:rgb(0,0,136)">typename</span>=C2=A0T<=
span style=3D"color:rgb(102,102,0)">></span>=C2=A0<font color=3D"#000088=
">class</font>=C2=A0bitset=C2=A0<span style=3D"color:rgb(102,102,0)">{</spa=
n><br>=C2=A0=C2=A0<span style=3D"color:rgb(0,0,136)">public</span><span sty=
le=3D"color:rgb(102,102,0)">:</span>=C2=A0=C2=A0<br>=C2=A0 =C2=A0 static co=
nstexpr size_t word_size =3D<font color=3D"#666600">=C2=A0</font></code><sp=
an style=3D"color:rgb(0,0,136)">sizeof</span><span style=3D"color:rgb(102,1=
02,0)">(</span>T<span style=3D"color:rgb(102,102,0)">)</span>=C2=A0=C2=A0<s=
pan style=3D"color:rgb(102,102,0)">*=C2=A0</span>=C2=A0CHAR_BIT=C2=A0<span =
style=3D"color:rgb(102,102,0)">;</span></div><div style=3D"border:1px solid=
rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><=
code>=C2=A0 =C2=A0=C2=A0</code>=C2=A0<span style=3D"color:rgb(0,0,136)">usi=
ng</span>=C2=A0underlying_type=C2=A0<span style=3D"color:rgb(102,102,0)">=
=3D T[ (N +=C2=A0</span>word_size=C2=A0- 1) / word_size ];</div><div style=
=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;background-color=
:rgb(250,250,250)"><br></div></div></blockquote></div><div style=3D"directi=
on:ltr">=C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0that is more efficie=
nt; when (N %=C2=A0<span style=3D"background-color:rgb(250,250,250)">word_s=
ize)</span><span style=3D"background-color:rgb(250,250,250)">=C2=A0=3D=3D 0=
, this approach will save us one unused extra word per instance.</span></di=
v><div dir=3D"ltr" style=3D"direction:rtl"><span style=3D"background-color:=
rgb(250,250,250)">regards,</span></div><div dir=3D"ltr" style=3D"direction:=
rtl"><span style=3D"background-color:rgb(250,250,250)">FM</span></div></div=
>
</div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--bcaec53d5b1ff0562a05046ed74d--
.
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Thu, 2 Oct 2014 06:38:32 -0700 (PDT)
Raw View
------=_Part_4084_1718364635.1412257112826
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Thursday, October 2, 2014 3:51:38 AM UTC-4, Nicola Gigante wrote:
>
>
> In my opinion this is a very useful feature! A lot of times I=E2=80=99ve =
wanted to=20
> use bitset but I couldn=E2=80=99t because
> I also needed to directly access the underlying data. I think this is a=
=20
> fundamental flaw in the current std::bitset
> design. I=E2=80=99d farther suggest to make it simple to tie a bitset to =
an=20
> already existing buffer. Would it be difficult
> to standardize a =E2=80=9Cbitset_view=E2=80=9D class that just adapts an =
existing random=20
> access container and expose the
> bit access capabilities of bitset?=20
>
Its possible. As you pointed out bitset_view would need to be a separate=20
class.
=20
> Then the old bitset could be implemented by wrapping this view over
> a std::array, while wrapping over an array_view would make it possible to=
=20
> access already existing buffers.
>
It depends on how bitset_view is implemented. If its implemented on top of=
=20
array_view (which I would recommend), this is a non-starter because the=20
object would contain 2 extra pointers. Defeating the entire purpose of my=
=20
current proposal.
=20
> Wrapping it over an std::vector, we=E2=80=99ll have boost::dynamic_bitset=
for free.
>
Well not quite, a hypothetical bitset_view I imagine would work like=20
array_view in that it just wraps over a pair or pointers and gives you a=20
bit access API over the buffer. In fact I'd probably define such a=20
bitset_view to just accept an array_view in its constructor so that it can=
=20
generically wrap any kind of buffer by piggybacking off of array_view's=20
capabilities. Such is the power and magnificence of array_view!=20
Supporting a dynamic bitset would require some additional logic to handle=
=20
growing via push_back(). It probably needs to be its own class. Also I'm=20
not sure I see a value having a dynamic_bitset_view over a std::vector? Do=
=20
you have a use case for that?
=20
> In this way you could make the old bitset a simple typedef (given that th=
e=20
> current proposal would
> break the ABI anyway, why not?), but you could also leave bitset alone,=
=20
> not breaking the ABI in any way,=20
> and let users that need more power to use bitset_view over whichever=20
> container they like.
>
> What do you think about this idea?
>
> Bye,
> Nicola
>
Probably we want separate bitset (std::array), dynamic_bitset=20
(std::vector), and bitset_view (std::array_view).
On Thursday, October 2, 2014 7:23:21 AM UTC-4, Farid Mehrabi wrote:
>
>
>
> that is more efficient; when (N % word_size) =3D=3D 0, this=
=20
> approach will save us one unused extra word per instance.
>
That's a bug in my paper. Thanks for catching, I'll fix it in the next=20
revision.=20
--=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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_4084_1718364635.1412257112826
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Thursday, October 2, 2014 3:51:38 AM UTC-4, Nic=
ola Gigante wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div style=
=3D"word-wrap:break-word"><br><div><div>In my opinion this is a very useful=
feature! A lot of times I=E2=80=99ve wanted to use bitset but I couldn=E2=
=80=99t because</div><div>I also needed to directly access the underlying d=
ata. I think this is a fundamental flaw in the current std::bitset</div><di=
v>design. I=E2=80=99d farther suggest to make it simple to tie a bitset to =
an already existing buffer. Would it be difficult</div><div>to standardize =
a =E2=80=9Cbitset_view=E2=80=9D class that just adapts an existing random a=
ccess container and expose the</div><div>bit access capabilities of bitset?=
</div></div></div></blockquote><div><br>Its possible. As you pointed out b=
itset_view would need to be a separate class.<br> </div><blockquote cl=
ass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px =
#ccc solid;padding-left: 1ex;"><div style=3D"word-wrap:break-word"><div><di=
v>Then the old bitset could be implemented by wrapping this view over</div>=
<div>a std::array, while wrapping over an array_view would make it possible=
to access already existing buffers.</div></div></div></blockquote><div><br=
>It depends on how bitset_view is implemented. If its implemented on top of=
array_view (which I would recommend), this is a non-starter because the ob=
ject would contain 2 extra pointers. Defeating the entire purpose of my cur=
rent proposal.<br> </div><blockquote class=3D"gmail_quote" style=3D"ma=
rgin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">=
<div style=3D"word-wrap:break-word"><div><div>Wrapping it over an std::vect=
or, we=E2=80=99ll have boost::dynamic_bitset for free.</div></div></div></b=
lockquote><div><br>Well not quite, a hypothetical bitset_view I imagine wou=
ld work like array_view in that it just wraps over a pair or pointers and g=
ives you a bit access API over the buffer. In fact I'd probably define such=
a bitset_view to just accept an array_view in its constructor so that it c=
an generically wrap any kind of buffer by piggybacking off of array_view's =
capabilities. Such is the power and magnificence of array_view! <br><br>Sup=
porting a dynamic bitset would require some additional logic to handle grow=
ing via push_back(). It probably needs to be its own class. Also I'm not su=
re I see a value having a dynamic_bitset_view over a std::vector? Do you ha=
ve a use case for that?<br> <br></div><blockquote class=3D"gmail_quote=
" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding=
-left: 1ex;"><div style=3D"word-wrap:break-word"><div><div>In this way you =
could make the old bitset a simple typedef (given that the current proposal=
would</div><div>break the ABI anyway, why not?), but you could also leave =
bitset alone, not breaking the ABI in any way, </div><div>and let user=
s that need more power to use bitset_view over whichever container they lik=
e.</div><div><br></div><div>What do you think about this idea?</div></div><=
br><div>Bye,</div><div>Nicola</div></div></blockquote><br>Probably we want =
separate bitset (std::array), dynamic_bitset (std::vector), and bitset_view=
(std::array_view).<br><br><br>On Thursday, October 2, 2014 7:23:21 AM UTC-=
4, Farid Mehrabi wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div di=
r=3D"rtl"><br><div><br><div class=3D"gmail_quote"><div style=3D"direction:l=
tr"> that is more efficient; =
when (N % <span style=3D"background-color:rgb(250,250,250)">word_size)=
</span><span style=3D"background-color:rgb(250,250,250)"> =3D=3D 0, th=
is approach will save us one unused extra word per instance.</span></div></=
div></div></div></blockquote><div><br>That's a bug in my paper. Thanks for =
catching, I'll fix it in the next revision. <br></div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_4084_1718364635.1412257112826--
.
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Thu, 2 Oct 2014 06:50:11 -0700 (PDT)
Raw View
------=_Part_2411_1727637266.1412257811499
Content-Type: text/plain; charset=UTF-8
I think your bitset_view idea has also answered my question. I will use
reference semantics to access the underlying buffer of bitset. With that,
one could create a bitset_view overtop of it and access the bits in the
original bitset.
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_2411_1727637266.1412257811499
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I think your bitset_view idea has also answered my questio=
n. I will use reference semantics to access the underlying buffer of bitset=
.. With that, one could create a bitset_view overtop of it and access the bi=
ts in the original bitset.<br></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_2411_1727637266.1412257811499--
.
Author: Nicola Gigante <nicola.gigante@gmail.com>
Date: Thu, 2 Oct 2014 15:59:27 +0200
Raw View
--Apple-Mail=_74B98940-B87B-46F9-995C-4AC4AD695728
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1
Il giorno 02/ott/2014, alle ore 15:38, Matthew Fioravante <fmatthew5876@gma=
il.com> ha scritto:
>=20
>=20
> On Thursday, October 2, 2014 3:51:38 AM UTC-4, Nicola Gigante wrote:
>=20
> It depends on how bitset_view is implemented. If its implemented on top o=
f array_view (which I would recommend), this is a non-starter because the o=
bject would contain 2 extra pointers. Defeating the entire purpose of my cu=
rrent proposal.
My idea would be not to base the class on something specific (array_view or=
something else), but to have the class to be wrapped
as a template parameter and include an object of such a class inside it.
I've implemented once something related for a data structure we're developi=
ng at my university:
https://github.com/nicola-gigante/bitvector/blob/master/include/bitview.h
The interface is tailored to our application and not at all similar to bits=
et but the aim
is the same: to access the individual bits of a piece of data.
If you instantiate bitview<array_view> you get a non-owning view that, supe=
rimposed on
array_view, wraps any container you like. If you instantiate bitview<std::a=
rray> (the arity of the template
is not the same, you need a typedef, but you'll get the point), you obtain =
an equivalent of bit set,=20
without any of the extra pointers you mentioned. With bitview<std::vector> =
you get a sort of
dynamic_bitset (the class provides resize() only if the underlying contain=
er provides it)
The interface need to be refined a lot for a serious proposal, but I think =
the core idea is good.
Also not that this class supports some access to subranges (similar to vala=
rray slices), that
bitset lacks, and that I think it's not less important.
> =20
> Wrapping it over an std::vector, we'll have boost::dynamic_bitset for fre=
e.
>=20
> Well not quite, a hypothetical bitset_view I imagine would work like arra=
y_view in that it just wraps over a pair or pointers and gives you a bit ac=
cess API over the buffer. In fact I'd probably define such a bitset_view to=
just accept an array_view in its constructor so that it can generically wr=
ap any kind of buffer by piggybacking off of array_view's capabilities. Suc=
h is the power and magnificence of array_view!=20
>=20
> Supporting a dynamic bitset would require some additional logic to handle=
growing via push_back(). It probably needs to be its own class. Also I'm n=
ot sure I see a value having a dynamic_bitset_view over a std::vector? Do y=
ou have a use case for that?
> =20
Yes, in my data structure I use the same bitview both backed by an std::arr=
ay, an std::array_view and a std::vector in three
different places. Of course, that's because I don't have boost::dynamic_bit=
set. But being able to use one flexible type in three
different use cases instead of three different but highly similar types is =
a good thing to me.
>=20
> Probably we want separate bitset (std::array), dynamic_bitset (std::vecto=
r), and bitset_view (std::array_view).
>=20
I understand why it could be simpler, yet I think a sufficiently general un=
derlying mechanism could be used to
implement all of them.
Bye,
Nicola
--=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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_74B98940-B87B-46F9-995C-4AC4AD695728
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>Il giorn=
o 02/ott/2014, alle ore 15:38, Matthew Fioravante <<a href=3D"mailto:fma=
tthew5876@gmail.com">fmatthew5876@gmail.com</a>> ha scritto:</div><br cl=
ass=3D"Apple-interchange-newline"><blockquote type=3D"cite"><div dir=3D"ltr=
"><br><br>On Thursday, October 2, 2014 3:51:38 AM UTC-4, Nicola Gigante wro=
te:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;=
border-left: 1px #ccc solid;padding-left: 1ex;"><div style=3D"word-wrap:bre=
ak-word"></div></blockquote><br><div>It depends on how bitset_view is imple=
mented. If its implemented on top of array_view (which I would recommend), =
this is a non-starter because the object would contain 2 extra pointers. De=
feating the entire purpose of my current proposal.<br></div></div></blockqu=
ote><div><br></div><div>My idea would be not to base the class on something=
specific (array_view or something else), but to have the class to be wrapp=
ed</div><div>as a template parameter and include an object of such a class =
inside it.</div><div><br></div><div>I’ve implemented once something r=
elated for a data structure we’re developing at my university:</div><=
div><br></div><div><a href=3D"https://github.com/nicola-gigante/bitvector/b=
lob/master/include/bitview.h">https://github.com/nicola-gigante/bitvector/b=
lob/master/include/bitview.h</a></div><div><br></div><div>The interface is =
tailored to our application and not at all similar to bitset but the aim</d=
iv><div>is the same: to access the individual bits of a piece of data.</div=
><div><br></div><div>If you instantiate bitview<array_view> you get a=
non-owning view that, superimposed on</div><div>array_view, wraps any cont=
ainer you like. If you instantiate bitview<std::array> (the arity of =
the template</div><div>is not the same, you need a typedef, but you’l=
l get the point), you obtain an equivalent of bit set, </div><div>with=
out any of the extra pointers you mentioned. With bitview<std::vector>=
; you get a sort of</div><div> dynamic_bitset (the class provides resi=
ze() only if the underlying container provides it)</div><div><br></div><div=
>The interface need to be refined a lot for a serious proposal, but I think=
the core idea is good.</div><div>Also not that this class supports some ac=
cess to subranges (similar to valarray slices), that</div><div>bitset lacks=
, and that I think it’s not less important.</div><br><blockquote type=
=3D"cite"><div dir=3D"ltr"><div> </div><blockquote class=3D"gmail_quot=
e" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;paddin=
g-left: 1ex;"><div style=3D"word-wrap:break-word">Wrapping it over an std::=
vector, we’ll have boost::dynamic_bitset for free.</div></blockquote>=
<div><br>Well not quite, a hypothetical bitset_view I imagine would work li=
ke array_view in that it just wraps over a pair or pointers and gives you a=
bit access API over the buffer. In fact I'd probably define such a bitset_=
view to just accept an array_view in its constructor so that it can generic=
ally wrap any kind of buffer by piggybacking off of array_view's capabiliti=
es. Such is the power and magnificence of array_view! <br><br>Supporting a =
dynamic bitset would require some additional logic to handle growing via pu=
sh_back(). It probably needs to be its own class. Also I'm not sure I see a=
value having a dynamic_bitset_view over a std::vector? Do you have a use c=
ase for that?<br> <br></div></div></blockquote><div><br></div><div>Yes=
, in my data structure I use the same bitview both backed by an std::array,=
an std::array_view and a std::vector in three</div><div>different places. =
Of course, that’s because I don’t have boost::dynamic_bitset. B=
ut being able to use one flexible type in three</div><div>different use cas=
es instead of three different but highly similar types is a good thing to m=
e.</div><br><blockquote type=3D"cite"><div dir=3D"ltr"><br>Probably we want=
separate bitset (std::array), dynamic_bitset (std::vector), and bitset_vie=
w (std::array_view).<br><br></div></blockquote><div><br></div><div>I unders=
tand why it could be simpler, yet I think a sufficiently general underlying=
mechanism could be used to</div><div>implement all of them.</div></div><br=
><div>Bye,</div><div>Nicola</div></body></html>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_74B98940-B87B-46F9-995C-4AC4AD695728--
.
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Thu, 2 Oct 2014 08:25:47 -0700 (PDT)
Raw View
------=_Part_6742_2027325697.1412263547681
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Thursday, October 2, 2014 9:59:32 AM UTC-4, Nicola Gigante wrote:
>
>
> Il giorno 02/ott/2014, alle ore 15:38, Matthew Fioravante <
> fmatth...@gmail.com <javascript:>> ha scritto:
>
>
>
> On Thursday, October 2, 2014 3:51:38 AM UTC-4, Nicola Gigante wrote:
>>
>>
> It depends on how bitset_view is implemented. If its implemented on top o=
f=20
> array_view (which I would recommend), this is a non-starter because the=
=20
> object would contain 2 extra pointers. Defeating the entire purpose of my=
=20
> current proposal.
>
>
> My idea would be not to base the class on something specific (array_view=
=20
> or something else), but to have the class to be wrapped
> as a template parameter and include an object of such a class inside it.
>
> I=E2=80=99ve implemented once something related for a data structure we=
=E2=80=99re=20
> developing at my university:
>
> https://github.com/nicola-gigante/bitvector/blob/master/include/bitview.h=
=20
> <https://www.google.com/url?q=3Dhttps%3A%2F%2Fgithub.com%2Fnicola-gigante=
%2Fbitvector%2Fblob%2Fmaster%2Finclude%2Fbitview.h&sa=3DD&sntz=3D1&usg=3DAF=
QjCNFLz8FMkFyDeduAjRUMw1uC0O7cUA>
>
This kind of approach is very difficult to do generically. The devil is in=
=20
the details.
For one, you're assuming the underlying container has a single argument=20
constructor which takes an integral size. This works for std::vector but=20
not for std::array, a C array, or an array_view which already have an=20
implicit size and don't need any constructor arguments. You've got to=20
somehow detect and handle both concepts correctly.
This also doesn't really support the full dynamic_bitset semantics. For=20
instance you cannot resize or push_back() into the underlying container if=
=20
it is a dynamic one like a vector. Your bitview only models a fixed size=20
collection of bits. Again you've got to determine whether or not your=20
container can be resized and support this behavior if so.
In order to do this kind of generic thing effectively you need to define=20
some concepts such as "fixed size buffer" (array_view) and "dynamically=20
growing buffer" (vector). Its better to modularize and outsource those=20
concepts to more pure interfaces designed only for them such as array_view=
=20
and dynamic_array_view. The array_view handles all of the logic related to=
=20
a fixed size buffer. Then built on top of that foundation, your bitset_view=
=20
only needs to worry about manipulating the bits of that buffer. By=20
leveraging array_view, bitset_view works on any imaginable kind of fixed=20
size buffer for free. Its a better separation and encapsulation.
Once you have those concepts, its better to make different bitview types=20
over them. If I have a bitset_view and a dynamic_bitset_view I know=20
immediately what to expect and don't have to know or care what the=20
underlying representation is. If I have a bitview<array>, bitview<vector>,=
=20
bitview<my_custom_array_class>, I don't know what the semanics of the=20
bitview is until I look at the underlying container. It also requires more=
=20
template parameters to be passed around. I can pass a bitset_view to a=20
normal function. If I'm passing around a bitview<T>, I have to use=20
templates everywhere.
Now finally, you mentioned that one benefit of your approach is that=20
std::bitset and std::dynamic_bitset could just be implemented trivially=20
using the bitview. This is actually not a concern for us we generally don't=
=20
care how things are implemented, as long as they fit the specification=20
efficiently. We hate our implementers and don't care how much work we=20
create for them ;).
There's only 1 way to really do a fixed size bitset and that's just create=
=20
an array and operate on the bits. We don't really need configurability=20
there. For a dynamic bitset, you could argue there are multiple=20
possibilities, just as there are many ways to implement the equivalent of=
=20
std::vector. Or maybe someone wants dequeue or something else crazy. We=20
aren't talking about dynamic_bitset yet so I don't yet want to go there.
I hope that made sense. Things get fuzzier when we go outside of bits and=
=20
bytes and start talking design philosophies.
--=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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_6742_2027325697.1412263547681
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Thursday, October 2, 2014 9:59:32 AM UTC-4, Nic=
ola Gigante wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div style=
=3D"word-wrap:break-word"><br><div><div>Il giorno 02/ott/2014, alle ore 15:=
38, Matthew Fioravante <<a href=3D"javascript:" target=3D"_blank" gdf-ob=
fuscated-mailto=3D"EflviVTShfIJ" onmousedown=3D"this.href=3D'javascript:';r=
eturn true;" onclick=3D"this.href=3D'javascript:';return true;">fmatth...@g=
mail.com</a>> ha scritto:</div><br><blockquote type=3D"cite"><div dir=3D=
"ltr"><br><br>On Thursday, October 2, 2014 3:51:38 AM UTC-4, Nicola Gigante=
wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8e=
x;border-left:1px #ccc solid;padding-left:1ex"><div style=3D"word-wrap:brea=
k-word"></div></blockquote><br><div>It depends on how bitset_view is implem=
ented. If its implemented on top of array_view (which I would recommend), t=
his is a non-starter because the object would contain 2 extra pointers. Def=
eating the entire purpose of my current proposal.<br></div></div></blockquo=
te><div><br></div><div>My idea would be not to base the class on something =
specific (array_view or something else), but to have the class to be wrappe=
d</div><div>as a template parameter and include an object of such a class i=
nside it.</div><div><br></div><div>I=E2=80=99ve implemented once something =
related for a data structure we=E2=80=99re developing at my university:</di=
v><div><br></div><div><a href=3D"https://www.google.com/url?q=3Dhttps%3A%2F=
%2Fgithub.com%2Fnicola-gigante%2Fbitvector%2Fblob%2Fmaster%2Finclude%2Fbitv=
iew.h&sa=3DD&sntz=3D1&usg=3DAFQjCNFLz8FMkFyDeduAjRUMw1uC0O7cUA"=
target=3D"_blank" onmousedown=3D"this.href=3D'https://www.google.com/url?q=
\75https%3A%2F%2Fgithub.com%2Fnicola-gigante%2Fbitvector%2Fblob%2Fmaster%2F=
include%2Fbitview.h\46sa\75D\46sntz\0751\46usg\75AFQjCNFLz8FMkFyDeduAjRUMw1=
uC0O7cUA';return true;" onclick=3D"this.href=3D'https://www.google.com/url?=
q\75https%3A%2F%2Fgithub.com%2Fnicola-gigante%2Fbitvector%2Fblob%2Fmaster%2=
Finclude%2Fbitview.h\46sa\75D\46sntz\0751\46usg\75AFQjCNFLz8FMkFyDeduAjRUMw=
1uC0O7cUA';return true;">https://github.com/nicola-<wbr>gigante/bitvector/b=
lob/master/<wbr>include/bitview.h</a></div></div></div></blockquote><div><b=
r>This kind of approach is very difficult to do generically. The devil is i=
n the details.<br><br>For one, you're assuming the underlying container has=
a single argument constructor which takes an integral size. This works for=
std::vector but not for std::array, a C array, or an array_view which alre=
ady have an implicit size and don't need any constructor arguments. You've =
got to somehow detect and handle both concepts correctly.<br><br>This also =
doesn't really support the full dynamic_bitset semantics. For instance you =
cannot resize or push_back() into the underlying container if it is a dynam=
ic one like a vector. Your bitview only models a fixed size collection of b=
its. Again you've got to determine whether or not your container can be res=
ized and support this behavior if so.<br><br>In order to do this kind of ge=
neric thing effectively you need to define some concepts such as "fixed siz=
e buffer" (array_view) and "dynamically growing buffer" (vector). Its bette=
r to modularize and outsource those concepts to more pure interfaces design=
ed only for them such as array_view and dynamic_array_view. The array_view =
handles all of the logic related to a fixed size buffer. Then built on top =
of that foundation, your bitset_view only needs to worry about manipulating=
the bits of that buffer. By leveraging array_view, bitset_view works on an=
y imaginable kind of fixed size buffer for free. Its a better separation an=
d encapsulation.<br><br>Once you have those concepts, its better to make di=
fferent bitview types over them. If I have a bitset_view and a dynamic_bits=
et_view I know immediately what to expect and don't have to know or care wh=
at the underlying representation is. If I have a bitview<array>, bitv=
iew<vector>, bitview<my_custom_array_class>, I don't know what =
the semanics of the bitview is until I look at the underlying container. It=
also requires more template parameters to be passed around. I can pass a b=
itset_view to a normal function. If I'm passing around a bitview<T>, =
I have to use templates everywhere.<br><br>Now finally, you mentioned that =
one benefit of your approach is that std::bitset and std::dynamic_bitset co=
uld just be implemented trivially using the bitview. This is actually not a=
concern for us we generally don't care how things are implemented, as long=
as they fit the specification efficiently. We hate our implementers and do=
n't care how much work we create for them ;).<br><br>There's only 1 way to =
really do a fixed size bitset and that's just create an array and operate o=
n the bits. We don't really need configurability there. For a dynamic bitse=
t, you could argue there are multiple possibilities, just as there are many=
ways to implement the equivalent of std::vector. Or maybe someone wants de=
queue or something else crazy. We aren't talking about dynamic_bitset yet s=
o I don't yet want to go there.<br><br>I hope that made sense. Things get f=
uzzier when we go outside of bits and bytes and start talking design philos=
ophies.<br></div><br></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_6742_2027325697.1412263547681--
.
Author: ricky.65@hotmail.com
Date: Thu, 2 Oct 2014 09:04:21 -0700 (PDT)
Raw View
------=_Part_6988_756819387.1412265861452
Content-Type: text/plain; charset=UTF-8
On Wednesday, October 1, 2014 4:03:14 PM UTC+1, Matthew Fioravante wrote:
>
>
> A separate type would be better:
>
> template <typename N> using fast_bitset = bitset<N, /* Implementation
> defined */>
> template <typename N> using small_bitset = bitset<N, /* Implementation
> defined */>
>
These look reasonable to me and I feel that they would generally appease
users in both camps. People who want fine-grain control can always specify
their own template parameter.
Finally, (this might be a separate proposal) bitset::to_string() is really
> an inefficient design. It returns a std::string which will require a memory
> allocation.
>
I also don't like bitset::to_string() but I still like the ability of
returning a std::string. It doesn't always require a memory allocation if
the implementation uses SSO. I feel it would be preferable if it were a
non-member function instead.
Instead of that, to_string() could return std::array<char,N+1>, which holds
> a null terminated bitstring.
I like the idea of returning a std::array but I'm not sure if a null
terminator is necessary. May I suggest the name "to_array" instead of
modifying to_string().
Probably we want separate bitset (std::array), dynamic_bitset
> (std::vector), and bitset_view (std::array_view).
I agree. That would comprise a suite of bitset containers that would likely
satisfy most programmers bitset requirements. Incidentally, does anybody
know the status of std::dynamic_bitset? I know it was proposed for TR2 but
I haven't read anything since.
-Riccardo
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_6988_756819387.1412265861452
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Wednesday, October 1, 2014 4:03:14 PM UTC+1, Matthew Fi=
oravante wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-=
left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr=
"><div><br>A separate type would be better:<br><br><div style=3D"background=
-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bo=
rder-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#008">=
template</span><span style=3D"color:#000"> </span><span style=3D"color:#660=
"><</span><span style=3D"color:#008">typename</span><span style=3D"color=
:#000"> N</span><span style=3D"color:#660">></span><span style=3D"color:=
#000"> </span><span style=3D"color:#008">using</span><span style=3D"color:#=
000"> fast_bitset </span><span style=3D"color:#660">=3D</span><span style=
=3D"color:#000"> bitset</span><span style=3D"color:#660"><</span><span s=
tyle=3D"color:#000">N</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> </span><span style=3D"color:#800">/* Implementation define=
d */</span><span style=3D"color:#660">></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:#0=
08">typename</span><span style=3D"color:#000"> N</span><span style=3D"color=
:#660">></span><span style=3D"color:#000"> </span><span style=3D"color:#=
008">using</span><span style=3D"color:#000"> small_bitset </span><span styl=
e=3D"color:#660">=3D</span><span style=3D"color:#000"> bitset</span><span s=
tyle=3D"color:#660"><</span><span style=3D"color:#000">N</span><span sty=
le=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D=
"color:#800">/* Implementation defined */</span><span style=3D"color:#660">=
></span><span style=3D"color:#000"><br></span></div></code></div></div><=
/div></blockquote><div><br></div><div> These look reasonable to me and=
I feel that they would generally appease users in both camps. People who w=
ant fine-grain control can always specify their own template parameter.&nbs=
p;</div><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0=
px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, =
204); border-left-style: solid; padding-left: 1ex;">Finally, (this might be=
a separate proposal) bitset::to_string() is really an inefficient design. =
It returns a std::string which will require a memory allocation.<br></block=
quote><div><br></div><div>I also don't like bitset::to_string() but I still=
like the ability of returning a std::string. It doesn't always requir=
e a memory allocation if the implementation uses SSO. I feel it would be pr=
eferable if it were a non-member function instead.</div><div><br></div><blo=
ckquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-le=
ft-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: so=
lid; padding-left: 1ex;">Instead of that, to_string() could return std::arr=
ay<char,N+1>, which holds a null terminated bitstring.</blockquote><d=
iv><br></div><div>I like the idea of returning a std::array but I'm not sur=
e if a null terminator is necessary. May I suggest the name "to_array" inst=
ead of modifying to_string().</div><div><br></div><blockquote class=3D"gmai=
l_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border=
-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1e=
x;">Probably we want separate bitset (std::array), dynamic_bitset (std::vec=
tor), and bitset_view (std::array_view).</blockquote><div><br></div><div>I =
agree. That would comprise a suite of bitset containers that would likely s=
atisfy most programmers bitset requirements. Incidentally, does anybody kno=
w the status of std::dynamic_bitset? I know it was proposed for TR2 but I h=
aven't read anything since.</div><div><br></div><div>-Riccardo</div></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_6988_756819387.1412265861452--
.
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Thu, 2 Oct 2014 09:12:11 -0700 (PDT)
Raw View
------=_Part_799_1118273478.1412266331369
Content-Type: text/plain; charset=UTF-8
On Thursday, October 2, 2014 12:04:21 PM UTC-4, rick...@hotmail.com wrote:
>
>
> Instead of that, to_string() could return std::array<char,N+1>, which
>> holds a null terminated bitstring.
>
>
> I like the idea of returning a std::array but I'm not sure if a null
> terminator is necessary. May I suggest the name "to_array" instead of
> modifying to_string().
>
>
Better would be fixed_string (other thread) or string_literal (a real
proposal). Anyway the string thing is just a minor rant. That's unrelated
to this proposal. If raised in earnest I would write a new paper for that
issue alone.
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_799_1118273478.1412266331369
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Thursday, October 2, 2014 12:04:21 PM UTC-4, ri=
ck...@hotmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: =
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div d=
ir=3D"ltr"><br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p=
x 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-lef=
t-style:solid;padding-left:1ex">Instead of that, to_string() could return s=
td::array<char,N+1>, which holds a null terminated bitstring.</blockq=
uote><div><br></div><div>I like the idea of returning a std::array but I'm =
not sure if a null terminator is necessary. May I suggest the name "to_arra=
y" instead of modifying to_string().</div><div><br></div></div></blockquote=
><div><br>Better would be fixed_string (other thread) or string_literal (a =
real proposal). Anyway the string thing is just a minor rant. That's unrela=
ted to this proposal. If raised in earnest I would write a new paper for th=
at issue alone.<br></div><div> </div><br></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_799_1118273478.1412266331369--
.
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Thu, 2 Oct 2014 18:55:28 -0700 (PDT)
Raw View
------=_Part_7565_1695776350.1412301328940
Content-Type: text/plain; charset=UTF-8
Final draft candidate for this paper is available:
https://github.com/fmatthew5876/stdcxx-bitset/
Please let me know if you have anymore suggestions or comments. Otherwise
this version will be submitted.
Thanks!
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_7565_1695776350.1412301328940
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Final draft candidate for this paper is available:<div><br=
></div><div>https://github.com/fmatthew5876/stdcxx-bitset/<br></div><div><b=
r></div><div>Please let me know if you have anymore suggestions or comments=
.. Otherwise this version will be submitted.</div><div><br>Thanks!</div></di=
v>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_7565_1695776350.1412301328940--
.
Author: Nicola Gigante <nicola.gigante@gmail.com>
Date: Fri, 3 Oct 2014 08:43:59 +0200
Raw View
Il giorno 02/ott/2014, alle ore 17:25, Matthew Fioravante <fmatthew5876@gma=
il.com> ha scritto:
> This kind of approach is very difficult to do generically. The devil is i=
n the details.
>=20
> For one, you're assuming the underlying container has a single argument c=
onstructor which takes an integral size. This works for std::vector but not=
for std::array, a C array, or an array_view which already have an implicit=
size and don't need any constructor arguments. You've got to somehow detec=
t and handle both concepts correctly.
>=20
> This also doesn't really support the full dynamic_bitset semantics. For i=
nstance you cannot resize or push_back() into the underlying container if i=
t is a dynamic one like a vector. Your bitview only models a fixed size col=
lection of bits. Again you've got to determine whether or not your containe=
r can be resized and support this behavior if so.
>=20
> In order to do this kind of generic thing effectively you need to define =
some concepts such as "fixed size buffer" (array_view) and "dynamically gro=
wing buffer" (vector). Its better to modularize and outsource those concept=
s to more pure interfaces designed only for them such as array_view and dyn=
amic_array_view. The array_view handles all of the logic related to a fixed=
size buffer. Then built on top of that foundation, your bitset_view only n=
eeds to worry about manipulating the bits of that buffer. By leveraging arr=
ay_view, bitset_view works on any imaginable kind of fixed size buffer for =
free. Its a better separation and encapsulation.
>=20
> Once you have those concepts, its better to make different bitview types =
over them. If I have a bitset_view and a dynamic_bitset_view I know immedia=
tely what to expect and don't have to know or care what the underlying repr=
esentation is. If I have a bitview<array>, bitview<vector>, bitview<my_cust=
om_array_class>, I don't know what the semanics of the bitview is until I l=
ook at the underlying container. It also requires more template parameters =
to be passed around. I can pass a bitset_view to a normal function. If I'm =
passing around a bitview<T>, I have to use templates everywhere.
>=20
> Now finally, you mentioned that one benefit of your approach is that std:=
:bitset and std::dynamic_bitset could just be implemented trivially using t=
he bitview. This is actually not a concern for us we generally don't care h=
ow things are implemented, as long as they fit the specification efficientl=
y. We hate our implementers and don't care how much work we create for them=
;).
>=20
> There's only 1 way to really do a fixed size bitset and that's just creat=
e an array and operate on the bits. We don't really need configurability th=
ere. For a dynamic bitset, you could argue there are multiple possibilities=
, just as there are many ways to implement the equivalent of std::vector. O=
r maybe someone wants dequeue or something else crazy. We aren't talking ab=
out dynamic_bitset yet so I don't yet want to go there.
>=20
> I hope that made sense. Things get fuzzier when we go outside of bits and=
bytes and start talking design philosophies.
>=20
>=20
Yes, it makes sense. Now I agree with you that a single oversized class is =
not the best idea.
Bye,
Nicola
--=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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.