220 13528 <9462C54C-E91B-4B66-AA8E-CAEA1F190FE6@gmail.com> article
Path: news.gmane.org!not-for-mail
From: Nicola Gigante <nicola.gigante@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal: Strongly Typed Bitset
Date: Thu, 2 Oct 2014 15:59:27 +0200
Lines: 177
Approved: news@gmane.org
Message-ID: <9462C54C-E91B-4B66-AA8E-CAEA1F190FE6@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> <CALDL7dEa=68AkS+LQzNzAnCQq9xrTX6r1qz1OV1aEDVBT3uOiA@mail.gmail.com> <fc3c2097-d86b-4ca9-9e9f-e345ea99ba3b@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\))
Content-Type: multipart/alternative; boundary="Apple-Mail=_74B98940-B87B-46F9-995C-4AC4AD695728"
X-Trace: ger.gmane.org 1412258377 15148 80.91.229.3 (2 Oct 2014 13:59:37 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 2 Oct 2014 13:59:37 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDMMZOF5V4KBBQ5UWWQQKGQE537WEVY@isocpp.org Thu Oct 02 15:59:32 2014
Return-path: <std-proposals+bncBDMMZOF5V4KBBQ5UWWQQKGQE537WEVY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ee0-f72.google.com ([74.125.83.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDMMZOF5V4KBBQ5UWWQQKGQE537WEVY@isocpp.org>)
	id 1XZguq-0003Xf-B0
	for gclcip-std-proposals@m.gmane.org; Thu, 02 Oct 2014 15:59:32 +0200
Original-Received: by mail-ee0-f72.google.com with SMTP id e51sf1214522eek.11
        for <gclcip-std-proposals@m.gmane.org>; Thu, 02 Oct 2014 06:59:31 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:mime-version:subject:date
         :references:to:in-reply-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=PdvyDI0pc1AuOvR6Nn9Tw7v7i6P5RcdjXm6u9z9gjMs=;
        b=b3PVpbi4VcR1DrYyQa1CU/SqrqNOjIkYakeS77hTH42LX6O3xnU6fcgxHIjdbSUhb6
         g7anCAZ06a/XGuyPtnVcCYauCkNqKtf3ak/cGh3fJ6VUJDESSUmsJ7xo6B6YnnDL4Brc
         kYuC7C0CjhGB3rLbXQ03enoS7scEXfoAz5JhHNMiD8QXaDQvJRYyYdFvDl7uCZHUoSmV
         NU1N/QTEkY90LDgvsU9ZPAg2rf6mKWua7ba5iH6HiiZ572g8smV67ah6mFqva4munAks
         qABEOoI78P//9twc2SXu1tpTUSxs78hwfTeCBhBH/gtYMiibTTuzdYMJ40mW2fnyq6Wy
         yq+w==
X-Gm-Message-State: ALoCoQm2ZtSbbE7GvR4iw4kPjZlEHaO229TJDWi0BDd7wSgE2LQVBDh3I5dISiDDt/25jqqJSDc1
X-Received: by 10.180.81.130 with SMTP id a2mr791421wiy.0.1412258371910;
        Thu, 02 Oct 2014 06:59:31 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.95.98 with SMTP id dj2ls90015wib.15.canary; Thu, 02 Oct
 2014 06:59:31 -0700 (PDT)
X-Received: by 10.180.72.239 with SMTP id g15mr4289951wiv.47.1412258371024;
        Thu, 02 Oct 2014 06:59:31 -0700 (PDT)
Original-Received: from mail-wg0-x22c.google.com (mail-wg0-x22c.google.com [2a00:1450:400c:c00::22c])
        by mx.google.com with ESMTPS id jk5si1305885wid.3.2014.10.02.06.59.31
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Thu, 02 Oct 2014 06:59:31 -0700 (PDT)
Received-SPF: pass (google.com: domain of nicola.gigante@gmail.com designates 2a00:1450:400c:c00::22c as permitted sender) client-ip=2a00:1450:400c:c00::22c;
Original-Received: by mail-wg0-f44.google.com with SMTP id y10so3222278wgg.3
        for <std-proposals@isocpp.org>; Thu, 02 Oct 2014 06:59:30 -0700 (PDT)
X-Received: by 10.194.179.73 with SMTP id de9mr73111858wjc.87.1412258370681;
        Thu, 02 Oct 2014 06:59:30 -0700 (PDT)
Original-Received: from [192.168.1.105] (adsl-ull-121-178.51-151.net24.it. [151.51.178.121])
        by mx.google.com with ESMTPSA id c7sm1356525wib.12.2014.10.02.06.59.29
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Thu, 02 Oct 2014 06:59:29 -0700 (PDT)
In-Reply-To: <fc3c2097-d86b-4ca9-9e9f-e345ea99ba3b@isocpp.org>
X-Mailer: Apple Mail (2.1878.6)
X-Original-Sender: nicola.gigante@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of nicola.gigante@gmail.com designates 2a00:1450:400c:c00::22c as
 permitted sender) smtp.mail=nicola.gigante@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:13528
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/13528>

--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 &lt;<a href=3D"mailto:fma=
tthew5876@gmail.com">fmatthew5876@gmail.com</a>&gt; 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&rsquo;ve implemented once something r=
elated for a data structure we&rsquo;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&lt;array_view&gt; you get a=
 non-owning view that, superimposed on</div><div>array_view, wraps any cont=
ainer you like. If you instantiate bitview&lt;std::array&gt; (the arity of =
the template</div><div>is not the same, you need a typedef, but you&rsquo;l=
l get the point), you obtain an equivalent of bit set,&nbsp;</div><div>with=
out any of the extra pointers you mentioned. With bitview&lt;std::vector&gt=
; you get a sort of</div><div>&nbsp;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&rsquo;s not less important.</div><br><blockquote type=
=3D"cite"><div dir=3D"ltr"><div>&nbsp;</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&rsquo;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>&nbsp;<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&rsquo;s because I don&rsquo;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&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 />

--Apple-Mail=_74B98940-B87B-46F9-995C-4AC4AD695728--

.
