220 7039 <f966afd6-75e5-4970-9d0f-0f8ffac5efe1@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:05:42 -0700 (PDT)
Lines: 154
Approved: news@gmane.org
Message-ID: <f966afd6-75e5-4970-9d0f-0f8ffac5efe1@isocpp.org>
References: <417ebcd9-ff0b-49d8-b055-bd098e97dddc@isocpp.org>
 <CAFk2RUbh7yMESeYFRFr+OiEz4FK_EPv+4dUSzA3UDWQbyz+hQw@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_261_11738981.1380999942602"
X-Trace: ger.gmane.org 1380999942 13314 80.91.229.3 (5 Oct 2013 19:05:42 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 5 Oct 2013 19:05:42 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDT2DGOJ34DBBB6GYGJAKGQE2KGB65I@isocpp.org Sat Oct 05 21:05:45 2013
Return-path: <std-proposals+bncBDT2DGOJ34DBBB6GYGJAKGQE2KGB65I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qa0-f70.google.com ([209.85.216.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDT2DGOJ34DBBB6GYGJAKGQE2KGB65I@isocpp.org>)
	id 1VSXAe-0004EM-Oe
	for gclcip-std-proposals@m.gmane.org; Sat, 05 Oct 2013 21:05:45 +0200
Original-Received: by mail-qa0-f70.google.com with SMTP id i13sf5559475qae.5
        for <gclcip-std-proposals@m.gmane.org>; Sat, 05 Oct 2013 12:05:43 -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=zU43tK9kIJ5iQR/ufh/P0kPgiGH3kcWJmezGBRTx4nw=;
        b=p6OFmNrxdMTkoCPhke/e+FzLXKoq7WmxbFHvn7XJxluhPB9h+9kJSAhf/fuaKH+pEj
         OI40In4v0SA+Dt6DXY7CADPtbQ3AGNnJ9rMJ3KgHj/8wwAAVBOTobsTnZZBQVR9yeV4w
         Yyax45ccb+KHhfm+nA9eyc+jhf47yQ5hblK+cN+Kl72rOefTRvQAD3yC7XxnNH4GAfcu
         /huy008fl4Ln+TfjRIPfSyyMZA0M+g7wKRS7vrcfc9RgY22GH0efDkI7d4HCFgsuK5Oq
         hYuZo9sGEsJtOSr77bPlqXjaqtDGlYnMcDzHWfmCvUVZzzVX3d4lJWIQ/p8jVtDagtSF
         pNEQ==
X-Received: by 10.236.227.165 with SMTP id d35mr17744194yhq.51.1380999943636;
        Sat, 05 Oct 2013 12:05:43 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.12.103 with SMTP id x7ls704239qeb.14.gmail; Sat, 05 Oct
 2013 12:05:43 -0700 (PDT)
X-Received: by 10.49.75.168 with SMTP id d8mr836933qew.3.1380999943160;
        Sat, 05 Oct 2013 12:05:43 -0700 (PDT)
In-Reply-To: <CAFk2RUbh7yMESeYFRFr+OiEz4FK_EPv+4dUSzA3UDWQbyz+hQw@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:7039
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/7039>

------=_Part_261_11738981.1380999942602
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable



W dniu sobota, 5 pa=BCdziernika 2013 19:33:01 UTC+2 u=BFytkownik Ville=20
Voutilainen napisa=B3:
>
>
> On 5 October 2013 20:14, Andrzej Krzemie=F1ski <akrz...@gmail.com<javascr=
ipt:>
> > wrote:
>
>>
>> (because this would turn an explicit conversion into an implicit one).=
=20
>> Such "conditionally explicit" converting constructor is doable, but I ru=
n=20
>> on another problem. The additional constructors would look like:
>>
>> *  template <class U>
>> *
>> *  optional::optional(U&& u);
>>
>> *
>> *  template <class U>
>> *
>> *  optional::optional(optional<U> const& ou);*
>>
>> Suppose you have the following class:
>>
>>  * struct Port
>>   {
>> *
>> *    Port (optional<int> oi);
>>   }; =20
>> *
>> *
>> *
>> *  optional<int> oi;
>> *
>> *  optional<Port> op =3D oi;*
>>
>> which of the two constructors would the user expect to be called? I gues=
s=20
>> the former, but he would be surprised. I do not know how to solve this=
=20
>> problem. Perhaps someone on the list does.
>>
>>
> Depends on the user. Advanced users will know that the universal-referenc=
e=20
> ctor is a better
> match since there's no const involved. Perhaps you could SFINAE it out in=
=20
> case the incoming
> type is optional<U>?=20
>

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?



--=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_261_11738981.1380999942602
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 19:33:01 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><div class=3D"gmail_quote">On 5 Octo=
ber 2013 20:14, Andrzej Krzemie=F1ski <span dir=3D"ltr">&lt;<a href=3D"java=
script:" target=3D"_blank" gdf-obfuscated-mailto=3D"cWZrB0ywbIUJ">akrz...@g=
mail.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"><div><div><div><br></div>(b=
ecause
 this would turn an explicit conversion into an implicit one). Such=20
"conditionally explicit" converting constructor is doable, but I run on=20
another problem. The additional constructors would look like:<br><br></div>=
<div><b>&nbsp; template &lt;class U&gt;<br></b></div><div><b>&nbsp; optiona=
l::optional(U&amp;&amp; u);<br><br></b></div><div><b>&nbsp; template &lt;cl=
ass U&gt;<br>
</b></div><div><b>&nbsp; optional::optional(optional&lt;U&gt; const&amp; ou=
);</b><br></div><div><br></div><div>Suppose you have the following class:<b=
r><br></div><div>&nbsp;<b> struct Port<br>&nbsp; {<br></b></div><div><b>&nb=
sp;&nbsp;&nbsp; Port (optional&lt;int&gt; oi);<br>
&nbsp; };&nbsp; <br></b></div><div><b><br></b></div><div><b>&nbsp; optional=
&lt;int&gt; oi;<br></b></div><b>&nbsp; optional&lt;Port&gt; op =3D oi;</b><=
br><br></div>which
 of the two constructors would the user expect to be called? I guess the
 former, but he would be surprised. I do not know how to solve this=20
problem. Perhaps someone on the list does.<br><br></div></blockquote><div><=
br></div><div>Depends on the user. Advanced users will know that the univer=
sal-reference ctor is a better<br>match since there's no const involved. Pe=
rhaps you could SFINAE it out in case the incoming<br>
</div><div>type is optional&lt;U&gt;? <br></div></div></div></div></blockqu=
ote><div><br>Oh, you spotted a different problem than I did. Mine was that =
(even if I fixed yours) it is not clear how to handle a case where <b>T</b>=
 has a constructor taking another optional. Consider a more tricky type:<br=
><br><b>&nbsp; struct Port<br>&nbsp; {<br></b><div><b>&nbsp;&nbsp;&nbsp; Po=
rt (optional&lt;int&gt; oi);<br>&nbsp;&nbsp;&nbsp; Port (int);<br>
&nbsp; }; <br></b></div><br>And now the code that uses it:<br><br><b>&nbsp;=
 optional&lt;int&gt; oi;<br></b><b>&nbsp; optional&lt;Port&gt; op =3D oi;</=
b><br><br>Now, forget how optional is or might be implemented. As a user, w=
hich constructor of <b>Port </b>would you expect to be called?<br><br><br><=
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_261_11738981.1380999942602--

.
