220 31502 <4238c4e6-51f5-4a2f-94c8-f61ca415e7e0@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: 3dw4rd@verizon.net
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: compressed std::bitset<N>
Date: Tue, 7 Mar 2017 21:23:38 -0800 (PST)
Lines: 215
Approved: news@gmane.org
Message-ID: <4238c4e6-51f5-4a2f-94c8-f61ca415e7e0@isocpp.org>
References: <32cfea0a-7df8-47cf-47fd-549985f12295@wanadoo.fr>
 <06e829ca-417b-470c-95ca-c661e8752f79@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_12_1932790725.1488950618864"
X-Trace: blaine.gmane.org 1488950628 5060 195.159.176.226 (8 Mar 2017 05:23:48 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 8 Mar 2017 05:23:48 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCS2FYFYXYEBBW5K73CQKGQEWSQI4QI@isocpp.org Wed Mar 08 06:23:42 2017
Return-path: <std-proposals+bncBCS2FYFYXYEBBW5K73CQKGQEWSQI4QI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f200.google.com ([209.85.220.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCS2FYFYXYEBBW5K73CQKGQEWSQI4QI@isocpp.org>)
	id 1clU4a-00008u-Cu
	for gclcip-std-proposals@m.gmane.org; Wed, 08 Mar 2017 06:23:40 +0100
Original-Received: by mail-qk0-f200.google.com with SMTP id n141sf55896990qke.1
        for <gclcip-std-proposals@m.gmane.org>; Tue, 07 Mar 2017 21:23:41 -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=1geA4qAxJ4Lv9cJES7XsuoCfop9jjvBCJGnCcVKpg7o=;
        b=JIkYSBklTUZC281TcNvE55LuMTWUpTTHzhMr29wdniDftpCsxKyIzy8CCBmUXOLaqr
         r0ck/X98Yt+wDlbyktJuSpyzQuFoYKwjm2rvUskpTau9GuMzAXFTcx8p1xeYV8cmuxAM
         tOWHHIMT3ypt8tVq7HDj7reex0TKgZpVQRuK3Cv9iOJAtG4doc5mpSHOkBOB2xRcsUX1
         QPvUW3+hzm7Ft/dTu5Uwx0AR3EWr8WfDEnYHcKyyztOoCYQJq9JNsF7uX7UZy9ttKYCk
         KnCu8mIjkZdm+k9aw+/xss+UUrmHyqEJCAqDN4gDeLl6xg4qYdRqqObgxL7aAZHq4WhW
         Khuw==
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=1geA4qAxJ4Lv9cJES7XsuoCfop9jjvBCJGnCcVKpg7o=;
        b=BNsmOp/kAKXJO73PQ+uaDvattYaIiQDLfW0fH3XWvCMnJS+/GehNjq/C5Wp4CUf8hW
         kOOrGwfzbRt3S2tqEJWgq0AKoJWyvAVXvfDww855GEi+Yua5cNF4UZFh4ns2XlAVx9tX
         3AwMw6pvptj6eOX4xhg4evrbYjown2YAY93mtafD6s4MBBhCGisG+ABWJHBmtA+Ux8Hy
         VMpn/WMOycwQYA+0mA4sy2Dt43sb/qROSe7wEud7EWwaR8Z6vRo1pHSxQFlibWLjG11A
         pEisIfOWrfTllYuTu+uv+ge6wr3/qX6fE89xVMMaA6bihgZL1hl399BnQiDYGUMwH0qe
         4dqQ==
X-Gm-Message-State: AMke39lk1wKUa2HyyLhfq5hilEYCf4naKYbVOLXBv6aYAwE02Bct0hPPvLqEljqMQl5NpA==
X-Received: by 10.200.56.211 with SMTP id g19mr1047761qtc.6.1488950620257;
        Tue, 07 Mar 2017 21:23:40 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.53.6 with SMTP id o6ls2347024otc.47.gmail; Tue, 07 Mar
 2017 21:23:39 -0800 (PST)
X-Received: by 10.157.22.200 with SMTP id s8mr562320ots.16.1488950619550;
        Tue, 07 Mar 2017 21:23:39 -0800 (PST)
In-Reply-To: <06e829ca-417b-470c-95ca-c661e8752f79@isocpp.org>
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:31502
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/31502>

------=_Part_12_1932790725.1488950618864
Content-Type: multipart/alternative; 
	boundary="----=_Part_13_552856765.1488950618864"

------=_Part_13_552856765.1488950618864
Content-Type: text/plain; charset=UTF-8



On Tuesday, February 21, 2017 at 3:40:00 PM UTC-5, ricky6565 wrote:
>
> Hi Vicente,
>
> I think the Bitset2 <https://github.com/ClaasBontus/bitset2>library by 
> Claas Bontus provides what you are looking for. It's like std::bitset but 
> with enhanced functionality. It let's you set the underlying integral type 
> of the bitset. In fact, it defaults to uint8_t, uint16_t, or uint32_t if N bits 
> fit into those integers. I would like this functionality added 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 
bitset leaf-type:

template<typename LeafTp = unsigned long long, std::size_t Bits = std::
numeric_limits<LeafTp>::digits>
  class bit_array
  {
    // pretty much like bitset except I would add
    using leaf_type = LeafTp;
    leaf_iterator lbegin() // 
    leaf_iterator lend(); // 
  };


This is flipped relative to Bitset2 in that leaf type comes first and the 
template would decide how many leaves based on bits.

So now you could get these small bitsets:
using bitset16 = bit_array<uint16_t>;
etc.

I've heard people want similar choices for a dynamic_bitset:
template<typename LeafTp = unsigned long long>
  class bit_vector
  {
    // pretty much like bitset except I would add
    using leaf_type = LeafTp;
    leaf_iterator lbegin() // 
    leaf_iterator lend(); // 
  };

People who do encryption wanted to set the size of the leaf and have access 
to leaves.
I chose bit_array and bit_vector to have a similar relationship as array 
and vector do.

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4238c4e6-51f5-4a2f-94c8-f61ca415e7e0%40isocpp.org.

------=_Part_13_552856765.1488950618864
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<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;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr">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" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://www.go=
ogle.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FClaasBontus%2Fbitset2\x26sa\x3=
dD\x26sntz\x3d1\x26usg\x3dAFQjCNGK_wFmX3DVScYeyAQGywgQn25crA&#39;;return tr=
ue;" onclick=3D"this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2=
F%2Fgithub.com%2FClaasBontus%2Fbitset2\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNGK_wFmX3DVScYeyAQGywgQn25crA&#39;;return true;">Bitset2 </a>library by =
Claas Bontus provides what you are looking for. It&#39;s like std::bitset b=
ut with enhanced functionality. It let&#39;s you set the underlying integra=
l 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=
:rgb(51,51,51)">if N</span><span style=3D"color:rgb(51,51,51)">=C2=A0bits f=
it into those integers.</span>=C2=A0I would like this functionality added t=
o std::bitset but, as you said, it would probably be a breaking change.</fo=
nt></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;=
 overflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">template</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">typename</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Le=
afTp</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">unsigned</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">long</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">long</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">size_t </sp=
an><span style=3D"color: #606;" class=3D"styled-by-prettify">Bits</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">numeric_limits</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">LeafTp</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">&gt;::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">digits</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br>=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">class</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> bit_array<br>=C2=A0 </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #800;" class=3D"styled-b=
y-prettify">// pretty much like bitset except I would add</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">using</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> leaf_type </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
606;" class=3D"styled-by-prettify">LeafTp</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 leaf_iterator lbegin</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: #=
800;" class=3D"styled-by-prettify">// </span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 leaf_iterator lend</span><spa=
n 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=
: #800;" class=3D"styled-by-prettify">// </span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br></span></div></code></div><br>This is flipp=
ed 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 sm=
all bitsets:<br>using bitset16 =3D bit_array&lt;uint16_t&gt;;<br>etc.<br><b=
r><font size=3D"2">I&#39;ve heard people want similar choices for a dynamic=
_bitset:<br></font><div style=3D"background-color: rgb(250, 250, 250); bord=
er-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; overf=
low-wrap: break-word;" class=3D"prettyprint"><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: #660;" class=3D"styled-by-p=
rettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">typename</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">LeafTp</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">unsigned</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">long</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">long</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>class</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> bit=
_vector<br>=C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>=C2=A0 =C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-pre=
ttify">// pretty much like bitset except I would add</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">using</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> leaf_type </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606=
;" class=3D"styled-by-prettify">LeafTp</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>=C2=A0 =C2=A0 leaf_iterator lbegin</span><span style=
=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: #800;"=
 class=3D"styled-by-prettify">// </span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 leaf_iterator lend</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #8=
00;" class=3D"styled-by-prettify">// </span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span></div></code></div><br>People who do encrypt=
ion wanted to set the size of the leaf and have access to leaves.<br>I chos=
e <span style=3D"font-family: courier new,monospace;">bit_array</span> and =
<span style=3D"font-family: courier new,monospace;">bit_vector</span> to ha=
ve a similar relationship as <span style=3D"font-family: courier new,monosp=
ace;">array</span> and <span style=3D"font-family: courier new,monospace;">=
vector</span> do.<br></div></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/4238c4e6-51f5-4a2f-94c8-f61ca415e7e0%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/4238c4e6-51f5-4a2f-94c8-f61ca415e7e0=
%40isocpp.org</a>.<br />

------=_Part_13_552856765.1488950618864--

------=_Part_12_1932790725.1488950618864--

.
