220 2395 <687e9b13-cec1-4776-8fa2-6ad15aaf5e24@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: =?UTF-8?Q?Andrzej_Krzemie=C5=84ski?= <akrzemi1@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: optional<T>, one more value or two states
Date: Mon, 28 Jan 2013 02:01:55 -0800 (PST)
Lines: 425
Approved: news@gmane.org
Message-ID: <687e9b13-cec1-4776-8fa2-6ad15aaf5e24@isocpp.org>
References: <CAGsORuC1ADLXgS9AZZiTo=knmhT-+9Yj+82v+b8Nq_WJpb1fOg@mail.gmail.com>
 <CAFk2RUZyZA0LLUNuVNcnibv+qBF69jMytWQL3tkp-Kp21oEU+A@mail.gmail.com>
 <CAGsORuB-Qkx-LaXj2jO4yLrwN524kiJONSg7oczkQZHYaJ6ASg@mail.gmail.com>
 <d360a952-28ae-4d57-bb20-96fd08725a0b@isocpp.org>
 <CAPXezF_JggyMaXjGS9r1EAGVu1NhQBEyGEXB8tKmVqgFfjoCeg@mail.gmail.com>
 <CALJmx62zJd_tZ=XYL7TaSkRN6432SObwH9YS87eLX-h_pMuFYQ@mail.gmail.com>
 <CAOHCbivAK0ypmMhrhJ3zKpF8BHu3h_rUNzeao-HnibJkC-qqGw@mail.gmail.com>
 <ef15483d-5665-4da3-9b79-aefd3c725e1b@isocpp.org>
 <CAOHCbithEUfm+w_06V71=hpkqGUJvqiyDFqD7fesfgLy4uUieg@mail.gmail.com>
 <2c2b9360-8e5e-422d-9b85-124bd947b004@isocpp.org>
 <123b9f65-12fd-4285-bb6c-cfee383d4552@isocpp.org>
 <CAHOE3yeF6KBBz7a1uw58oA3Shh_w0HFGiLtUGEd4ntJAKBauew@mail.gmail.com>
 <CAFk2RUZXrc5MoLdR8ie_kJqwLS1byqpv96qNX4XeEKNnXPu9hQ@mail.gmail.com>
 <CAHOE3ydsbjeP9OJhiC-5BYOnxoqUV3PUF2n6Mkf-VTN9_hJDKg@mail.gmail.com>
 <CAFk2RUa+T=SF31OVA5PJgzf70c8yox5ZT-S8+uuJdY6amrOtjg@mail.gmail.com>
 <CAHOE3yfknuLGWzoN-A1Ugb1VTQB+T9MCn3LS67_en0ZNXd+44w@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_67_14748196.1359367315941"
