220 7042 <04a0eaa5-ab73-4f0d-99ca-bf0802da73a9@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: More converting constructors for Optional
Date: Sat, 5 Oct 2013 12:38:50 -0700 (PDT)
Lines: 120
Approved: news@gmane.org
Message-ID: <04a0eaa5-ab73-4f0d-99ca-bf0802da73a9@isocpp.org>
References: <417ebcd9-ff0b-49d8-b055-bd098e97dddc@isocpp.org>
 <CAFk2RUbh7yMESeYFRFr+OiEz4FK_EPv+4dUSzA3UDWQbyz+hQw@mail.gmail.com>
 <f966afd6-75e5-4970-9d0f-0f8ffac5efe1@isocpp.org>
 <CAFk2RUbH_uvpq1JBJ6NX3QenwTCH1LXb0DvKHUQO3N3BM97nVA@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_1164_632210.1381001930658"
X-Trace: ger.gmane.org 1381001929 314 80.91.229.3 (5 Oct 2013 19:38:49 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 5 Oct 2013 19:38:49 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDT2DGOJ34DBBS6VYGJAKGQEHTKZ7SY@isocpp.org Sat Oct 05 21:38:53 2013
Return-path: <std-proposals+bncBDT2DGOJ34DBBS6VYGJAKGQEHTKZ7SY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qc0-f200.google.com ([209.85.216.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDT2DGOJ34DBBS6VYGJAKGQEHTKZ7SY@isocpp.org>)
	id 1VSXgi-00072b-OD
	for gclcip-std-proposals@m.gmane.org; Sat, 05 Oct 2013 21:38:53 +0200
Original-Received: by mail-qc0-f200.google.com with SMTP id x20sf10390565qcv.11
        for <gclcip-std-proposals@m.gmane.org>; Sat, 05 Oct 2013 12:38:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=DmbD/qSkOZQdU+lZz1cj+TSxUFh/GHyPyB+pQJk3iTs=;
        b=ZoLlQ+vySl802zjjd6+q1DIv3lQVl8pA9021EqiAsF/snhnrGJ1KV4ZiP8T9HCv/ZK
         sLc6aqJMT4oiShcZcfKvdYr9IoAQO7G6OtGhqzgL+SraTq2GOY+mjCBxft/lnLSxKtsU
         w8NW3IxIQ9BY6w5dktYDds1FMxsK4pqQCcqxLNd88/xCChmLTVRfmC3LhGSxQByc/BUU
         tl61cQoyF3zZFnf0AoTr/ne3whVFl2yTj6O2/42ytyYq9UgTB4t/fGrcroAvlGM6PGPA
         0IoCpami3sGbduLw/hqYufUUTMzNzxugZWUuR1kOuZhC+W/GV2FRntZyAdbInPn2rxNj
         2lWQ==
X-Received: by 10.236.142.38 with SMTP id h26mr29133yhj.57.1381001931801;
        Sat, 05 Oct 2013 12:38:51 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.99.10 with SMTP id em10ls1864498qeb.82.gmail; Sat, 05 Oct
 2013 12:38:51 -0700 (PDT)
X-Received: by 10.49.48.38 with SMTP id i6mr804342qen.4.1381001931112;
        Sat, 05 Oct 2013 12:38:51 -0700 (PDT)
In-Reply-To: <CAFk2RUbH_uvpq1JBJ6NX3QenwTCH1LXb0DvKHUQO3N3BM97nVA@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>, <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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:7042
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/7042>

------=_Part_1164_632210.1381001930658
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable



W dniu sobota, 5 pa=BCdziernika 2013 21:30:10 UTC+2 u=BFytkownik Ville=20
Voutilainen napisa=B3:
>
>
>
>
> On 5 October 2013 22:05, Andrzej Krzemie=F1ski <akrz...@gmail.com<javascr=
ipt:>
> > wrote:
>
>>
>> Oh, you spotted a different problem than I did. Mine was that (even if I=
=20
>> fixed yours) it is not clear how to handle a case where *T* has a=20
>> constructor taking another optional. Consider a more tricky type:
>>
>> *  struct Port
>>   {
>> *
>> *    Port (optional<int> oi);
>>     Port (int);
>>   };=20
>> *
>>
>> And now the code that uses it:
>>
>>
>> *  optional<int> oi;
>> **  optional<Port> op =3D oi;*
>>
>> Now, forget how optional is or might be implemented. As a user, which=20
>> constructor of *Port *would you expect to be called?
>>
>>
> The one taking optional<int>, since optional doesn't automatically conver=
t=20
> to an int. If you
> have
> int i;
> optional<Port> op =3D i;
> then I expect Port(int) to be used.
>

Another (valid) expectation would be that constructor:=20

*  template <class U> optional<T>::optional( optional<U> const& o );*

does:

*  if (o) { *(*this) =3D *o; }*

in which case *Port(int)* would be used.
=20

--=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/.

------=_Part_1164_632210.1381001930658
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>W dniu sobota, 5 pa=BCdziernika 2013 21:30:10 UTC+=
2 u=BFytkownik Ville Voutilainen napisa=B3:<blockquote class=3D"gmail_quote=
" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding=
-left: 1ex;"><div dir=3D"ltr"><br><div><br><br><div class=3D"gmail_quote">O=
n 5 October 2013 22:05, Andrzej Krzemie=F1ski <span dir=3D"ltr">&lt;<a href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"M5YxrHarD3MJ">a=
krz...@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><div>Oh, you spotted a =
different problem than I did. Mine was that (even if I fixed yours) it is n=
ot clear how to handle a case where <b>T</b> has a constructor taking anoth=
er optional. Consider a more tricky type:<br>
<br><b>&nbsp; struct Port<br>&nbsp; {<br></b><div><b>&nbsp;&nbsp;&nbsp; Por=
t (optional&lt;int&gt; oi);<br>&nbsp;&nbsp;&nbsp; Port (int);<br>
&nbsp; }; <br></b></div><br>And now the code that uses it:<div><br><br><b>&=
nbsp; optional&lt;int&gt; oi;<br></b><b>&nbsp; optional&lt;Port&gt; op =3D =
oi;</b><br><br></div>Now, forget how optional is or might be implemented. A=
s a user, which constructor of <b>Port </b>would you expect to be called?<b=
r>
<br></div></div></blockquote><div><br></div><div>The one taking optional&lt=
;int&gt;, since optional doesn't automatically convert to an int. If you<br=
></div><div>have<br></div><div>int i;<br>optional&lt;Port&gt; op =3D i;<br>
</div><div>then I expect Port(int) to be used.<br></div></div></div></div><=
/blockquote><div><br>Another (valid) expectation would be that constructor:=
 <br><br><b>&nbsp; template &lt;class U&gt; optional&lt;T&gt;::optional( op=
tional&lt;U&gt; const&amp; o );</b><br><br>does:<br><br><b>&nbsp; if (o) { =
*(*this) =3D *o; }</b><br><br>in which case <b>Port(int)</b> would be used.=
<br>&nbsp;<br></div></div>

<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 unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />

------=_Part_1164_632210.1381001930658--

.
