220 13609 <FF740D55-733D-4969-8388-FC9E53F05C65@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: The view concept
Date: Fri, 3 Oct 2014 08:56:42 +0200
Lines: 99
Approved: news@gmane.org
Message-ID: <FF740D55-733D-4969-8388-FC9E53F05C65@gmail.com>
References: <428c47bd-67f2-47d1-98c0-e5ca85698076@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: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1412319414 19008 80.91.229.3 (3 Oct 2014 06:56:54 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 3 Oct 2014 06:56:54 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDMMZOF5V4KBBLMRXGQQKGQEIJJNZCA@isocpp.org Fri Oct 03 08:56:47 2014
Return-path: <std-proposals+bncBDMMZOF5V4KBBLMRXGQQKGQEIJJNZCA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wi0-f199.google.com ([209.85.212.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDMMZOF5V4KBBLMRXGQQKGQEIJJNZCA@isocpp.org>)
	id 1XZwnH-0004kE-54
	for gclcip-std-proposals@m.gmane.org; Fri, 03 Oct 2014 08:56:47 +0200
Original-Received: by mail-wi0-f199.google.com with SMTP id d1sf434020wiv.6
        for <gclcip-std-proposals@m.gmane.org>; Thu, 02 Oct 2014 23:56:46 -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:subject:from:in-reply-to:date
         :message-id:references: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:content-transfer-encoding;
        bh=fl9YunSoecE4jZX9v06mRYbJCpatBmpzJxW5quCaWvo=;
        b=UkYdEeggLeUyEVJiYwPC7IEIR9NU1MxGAQIVrgUmcO/YIFFAjtlVHIWN3w2qjUBekA
         LD7fqARq3RAcTBjzNKuu5Q7nnQvVV+cK9ePtaRxYcRArkQEpKXinrTojKgczPsxuaqo5
         B9p3RB8wFnqrFqV+emhTanJxKONq3J9VPjPQro2WFq1+rt0miveC860tA/cCkPrmZUTA
         QiUSzMBP68f9up9FACW28SdDcZvQHj2dDl5Ggd5zr72CZtnIm+qdXjUx0y3s01Kd60GD
         6NpVES9K/V/NsQHwDOMra8ytnJHrSuC5bT3QQC3o97+XfUuEiwfolQIFXhjX0AigPJxN
         rD6Q==
X-Gm-Message-State: ALoCoQmhGy2NxhYWu+MHVZQ93wlLbBDy9+mdhod/v/hSU6y6smnNjvK21MMpXhPoX2phf4YZMmPg
X-Received: by 10.152.29.130 with SMTP id k2mr646738lah.3.1412319406806;
        Thu, 02 Oct 2014 23:56:46 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.103.8 with SMTP id fs8ls193942wib.48.canary; Thu, 02 Oct
 2014 23:56:45 -0700 (PDT)
X-Received: by 10.180.86.73 with SMTP id n9mr10004792wiz.30.1412319405557;
        Thu, 02 Oct 2014 23:56:45 -0700 (PDT)
Original-Received: from mail-wi0-x235.google.com (mail-wi0-x235.google.com [2a00:1450:400c:c05::235])
        by mx.google.com with ESMTPS id em19si7898631wjd.52.2014.10.02.23.56.45
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Thu, 02 Oct 2014 23:56:45 -0700 (PDT)
Received-SPF: pass (google.com: domain of nicola.gigante@gmail.com designates 2a00:1450:400c:c05::235 as permitted sender) client-ip=2a00:1450:400c:c05::235;
Original-Received: by mail-wi0-f181.google.com with SMTP id hi2so1125564wib.14
        for <std-proposals@isocpp.org>; Thu, 02 Oct 2014 23:56:45 -0700 (PDT)
X-Received: by 10.180.75.49 with SMTP id z17mr9941535wiv.3.1412319405458;
        Thu, 02 Oct 2014 23:56:45 -0700 (PDT)
Original-Received: from [158.110.153.153] ([158.110.153.153])
        by mx.google.com with ESMTPSA id iy10sm1081664wic.5.2014.10.02.23.56.43
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Thu, 02 Oct 2014 23:56:44 -0700 (PDT)
In-Reply-To: <428c47bd-67f2-47d1-98c0-e5ca85698076@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:c05::235 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:13609
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/13609>


Il giorno 03/ott/2014, alle ore 07:40, Matthew Fioravante <fmatthew5876@gma=
il.com> ha scritto:

> With array_view, string_view, and now possibly bitset_view, this view thi=
ng is becoming contagious.
>=20
> I think at this stage it makes sense to precisely define exactly what a v=
iew is and how it behaves as a concept. Any kind of view type that is inven=
ted now or in the future should adhere to a set of rules so that they all h=
ave a uniform interface.
>=20
> First, what exactly is a view?
>=20
> I would define it as an adapter over a fixed size contiguous range of mem=
ory.
>=20

I like the idea to set in stone those definitions.=20
First question, why is the memory block necessary contiguous
for all kinds of view?
I think it would be reasonable to expect a bitset_view to work on top
of a strided array_view that sits on top of a contiguous buffer.

You could even have things like a filter_view, that discards elements
that don't satisfy a predicate, on top of a sorted_view, etc...

If one goes this way I see some overlap with the work in progress
on ranges. Maybe the two things could be made to fit together
(a view will be a range, anyway).

The contiguity is necessary to support the data() member, but other
than that it is sufficient that the underlying container/buffer have
random access iterators, I think. If it only has forward iterators
you can remove the operator[] from the interface through SFINAE=20
and only provide iterators yourself.


> How does a view behave with respect to common operations?
>=20
> Let's compare a view<T>, to a T, and T* and see how they behave. These ru=
les are derived from string_view and array_view.
>=20
> T =3D T: copy the value (deep copy)
> T* =3D T*: reassign the pointer (shallow copy)
> view<T> =3D view<T>: reassign the view (shallow copy)
>=20
> T =3D=3D T: compare 2 values (deep compare)
> T* =3D=3D T*: compare whether 2 pointers point to the same thing (shallow=
 compare)
> view<T> =3D=3D view<T>: compare the values (deep compare)
>=20
> T.foo(): direct member invocation of T
> (T*)->foo(): indirect member invocation of T
> view<T>.foo(): direct member invocation of the view type methods
>=20
> Questions:
> 1) How do we shallow compare 2 views?
> 2) How do we deep copy a view?
>=20
> What are the common operations for any view?
>=20
> 1) We can iterate over a view with begin()/end()
> 2) We can access an element using operator[] / at() / front() / back() / =
data()
> 3) We can ask for the size() and whether or not the view is empty()
> 4) We can shrink the view by removing front or back elements, but not mak=
e it larger. Once you chop off the front or back of the view, you can never=
 recover it.
> 5) We can reassign the view to another source array
> 6) We can compare 2 views
>=20
> The array_view proposal also gets into multi-dimensional views and stridi=
ng, but I'm not going to go there yet.
>=20
> If there are a certain set of operations that apply to any kind of view, =
then perhaps it makes sense to define and mandate them for all of the view =
classes. This could even be done with inheritance. Have a basic_view<T> bas=
e class which implements the above methods and have array_view (striding / =
sectioning / dimensions), string_view (string class), bitset_view (bit mani=
pulation) build on top of that.
>=20

Good ideas!

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/.

.
