220 31510 <fe192db2-f40d-43cf-a251-9e456cd3430c@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: 3dw4rd@verizon.net
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: compressed std::bitset<N>
Date: Wed, 8 Mar 2017 14:26:07 -0800 (PST)
Lines: 365
Approved: news@gmane.org
Message-ID: <fe192db2-f40d-43cf-a251-9e456cd3430c@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>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_470_813546826.1489011967203"
X-Trace: blaine.gmane.org 1489011971 11781 195.159.176.226 (8 Mar 2017 22:26:11 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 8 Mar 2017 22:26:11 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCS2FYFYXYEBB74JQLDAKGQESPGTZXY@isocpp.org Wed Mar 08 23:26:06 2017
Return-path: <std-proposals+bncBCS2FYFYXYEBB74JQLDAKGQESPGTZXY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua0-f200.google.com ([209.85.217.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCS2FYFYXYEBB74JQLDAKGQESPGTZXY@isocpp.org>)
	id 1clk1z-0002Lo-2R
	for gclcip-std-proposals@m.gmane.org; Wed, 08 Mar 2017 23:26:03 +0100
Original-Received: by mail-ua0-f200.google.com with SMTP id q7sf74011037uaf.0
        for <gclcip-std-proposals@m.gmane.org>; Wed, 08 Mar 2017 14:26:09 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to: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=QM149fsfzrJFC89I1bMHY+l/4FVfZXMmnvrE+HUPLVU=;
        b=0D5Xr3/vlvKV3mXovbd+MGrTvoGFbJNh4DvOchnIKCkyUa4FrLh9YiYIz1F6osUmF+
         B3wPpLx+ocQvIbXg9AiZugU0xTcySOi3b2NsKdHE5v6AJfRQsG2nvMDmMfT9bfzFB1XU
         7Bt2JkUPm5Q8wOFxmNu6qaSPTmfafWSvTmity3nJnB5eWfhxwuuHLyRvs1APTaWPqPzB
         EcTZaHy9Lebgc+YoJ80LmQauMYwmVAApqWr0vnjC+Nr/wRjSYmYyjKj/w2e3A+bAHnKd
         4DmQR7QtMmu5yDL9EjnbeU/zjlN+Rr76OZHaPNddFL4TJmslyNdaJpehMXR6xV3J7WBE
         hCLQ==
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: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=QM149fsfzrJFC89I1bMHY+l/4FVfZXMmnvrE+HUPLVU=;
        b=bk53vfz8XZanZCorodQKK8hYzR0osKMdcSS0R/b8xQLdao0JREUutM63uNphT11Kdf
         Si1UtbRl5AEYb8ZHqlbD3tGFWJHzC1R3FsNjoGGcLF2VFdAkJtTr8A+OsqySr6b0daNJ
         kcSs8JzJiVaDE2zO74RWManIv3pLh2FowFMBeF0fEH3PYZEZtqkH7KCsbDmbVyfe9rGN
         VhO82WViz/jO7wU5h1yKfxriS5oH12dl+F/ALiBEByX4vgZ8EnKZjzVYiEjaFr5zbjbz
         u+z6sw3Oor3R83Ym0QXYYMjznY2JzCoC8i6bx5RSMZKIcDKSdmVlODJK+NbYrE2gJc84
         XZBw==
X-Gm-Message-State: AMke39m2h5hMW7fYnaFvT7NPfTYb/cQdOWlXuoFonc4/Fp6jr5KnPGnIClY0u+Py2L1FTg==
X-Received: by 10.129.95.133 with SMTP id t127mr4072523ywb.94.1489011968792;
        Wed, 08 Mar 2017 14:26:08 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.34.49 with SMTP id o46ls326033ota.35.gmail; Wed, 08 Mar
 2017 14:26:07 -0800 (PST)
X-Received: by 10.157.36.169 with SMTP id z38mr1313795ota.14.1489011967794;
        Wed, 08 Mar 2017 14:26:07 -0800 (PST)
In-Reply-To: <3c737844-0d92-3713-7b7d-06130959a877@wanadoo.fr>
X-Original-Sender: 3dw4rd@verizon.net
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:31510
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/31510>

------=_Part_470_813546826.1489011967203
Content-Type: multipart/alternative; 
	boundary="----=_Part_471_2060387384.1489011967203"

------=_Part_471_2060387384.1489011967203
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



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 <javascript:> 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 bu=
t=20
>> with enhanced functionality. It let's you set the underlying integral ty=
pe=20
>> of the bitset. In fact, it defaults to uint8_t, uint16_t, or uint32_t if=
=20
>> N bits fit into those integers. I would like this functionality added to=
=20
>> 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 std=
::
> 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 the=
=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 d=
o=20
> 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.
We could also not a a default type.
=20

> If the data function returns a span<T,N> we don't need the leaf iterator=
=20
> functions.
>
=20
This is good.  My one worry was that my API was getting baroque with both=
=20
vector and bitset access.

I've heard people want similar choices for a dynamic_bitset:
template<typename LeafTp =3D unsigned long long>
  class bit_vector
  {
    // pretty much like bitset except I would add
    using leaf_type =3D LeafTp;
    leaf_iterator lbegin() //=20
    leaf_iterator lend(); //=20
  };

People who do encryption wanted to set the size of the leaf and have access=
=20
to leaves.
I chose bit_array and bit_vector to have a similar relationship as array=20
and vector do.

For the names I believe we should stay close to bitset and dynamic_bitset.=
=20
But we can not use bitset :(
I need to think more about your bit_array/bit_vector suggestion, but=20
array/vector don't have set operations. I will go towards bit_set and=20
dynamic_bit_set.
In addition bit_array<int16_t, 10> could be misleading as array<int16_t,=20
10> has a completely different meaning and layout. Do we have 10 int16_t?

We could bikeshed for ever ;-)  Maybe bitvec and dynamic_bitvec?
I see your point about confusion though.

I could almost see a reason for a UDL bits, and bytes.  APIs could take=20
either.
They would *not *convert to ints automatically.  APIs taking number of=20
elements (array, vector, ...) would remain unchanged.
This is almost like <units>.
But numeric and bitset types would be able to take bits and bytes.  These=
=20
UDLs would return bit_size_t and byte_size_t that could inter-convert=20
between each other but not to integers without a to_size_t() or something.
This might help the fixed_point people and bit utility.  Or it might annoy=
=20
them.



Vicente

>

--=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/fe192db2-f40d-43cf-a251-9e456cd3430c%40isocpp.or=
g.

------=_Part_471_2060387384.1489011967203
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Wednesday, March 8, 2017 at 7:44:56 AM UTC-5, V=
icente J. Botet Escriba wrote:<blockquote class=3D"gmail_quote" style=3D"ma=
rgin: 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 href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"Bx=
Cl0knQCwAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&#3=
9;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;"=
>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 face=3D"arial, sans-serif" size=3D"2">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>We could also no=
t a a default type.<br></div><div>=C2=A0</div><blockquote class=3D"gmail_qu=
ote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padd=
ing-left: 1ex;"><div bgcolor=3D"#FFFFFF" text=3D"#000000">
    If the data function returns a span&lt;T,N&gt; we don&#39;t need the
    leaf iterator functions.<br></div></blockquote><div bgcolor=3D"#FFFFFF"=
 text=3D"#000000">=C2=A0<br>This is good.=C2=A0 My one worry was that my AP=
I was getting baroque with both vector and bitset access.<br><br>
    <blockquote type=3D"cite">
      <div dir=3D"ltr">
        <div><font size=3D"2">I&#39;ve heard people want similar choices fo=
r a
            dynamic_bitset:<br>
          </font>
          <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">&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_vector<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>
                </span></div>
            </code></div>
          <br>
          People who do encryption wanted to set the size of the leaf
          and have access to leaves.<br>
          I chose <span style=3D"font-family:courier new,monospace">bit_arr=
ay</span>
          and <span style=3D"font-family:courier new,monospace">bit_vector<=
/span>
          to have a similar relationship as <span style=3D"font-family:cour=
ier new,monospace">array</span> and <span style=3D"font-family:courier new,=
monospace">vector</span>
          do.<br>
        </div>
      </div>
    </blockquote>
    For the names I believe we should stay close to bitset and
    dynamic_bitset. But we can not use bitset :(<br>
    I need to think more about your bit_array/bit_vector suggestion, but
    array/vector don&#39;t have set operations. I will go towards bit_set
    and dynamic_bit_set.<br>
    In addition bit_array&lt;int16_t, 10&gt; could be misleading as
    array&lt;int16_t, 10&gt; has a completely different meaning and
    layout. Do we have 10 int16_t?<br><br>We could bikeshed for ever ;-)=C2=
=A0 Maybe bitvec and dynamic_bitvec?<br>I see your point about confusion th=
ough.<br><br>I could almost see a reason for a UDL bits, and bytes.=C2=A0 A=
PIs could take either.<br>They would <b>not </b>convert to ints automatical=
ly.=C2=A0 APIs taking number of elements (array, vector, ...) would remain =
unchanged.<br>This is almost like &lt;units&gt;.<br>But numeric and bitset =
types would be able to take bits and bytes.=C2=A0 These UDLs would return b=
it_size_t and byte_size_t that could inter-convert between each other but n=
ot to integers without a to_size_t() or something.<br>This might help the f=
ixed_point people and bit utility.=C2=A0 Or it might annoy them.<br><br><br=
>
    <br>
    Vicente<br>
  </div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0=
..8ex;border-left: 1px #ccc solid;padding-left: 1ex;">

</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/fe192db2-f40d-43cf-a251-9e456cd3430c%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/fe192db2-f40d-43cf-a251-9e456cd3430c=
%40isocpp.org</a>.<br />

------=_Part_471_2060387384.1489011967203--

------=_Part_470_813546826.1489011967203--

.
