220 31512 <dd7dfbe0-8a9e-4fe4-b37a-312c495f648f@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: compressed std::bitset<N>
Date: Wed, 8 Mar 2017 15:22:45 -0800 (PST)
Lines: 257
Approved: news@gmane.org
Message-ID: <dd7dfbe0-8a9e-4fe4-b37a-312c495f648f@isocpp.org>
References: <32cfea0a-7df8-47cf-47fd-549985f12295@wanadoo.fr>
 <06e829ca-417b-470c-95ca-c661e8752f79@isocpp.org>
 <4238c4e6-51f5-4a2f-94c8-f61ca415e7e0@isocpp.org>
 <3c737844-0d92-3713-7b7d-06130959a877@wanadoo.fr>
 <fe192db2-f40d-43cf-a251-9e456cd3430c@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_507_675719803.1489015365692"
X-Trace: blaine.gmane.org 1489015367 27032 195.159.176.226 (8 Mar 2017 23:22:47 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 8 Mar 2017 23:22:47 +0000 (UTC)
Cc: 3dw4rd@verizon.net
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBRVEQLDAKGQETVU2PJI@isocpp.org Thu Mar 09 00:22:42 2017
Return-path: <std-proposals+bncBCEKFTV6ZUMBBRVEQLDAKGQETVU2PJI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pf0-f200.google.com ([209.85.192.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBRVEQLDAKGQETVU2PJI@isocpp.org>)
	id 1clkun-0006JH-Fn
	for gclcip-std-proposals@m.gmane.org; Thu, 09 Mar 2017 00:22:41 +0100
Original-Received: by mail-pf0-f200.google.com with SMTP id l66sf83254089pfl.6
        for <gclcip-std-proposals@m.gmane.org>; Wed, 08 Mar 2017 15:22:47 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=qylYIaEcaUsCvc9HeuYDVVt4Cuhg/sgmDbxqJufJGLE=;
        b=nPue4s7HxhrjhRfYTdlAttr2EMAnslvWvUdV1FDMvzStWcHffY79SnPtWW6FXq24yO
         D0M5aJQgiDwKI60rIf4VAl2MnssM0zjC7eO9mht//3UcvCumnuO/78ozT0UKTskFxYPC
         4B8gc3OJGy6zSfXdJm+A6dIe6WdzUlePLDuimBxXq9zvaZZvksqmEzHsY22PyipIleZO
         jpC7xuRuO64JcVsZ0xoG1qKvvCI17CckexrBh2PvEIoWoglFNqkzh8CALSOsuQv8E5QH
         4uaUUjicQG+F408fP5pPF6aLGOEyuAJ7tkJ98isdvucgH/UvHDYyXOyqR1kWCzB4V4Cx
         0EQw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=qylYIaEcaUsCvc9HeuYDVVt4Cuhg/sgmDbxqJufJGLE=;
        b=YJoNuBU41q6o7iW0Z4hdX/yB1Wwv6q4FZ+GPfQ9vqQ+UB/cwDTOS28/aysLGhWIZai
         t8tXKtTyPI9houD4ahlxXyGojtzFVniRKktuXoBm3Dtii0j2epHGxL99z9WnZLdj9hNK
         lj8nOMefAb+S2C7h/D5zo3ov19YdMuJFGp8h68Rqm2V8YEAicun7a2a+KvYr0DxlwX2w
         TOi/UjSzCtlEhF1elGsrXO/bV43GFQarDiV0wXa6hsppfzBgSSsGzppE9NmXKM5DVULe
         p7sXJtHXb9SdkTMWB+Y38huMwRWPZMzSs3cUBlVkDI/qePLIzUqayYC5SmhO0YKOhfu1
         W9yw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to
         :references:subject:mime-version:x-original-sender:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=qylYIaEcaUsCvc9HeuYDVVt4Cuhg/sgmDbxqJufJGLE=;
        b=UGoxkXO2/SmyTq15azxENQCIkAYWWJVyTIVuhL8UytOCc+wUchOwvru4KokeR0ijFt
         /dvgjmghebE26Bmsk2LqEf+c5MpQRRPprXG4htCY9LoRsFTRhOeni4Ic6YHNnmcHcunX
         lZh/jfhjPHIaSTv460qZ6k22gUGssgyM5P5lwVoj2874+xyTKOzVAoWgl7Kosnie75gt
         cdpTmEWwtX6MwVPIlX8BBwxGd/RuniDi08Br6xodAiErJyY3tErez3CKpJ6ggo5hbWv8
         mbjLtzoHxhEGxmDXL7TjKaCRL5AWevHJtwvyIKgzYjodgsnRmgpl7Zrv9ZGsnkfDB60V
         uEOQ==
X-Gm-Message-State: AMke39lX8PzNSiEke65ikNo+pORDP1zYg8d/Bhqp8qel9ce7+HjiHUxdZJB9Z88bGyDpqw==
X-Received: by 10.99.64.129 with SMTP id n123mr4295397pga.61.1489015367243;
        Wed, 08 Mar 2017 15:22:47 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.62.1 with SMTP id a1ls4896773otd.37.gmail; Wed, 08 Mar
 2017 15:22:46 -0800 (PST)
X-Received: by 10.157.18.133 with SMTP id g5mr1335011otg.8.1489015366382;
        Wed, 08 Mar 2017 15:22:46 -0800 (PST)
In-Reply-To: <fe192db2-f40d-43cf-a251-9e456cd3430c@isocpp.org>
X-Original-Sender: jmckesson@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:31512
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/31512>

------=_Part_507_675719803.1489015365692
Content-Type: multipart/alternative; 
	boundary="----=_Part_508_416094480.1489015365692"

------=_Part_508_416094480.1489015365692
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Wednesday, March 8, 2017 at 5:26:07 PM UTC-5, 3dw...@verizon.net wrote:
>
>
>
> On Wednesday, March 8, 2017 at 7:44:56 AM UTC-5, Vicente J. Botet Escriba=
=20
> wrote:
>>
>> Le 08/03/2017 =C3=A0 06:23, 3dw...@verizon.net a =C3=A9crit :
>>
>>
>>
>> On Tuesday, February 21, 2017 at 3:40:00 PM UTC-5, ricky6565 wrote:=20
>>>
>>> Hi Vicente,=20
>>>
>>> I think the Bitset2 <https://github.com/ClaasBontus/bitset2>library by=
=20
>>> Claas Bontus provides what you are looking for. It's like std::bitset b=
ut=20
>>> with enhanced functionality. It let's you set the underlying integral t=
ype=20
>>> of the bitset. In fact, it defaults to uint8_t, uint16_t, or uint32_t i=
f=20
>>> N bits fit into those integers. I would like this functionality added=
=20
>>> to std::bitset but, as you said, it would probably be a breaking change=
..
>>>
>>> Riccardo
>>>
>>
>> I was just thinking something similar.  Allow the user to specify the=20
>> bitset leaf-type:
>>
>> template<typename LeafTp =3D unsigned long long, std::size_t Bits =3D st=
d::
>> numeric_limits<LeafTp>::digits>
>>   class bit_array
>>   {
>>     // pretty much like bitset except I would add
>>     using leaf_type =3D LeafTp;
>>     leaf_iterator lbegin() //=20
>>     leaf_iterator lend(); //=20
>>   };
>>
>>
>> This is flipped relative to Bitset2 in that leaf type comes first and th=
e=20
>> template would decide how many leaves based on bits.
>>
>> So now you could get these small bitsets:
>> using bitset16 =3D bit_array<uint16_t>;
>> etc.
>>
>> I believe that both orders could have have usage (see below), an alias=
=20
>> templates should help here to have both.
>> However I don't like the possibility to have bit_array<>. How many bits=
=20
>> do we have?
>>
>
> In this case bit_array<> is bit_array<unsigned long long,=20
> std::numeric_limits<unsigned long long>::digits>
> so on my system, 64-bits.  Perhaps we want a fixed size integral type as=
=20
> the default type.
>

You can't use a type that implementations are not required to support.

We could also not a a default type.
>

Um, why not? Really, what's wrong with `unsigned int`? There are plenty of=
=20
people who don't care about what the "leaf" type is; they just want a=20
convenient class for doing bit manipulation with. Why make things=20
needlessly difficult for them?

>

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/dd7dfbe0-8a9e-4fe4-b37a-312c495f648f%40isocpp.or=
g.

------=_Part_508_416094480.1489015365692
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Wednesday, March 8, 2017 at 5:26:07 PM UTC-5, 3=
dw...@verizon.net 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><br>On Wednesday, March 8, 2017 at 7:44:56 AM UTC-5, Vicente=
 J. Botet Escriba wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0=
;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div>Le 08/03/2017 =C3=A0 06:23,
      <a rel=3D"nofollow">3dw...@verizon.net</a> a =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote type=3D"cite">
      <div dir=3D"ltr"><br>
        <br>
        On Tuesday, February 21, 2017 at 3:40:00 PM UTC-5, ricky6565
        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">Hi Vicente,
            <div><br>
            </div>
            <div><font size=3D"2" face=3D"arial, sans-serif">I think the <a=
 href=3D"https://github.com/ClaasBontus/bitset2" rel=3D"nofollow" target=3D=
"_blank" onmousedown=3D"this.href=3D&#39;https://www.google.com/url?q\x3dht=
tps%3A%2F%2Fgithub.com%2FClaasBontus%2Fbitset2\x26sa\x3dD\x26sntz\x3d1\x26u=
sg\x3dAFQjCNGK_wFmX3DVScYeyAQGywgQn25crA&#39;;return true;" onclick=3D"this=
..href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FCla=
asBontus%2Fbitset2\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGK_wFmX3DVScYeyA=
QGywgQn25crA&#39;;return true;">Bitset2 </a>library by Claas Bontus provide=
s
                what you are looking for. It&#39;s like std::bitset but wit=
h
                enhanced functionality. It let&#39;s you set the underlying
                integral type of the bitset. In fact, it=C2=A0<span style=
=3D"color:rgb(51,51,51)">defaults to uint8_t,
                  uint16_t, or uint32_t=C2=A0</span><span style=3D"color:rg=
b(51,51,51)">if N</span><span style=3D"color:rgb(51,51,51)">=C2=A0bits fit =
into those
                  integers.</span>=C2=A0I would like this functionality add=
ed
                to std::bitset but, as you said, it would probably be a
                breaking change.</font></div>
            <div><br>
            </div>
            <div>Riccardo<br>
            </div>
          </div>
        </blockquote>
        <div><br>
          I was just thinking something similar.=C2=A0 Allow the user to
          specify the bitset leaf-type:<br>
          <br>
          <div style=3D"background-color:rgb(250,250,250);border-color:rgb(=
187,187,187);border-style:solid;border-width:1px"><code>
              <div><span style=3D"color:#008">template</span><span style=3D=
"color:#660">&lt;</span><span style=3D"color:#008">typename</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#606">LeafTp</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#660">=3D</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">unsigned</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">long</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">long</span><span style=
=3D"color:#660">,</span><span style=3D"color:#000"> std</span><span style=
=3D"color:#660">::</span><span style=3D"color:#000">size_t
                </span><span style=3D"color:#606">Bits</span><span style=3D=
"color:#000"> </span><span style=3D"color:#660">=3D</span><span style=3D"co=
lor:#000"> std</span><span style=3D"color:#660">::</span><span style=3D"col=
or:#000">numeric_limits</span><span style=3D"color:#660">&lt;</span><span s=
tyle=3D"color:#606">LeafTp</span><span style=3D"color:#660">&gt;::</span><s=
pan style=3D"color:#000">d<wbr>igits</span><span style=3D"color:#660">&gt;<=
/span><span style=3D"color:#000"><br>
                  =C2=A0 </span><span style=3D"color:#008">class</span><spa=
n style=3D"color:#000">
                  bit_array<br>
                  =C2=A0 </span><span style=3D"color:#660">{</span><span st=
yle=3D"color:#000"><br>
                  =C2=A0 =C2=A0 </span><span style=3D"color:#800">// pretty=
 much like bitset
                  except I would add</span><span style=3D"color:#000"><br>
                  =C2=A0 =C2=A0 </span><span style=3D"color:#008">using</sp=
an><span style=3D"color:#000">
                  leaf_type </span><span style=3D"color:#660">=3D</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#606">LeafTp</span><sp=
an style=3D"color:#660">;</span><span style=3D"color:#000"><br>
                  =C2=A0 =C2=A0 leaf_iterator lbegin</span><span style=3D"c=
olor:#660">()</span><span style=3D"color:#000"> </span><span style=3D"color=
:#800">// </span><span style=3D"color:#000"><br>
                  =C2=A0 =C2=A0 leaf_iterator lend</span><span style=3D"col=
or:#660">();</span><span style=3D"color:#000"> </span><span style=3D"color:=
#800">// </span><span style=3D"color:#000"><br>
                  =C2=A0 </span><span style=3D"color:#660">};</span><span s=
tyle=3D"color:#000"><br>
                  <br>
                </span></div>
            </code></div>
          <br>
          This is flipped relative to Bitset2 in that leaf type comes
          first and the template would decide how many leaves based on
          bits.<br>
          <br>
          So now you could get these small bitsets:<br>
          using bitset16 =3D bit_array&lt;uint16_t&gt;;<br>
          etc.<br>
          <br>
        </div>
      </div>
    </blockquote>
    I believe that both orders could have have usage (see below), an
    alias templates should help here to have both.<br>
    However I don&#39;t like the possibility to have bit_array&lt;&gt;. How
    many bits do we have?<br></div></blockquote><div><br>In this case bit_a=
rray&lt;&gt; is bit_array&lt;unsigned long long, std::numeric_limits&lt;uns=
igned long long&gt;::digits&gt;<br>so on my system, 64-bits.=C2=A0 Perhaps =
we want a fixed size integral type as the default type.<br></div></div></bl=
ockquote><div><br>You can&#39;t use a type that implementations are not req=
uired to support.<br><br></div><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>We could also not a a default type.<br></div></div><=
/blockquote><div><br>Um, why not? Really, what&#39;s wrong with `unsigned i=
nt`? There are plenty of people who don&#39;t care about what the &quot;lea=
f&quot; type is; they just want a convenient class for doing bit manipulati=
on with. Why make things needlessly difficult for them?<br></div><blockquot=
e class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: =
1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex">

</blockquote></div></blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/dd7dfbe0-8a9e-4fe4-b37a-312c495f648f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/dd7dfbe0-8a9e-4fe4-b37a-312c495f648f=
%40isocpp.org</a>.<br />

------=_Part_508_416094480.1489015365692--

------=_Part_507_675719803.1489015365692--

.