X-Trace: ger.gmane.org 1359367316 30338 80.91.229.3 (28 Jan 2013 10:01:56 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 28 Jan 2013 10:01:56 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDT2DGOJ34DBBFMZTGEAKGQELPD3DTY@isocpp.org Mon Jan 28 11:02:16 2013
Return-path: <std-proposals+bncBDT2DGOJ34DBBFMZTGEAKGQELPD3DTY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qa0-f71.google.com ([209.85.216.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDT2DGOJ34DBBFMZTGEAKGQELPD3DTY@isocpp.org>)
	id 1TzlXc-0004QF-3l
	for gclcip-std-proposals@m.gmane.org; Mon, 28 Jan 2013 11:02:16 +0100
Original-Received: by mail-qa0-f71.google.com with SMTP id z4sf2871188qan.2
        for <gclcip-std-proposals@m.gmane.org>; Mon, 28 Jan 2013 02:01:57 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-received:x-beenthere:x-received:date:from:to:message-id
         :in-reply-to:references:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:x-google-group-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=MN5OuigBCij5SYPZKFTK+zuSbhqMsxZC/VKNmQ6FmCU=;
        b=V1QWZlcHvDdO8ypmS4xdoRUIDut0En/TY76OswqmSGGqMCqFUUVouYwNUw95sNhvyV
         HPgENxRDcvodjEntlLrKg/F1ht4hSUeHnTdyE14vlp0WRCUa4PXPkQJvrQxXmmVBC2qT
         uI9Yi/6kI8pEhap+MfMXmrAk3Gc9cNsBmV/OqdQixw8Ftbq8YaGOYUFRMWl4wSGZlL+w
         C+FfJUhERkKLJsp3H0zjh1FUFcwiz2Z8FMXVGNE29HPD8vNHj1IdNC2R8ewYYOniVIKo
         8QglsFkqU+jPO9YwmD02thLz3Tnd8Sg660lptIOOlQ190/1uXpGNX3gsEOnNeq6yEzir
         LFcA==
X-Received: by 10.224.211.193 with SMTP id gp1mr947198qab.4.1359367317884;
        Mon, 28 Jan 2013 02:01:57 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.37.234 with SMTP id b10ls940055qek.63.gmail; Mon, 28 Jan
 2013 02:01:56 -0800 (PST)
X-Received: by 10.49.116.1 with SMTP id js1mr2262979qeb.19.1359367316403;
        Mon, 28 Jan 2013 02:01:56 -0800 (PST)
In-Reply-To: <CAHOE3yfknuLGWzoN-A1Ugb1VTQB+T9MCn3LS67_en0ZNXd+44w@mail.gmail.com>
X-Original-Sender: akrzemi1@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?hl=en>,
 <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?hl=en&topic=25838>,
 <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:2395
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/2395>

------=_Part_67_14748196.1359367315941
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable



W dniu niedziela, 27 stycznia 2013 22:27:34 UTC+1 u=BFytkownik Daniel James=
=20
napisa=B3:
>
> On 27 January 2013 20:55, Ville Voutilainen <ville.vo...@gmail.com<javasc=
ript:>>=20
> wrote:=20
> > Yes? x and y point to different things also if y is of the proposed=20
> > value_ptr type.=20
>
> Don't you think it's odd that value_ptr doesn't behave like a pointer?=20
> That's because it isn't a pointer, it's a fixed size container (like=20
> array). Calling it 'value_ptr' is like referring to 'std::vector' as=20
> 'value_ptr_with_length' - it's the implementation not the interface.=20
>
> > They point to different things if y is an auto_ptr.=20
>
> I'd forgotten about auto_ptr, but since it is deprecated, it's largely=20
> irrelevant. I think everyone agrees that auto_ptr is not an example of=20
> good design. IMO it actually supports my principle. The problem with=20
> auto_ptr is that it doesn't follow the expected semantics.=20
>
> > So there are=20
> > already exceptions=20
> > to this alleged rule, and chances are there's more exceptions coming.=
=20
>
> IMO there shouldn't be. Thanks to templates, C++ has an odd mix of=20
> structural and nominal typing. So when you have a type structure the=20
> implies a certain behaviour, it means something. I don't think saving=20
> a few characters is a good reason to break that. Anyone who does think=20
> that it is should at least acknowledge that there is a trade off here.=20
>

This is how i see it. We all first learned how a raw pointer works, and we=
=20
keep in mind all its semantics. Then, we get shared_ptr, and it is=20
different than a raw pointer, but it is still significantly similar, that=
=20
we can still call it a pointer. Then, we have unique_ptr, which is even=20
more different. For instance, your example:

    auto x =3D y;=20
    *x =3D 2;=20

fails to compile if y is a unique_ptr. But it can still be thought of as a=
=20
pointer, because parts of the reasoning for raw pointers still applies to=
=20
unique_ptr. Now, optional is even less similar to a pointer, but it still=
=20
has some similarities. And there is enough similarities to have some=20
algorithms work both on pointers and optional. During these discussions I=
=20
was already able to identify at least four algorithms:

// Not entirely C++ syntax, but you get the idea

auto less_pointees(NullableProxy const& x, NullableProxy const& y)
{
  return (!y) ? false :(!x) ? true: *x < *y;
}

auto equal_pointees(NullableProxy const& x, NullableProxy const& y)
{
  return bool(x) !=3D bool(y) ? false : bool(x) =3D=3D false ? true : *x =
=3D=3D *y;
}

auto get_value_or(NullableProxy && np, U && val)
{
  return bool(np) ? *np : val; // + forward/move
}


auto to_pointer(NullableProxy && np)
{
  return bool(np) ? addressof(*np) : nullptr;
}


auto less_value(NullableProxy const& x, U && y)
{
  return (!x) ? true : *x < y;
}

Thus, because Identifying the common parts is useful, it is beneficial to=
=20
identify what aspects of pointers are relevant for "abstracting" type=20
requirements NullableProxy, and which aren't. And conversely, there are=20
some aspects of pointer semantics that are irrelevant (and can be dropped)=
=20
when abstracting the concept. We need operator* to express algorithms=20
common to NullablePrioxy concepts, but we are only interested in one aspect=
=20
of it: giving us the reference to the hidden value (regardless of where it=
=20
is located and how it is copied -- NullableProxies do not have to be=20
copyable or moveable). The other parts of the semantics of pointers are=20
dropped when abstracting.=20

operator* offers a couple of things. I do not think there is anything that=
=20
requires of us are using all of its semantics.=20

Typically you would expect of operator* (for multiplication) to be=20
commutative. Do you consider providing operator* for matrix multiplication=
=20
a design error then?



> Some people have referred to optional as a "nullable proxy". But it=20
> isn't a proxy, it's a container (in the sense that it contains things,=20
> not in the sense of the C++ definition - although it should be, for=20
> things like flatMap).=20
>

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To post to this group, send email to std-proposals@isocpp.org.
To unsubscribe from this group, send email to std-proposals+unsubscribe@iso=
cpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/?hl=3Den.



------=_Part_67_14748196.1359367315941
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable

<br><br>W dniu niedziela, 27 stycznia 2013 22:27:34 UTC+1 u=BFytkownik Dani=
el James napisa=B3:<blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 27 Janua=
ry 2013 20:55, Ville Voutilainen &lt;<a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"euS-fquGG5QJ">ville.vo...@gmail.com</a>&gt; wr=
ote:
<br>&gt; Yes? x and y point to different things also if y is of the propose=
d
<br>&gt; value_ptr type.
<br>
<br>Don't you think it's odd that value_ptr doesn't behave like a pointer?
<br>That's because it isn't a pointer, it's a fixed size container (like
<br>array). Calling it 'value_ptr' is like referring to 'std::vector' as
<br>'value_ptr_with_length' - it's the implementation not the interface.
<br>
<br>&gt; They point to different things if y is an auto_ptr.
<br>
<br>I'd forgotten about auto_ptr, but since it is deprecated, it's largely
<br>irrelevant. I think everyone agrees that auto_ptr is not an example of
<br>good design. IMO it actually supports my principle. The problem with
<br>auto_ptr is that it doesn't follow the expected semantics.
<br>
<br>&gt; So there are
<br>&gt; already exceptions
<br>&gt; to this alleged rule, and chances are there's more exceptions comi=
ng.
<br>
<br>IMO there shouldn't be. Thanks to templates, C++ has an odd mix of
<br>structural and nominal typing. So when you have a type structure the
<br>implies a certain behaviour, it means something. I don't think saving
<br>a few characters is a good reason to break that. Anyone who does think
<br>that it is should at least acknowledge that there is a trade off here.
<br></blockquote><div><br>This is how i see it. We all first learned how a =
raw pointer works, and we keep in mind all its semantics. Then, we get shar=
ed_ptr, and it is different than a raw pointer, but it is still significant=
ly similar, that we can still call it a pointer. Then, we have unique_ptr, =
which is even more different. For instance, your example:<br><br>&nbsp;&nbs=
p;&nbsp; auto x =3D y;
<br>&nbsp; &nbsp; *x =3D 2;
<br><br>fails to compile if y is a unique_ptr. But it can still be thought =
of as a pointer, because parts of the reasoning for raw pointers still appl=
ies to unique_ptr. Now, optional is even less similar to a pointer, but it =
still has some similarities. And there is enough similarities to have some =
algorithms work both on pointers and optional. During these discussions I w=
as already able to identify at least four algorithms:<br><br><div class=3D"=
prettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: r=
gb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: break=
-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span sty=
le=3D"color: #800;" class=3D"styled-by-prettify">// Not entirely C++ syntax=
, but you get the idea</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> less_pointees</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">N=
ullableProxy</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">const</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> x</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606=
;" class=3D"styled-by-prettify">NullableProxy</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">const</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> y</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(!</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">y</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: #660;" class=3D"styled-b=
y-prettify">?</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">false<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">:(!</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">x</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">?</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">true</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">x </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">y</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
></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><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> equal_pointees</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">NullableProxy</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> x</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pret=
tify">NullableProxy</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
const</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> y</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">return</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">bool</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">x</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</=
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 styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">bool</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">y</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">?</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">false</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">bool</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">x</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: #660;" class=3D"styled-by-prettify">=3D=3D</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">false</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </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: #008;" class=3D"styled-b=
y-prettify">true</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">x </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">=3D=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">y</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></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><=
span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> get_value_or</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">NullableProxy</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">&amp;&amp;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> np</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> U </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&amp;&amp;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> val</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">return</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">np</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: #660;" class=3D"styled-b=
y-prettify">?</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">np </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> val</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">// + forward/move</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br><br><br></span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> to_pointer</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
NullableProxy</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;&=
amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> np</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">return</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">bool</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">np</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">?</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> addressof</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">(*</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">np</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">n=
ullptr</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br></span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> less_value</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #=
606;" class=3D"styled-by-prettify">NullableProxy</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">const</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> x</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> U </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;=
&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> y</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">return</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">(!</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">x</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">?</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">true</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">x </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&l=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> y</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span></div></code></div><br>Thus, =
because Identifying the common parts is useful, it is beneficial to identif=
y what aspects of pointers are relevant for "abstracting" type requirements=
 NullableProxy, and which aren't. And conversely, there are some aspects of=
 pointer semantics that are irrelevant (and can be dropped) when abstractin=
g the concept. We need operator* to express algorithms common to NullablePr=
ioxy concepts, but we are only interested in one aspect of it: giving us th=
e reference to the hidden value (regardless of where it is located and how =
it is copied -- NullableProxies do not have to be copyable or moveable). Th=
e other parts of the semantics of pointers are dropped when abstracting. <b=
r><br>operator* offers a couple of things. I do not think there is anything=
 that requires of us are using all of its semantics. <br><br>Typically you =
would expect of operator* (for multiplication) to be commutative. Do you co=
nsider providing operator* for matrix multiplication a design error then?<b=
r><br><br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<br>Some people have referred to optional as a "nullable proxy". But it
<br>isn't a proxy, it's a container (in the sense that it contains things,
<br>not in the sense of the C++ definition - although it should be, for
<br>things like flatMap).
<br></blockquote>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
To unsubscribe from this group, send email to std-proposals+unsubscribe@iso=
cpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_67_14748196.1359367315941--

.
