220 13518 <CALDL7dEa=68AkS+LQzNzAnCQq9xrTX6r1qz1OV1aEDVBT3uOiA@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Farid Mehrabi <farid.mehrabi@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal: Strongly Typed Bitset
Date: Thu, 2 Oct 2014 14:52:59 +0330
Lines: 154
Approved: news@gmane.org
Message-ID: <CALDL7dEa=68AkS+LQzNzAnCQq9xrTX6r1qz1OV1aEDVBT3uOiA@mail.gmail.com>
References: <f77c8cc7-64f6-4d3b-9a10-8a5ee5f2254d@isocpp.org>
 <113390b2-9c74-47e2-a943-5d27dd48bdf1@isocpp.org> <CAGg_6+P+Hsq_stLp4+CTyK3ezvOvCAyCy7hBu+ZqSbJMfJHQ8w@mail.gmail.com>
 <41983d24-efb2-4255-b09b-f84cff7bf56d@isocpp.org> <f24d9028-86d6-4fc7-b5bf-03aacebb18d5@isocpp.org>
 <63de9d71-e3b0-4242-9698-bea3a307b3c7@isocpp.org> <B1C4DDBA-B386-4B07-A0CA-8E79FDD2E3A8@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=bcaec53d5b1ff0562a05046ed74d
X-Trace: ger.gmane.org 1412249010 18497 80.91.229.3 (2 Oct 2014 11:23:30 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 2 Oct 2014 11:23:30 +0000 (UTC)
To: std-proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC27JR6ERAOBBJ7LWSQQKGQE32WS45A@isocpp.org Thu Oct 02 13:23:25 2014
Return-path: <std-proposals+bncBC27JR6ERAOBBJ7LWSQQKGQE32WS45A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wg0-f70.google.com ([74.125.82.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC27JR6ERAOBBJ7LWSQQKGQE32WS45A@isocpp.org>)
	id 1XZeTg-0008E6-U5
	for gclcip-std-proposals@m.gmane.org; Thu, 02 Oct 2014 13:23:21 +0200
Original-Received: by mail-wg0-f70.google.com with SMTP id a1sf1037089wgh.1
        for <gclcip-std-proposals@m.gmane.org>; Thu, 02 Oct 2014 04:23:20 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe:content-type;
        bh=+Ox5shnPufYtlsnU4TtciRKdEWz0BFwTP95HETaADzA=;
        b=QswmyrfzrB6cZ5Orsf2XglqZ5Tl+khWvEfsNPGH0AF3gwgPWGvyToGzbAjqwIbZpDk
         nFI84c74YY5M400p3v2jLlYJerAEWpiVS682LAQPLaPcdv4uum6PygrQVWeHiA29kZY5
         3f4zaY4nsb9+Rrt/ZZlYTyPmx0sjOg9KCwjCG/xsPRdNlw5Goc+u//KHQKQb4NWsnBEN
         nZ0V7pBKp9McOpDEe1tEeX2qmKS9gDUvJMzrL/5/nDSOpavf1sXIZBiQUp4vi1A8M+i1
         spphtqQsdGKUleZlHV2VAKpsFvRjMCfb7kdHAWyJvxFXjILNi1NeEbXErkUY0RHBYpS1
         dAsA==
X-Gm-Message-State: ALoCoQkRB3/7EDykrjG5XCeH5EgckKbmNM+9W2TzFM6h7/UQitm3Em8mXiYwHwEKDBTZqyfX/oSY
X-Received: by 10.112.6.138 with SMTP id b10mr409316lba.18.1412249000607;
        Thu, 02 Oct 2014 04:23:20 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.126.105 with SMTP id mx9ls63882wib.53.gmail; Thu, 02 Oct
 2014 04:23:19 -0700 (PDT)
X-Received: by 10.180.95.163 with SMTP id dl3mr3161686wib.79.1412248999561;
        Thu, 02 Oct 2014 04:23:19 -0700 (PDT)
Original-Received: from mail-wi0-x232.google.com (mail-wi0-x232.google.com [2a00:1450:400c:c05::232])
        by mx.google.com with ESMTPS id er10si762824wib.88.2014.10.02.04.23.19
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Thu, 02 Oct 2014 04:23:19 -0700 (PDT)
Received-SPF: pass (google.com: domain of farid.mehrabi@gmail.com designates 2a00:1450:400c:c05::232 as permitted sender) client-ip=2a00:1450:400c:c05::232;
Original-Received: by mail-wi0-f178.google.com with SMTP id cc10so3677321wib.5
        for <std-proposals@isocpp.org>; Thu, 02 Oct 2014 04:23:19 -0700 (PDT)
X-Received: by 10.180.20.139 with SMTP id n11mr3389008wie.22.1412248999317;
 Thu, 02 Oct 2014 04:23:19 -0700 (PDT)
Original-Received: by 10.217.41.5 with HTTP; Thu, 2 Oct 2014 04:22:59 -0700 (PDT)
In-Reply-To: <B1C4DDBA-B386-4B07-A0CA-8E79FDD2E3A8@gmail.com>
X-Original-Sender: farid.mehrabi@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of farid.mehrabi@gmail.com designates 2a00:1450:400c:c05::232 as
 permitted sender) smtp.mail=farid.mehrabi@gmail.com;       dkim=pass
 header.i=@gmail.com;       dmarc=pass (p=NONE dis=NONE) header.from=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: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://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>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:13518
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/13518>

--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">&lt;<a href=3D"mailto:nicola.gigante@gmail.com" target=3D"_blank">nic=
ola.gigante@gmail.com</a>&gt;</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 &lt;<a hre=
f=3D"mailto:fmatthew5876@gmail.com" target=3D"_blank">fmatthew5876@gmail.co=
m</a>&gt; ha scritto:</div><span class=3D""><br><blockquote type=3D"cite"><=
div dir=3D"ltr">I&#39;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&#39;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)">&lt;</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)">&gt;</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)">&lt;</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)">&gt;</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)">&lt;</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)">)&gt;</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)">&lt;</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)">&gt;</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&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 />
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--

.
