220 18899 <5c654bc3-5294-4f8a-bf1a-bf4a9f6c8603@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Igor Baidiuk <target.san@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Unified coercion protocol: static_cast explicit overload
Date: Wed, 1 Jul 2015 04:17:51 -0700 (PDT)
Lines: 105
Approved: news@gmane.org
Message-ID: <5c654bc3-5294-4f8a-bf1a-bf4a9f6c8603@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1852_1279424045.1435749471762"
X-Trace: ger.gmane.org 1435749475 29601 80.91.229.3 (1 Jul 2015 11:17:55 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 1 Jul 2015 11:17:55 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDK4F76SSIIBBYEYZ6WAKGQE7PYJTHA@isocpp.org Wed Jul 01 13:17:55 2015
Return-path: <std-proposals+bncBDK4F76SSIIBBYEYZ6WAKGQE7PYJTHA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ob0-f197.google.com ([209.85.214.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDK4F76SSIIBBYEYZ6WAKGQE7PYJTHA@isocpp.org>)
	id 1ZAG1a-0000Na-IV
	for gclcip-std-proposals@m.gmane.org; Wed, 01 Jul 2015 13:17:54 +0200
Original-Received: by obbtu2 with SMTP id tu2sf61834533obb.1
        for <gclcip-std-proposals@m.gmane.org>; Wed, 01 Jul 2015 04:17:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:subject:mime-version:content-type
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=AZEGwtpeEZEQsYb0lWUOjDPhyUmdurMIcqg4yHmr9pU=;
        b=HbOTIe/ngG45tyhkFLn7iGx7vfrLxF8c+dtt6hM/jb5wn74IS2MsaWZnlqlMF16/gU
         jfpo/tfCOmZaS7A6r9foGxYS65mfnyrbDKnguqgMB9IbNGrrivqm1rz77wHEsY70g2zu
         zuUG+yfEdimONKtWoVxjFDCajnes4ze70ciYY5X8NxSutgx5KW5Fk8tPl4fbue7PSNn8
         qEJiRwZFtnHdUEcT5C4Xpr8aRiix8OvN5ZWYU7IUicZ41Zo+RDrf/hai/OTp60e/4p3l
         iG+Ei8HHO6e0b1XxCJpNcduAXy4hbM0yK3OBlHr81A9WpZDuCDP2HuO8c3CV7pbjFbOL
         k9SA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:subject:mime-version
         :content-type:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=AZEGwtpeEZEQsYb0lWUOjDPhyUmdurMIcqg4yHmr9pU=;
        b=OKnmX3O2XfBWsQ1ev+4zufMJ2PJ7JIy1H2/l+k3oT1G4PTL0Li+76+1vcjEvELXoPV
         1YNUmD0ZFOYRCVUUhihOBiMoxpjERPoaihpLBxkjlMWfBMOkPN6/OJXofY+dLKili/Gs
         VFFP63w7iTaOn3gIoQbV21GBNtOyCm0vVcCG92IyIQykjRA/ZfqjZ4q1Vg0lsLkgTrni
         B8uZynZ+ome7Os6t9v5WpAHcyzbQW3kRmOKzqHq1ZPyqLfVjgMZ68BpROyH/f7w1FWHF
         ARcF/g5kpoSsjjQJgnpzddrL+uzNNt8j+2Ju1VbUUC7iy6Q17a5k1cSLC+1PsOMxIq2J
         IpiA==
X-Gm-Message-State: ALoCoQl4KRYMqy3vpDD6cV5RzwHgmceZRoWDcI1h8WvNo3yjnVx4X9nU4j4usNV8kYOVhwEmeOjT
X-Received: by 10.182.213.4 with SMTP id no4mr33803375obc.21.1435749473537;
        Wed, 01 Jul 2015 04:17:53 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.31.227 with SMTP id f90ls731059qgf.9.gmail; Wed, 01 Jul
 2015 04:17:52 -0700 (PDT)
X-Received: by 10.140.105.10 with SMTP id b10mr310652qgf.26.1435749472328;
        Wed, 01 Jul 2015 04:17:52 -0700 (PDT)
X-Original-Sender: target.san@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: 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:18899
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/18899>

------=_Part_1852_1279424045.1435749471762
Content-Type: multipart/alternative; 
	boundary="----=_Part_1853_526166904.1435749471762"

------=_Part_1853_526166904.1435749471762
Content-Type: text/plain; charset=UTF-8

What if we could define
operator static_cast<To>(From const& from)
{
    return { from.a, from.b};
}
// later in code
From from;
auto to = static_cast<To>(from);
as means of non-member, explicit conversion syntax?
So we don't need to write tons of functions like toFoo, toBar, toBaz etc.
Or, allow declaring non-member conversion operators, which are explicit by 
default?

-- 

--- 
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 email 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-proposals/.

------=_Part_1853_526166904.1435749471762
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">What if we could define<br><div class=3D"prettyprint" styl=
e=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187)=
; border-style: solid; border-width: 1px; word-wrap: break-word;"><code cla=
ss=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008=
;" class=3D"styled-by-prettify">operator</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">static_cast</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;</span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">To</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">&gt;(</span><span style=3D"color: #606;" class=3D"styled-by-prett=
ify">From</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">const</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">from</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">return</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">from</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">a</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-by-prettify">from</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">b</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span><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: #800;" class=3D"styled-by-prettify">// later in code</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #606;" class=3D"styled-by-prettify">From</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">from</span><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: #008;" class=3D"st=
yled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> to </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">static_cas=
t</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</spa=
n><span style=3D"color: #606;" class=3D"styled-by-prettify">To</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">&gt;(</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">from</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span></div></code></div>as means of =
non-member, explicit conversion syntax?<br>So we don't need to write tons o=
f functions like toFoo, toBar, toBaz etc.<br>Or, allow declaring non-member=
 conversion operators, which are explicit by default?<br></div>

<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 />

------=_Part_1853_526166904.1435749471762--
------=_Part_1852_1279424045.1435749471762--

.
