Topic: Explicitly overload ternary operator return type only


Author: "Ivan G." <nekotekina@gmail.com>
Date: Wed, 23 Nov 2016 15:18:06 -0800 (PST)
Raw View
------=_Part_5508_1829031218.1479943086100
Content-Type: multipart/alternative;
 boundary="----=_Part_5509_1674985697.1479943086100"

------=_Part_5509_1674985697.1479943086100
Content-Type: text/plain; charset=UTF-8

How about the following syntax (function body not allowed, only
default/delete special syntax, in namespace scope):

inline type operator?:(const bar_t&, const foo_t&) = default;
template <typename T> void operator?:(const foo_t&, const T&) = delete; //
Forbid

This would not effectively overload ternary operator but only specify its
return type or forbid some undesirable cases.
The motivation is, for example, to specify common base class or make some
custom arithmetic types work seamlessly with ternary operator.
Sorry if there are similar or completely better proposals.

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/10c4f953-040b-4e33-bf26-724db5381036%40isocpp.org.

------=_Part_5509_1674985697.1479943086100
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>How about the following syntax (function body not all=
owed, only default/delete special syntax, in namespace scope):<br></div><di=
v><br></div><div><div style=3D"background-color: #FAFAFA; border-color: #BB=
B; border-style: solid; border-width: 1px; word-wrap: break-word;" class=3D=
"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint"><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">inline</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> type </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">?:(</span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> bar_t</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&amp;,</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">const</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> foo_t</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">&amp;)</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">default</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"styled-by-prettify">template</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">typename</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">void<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">?:(</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> foo_t</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&amp;,</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">const</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">&amp;)</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">delete</span><sp=
an 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">// Forbid </span></div></code></div><=
br>This would not effectively overload ternary operator but only specify it=
s return type or forbid some undesirable cases.</div><div>The motivation is=
, for example, to specify common base class or make some custom arithmetic =
types work seamlessly with ternary operator.</div><div>Sorry if there are s=
imilar or completely better proposals.</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/10c4f953-040b-4e33-bf26-724db5381036%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/10c4f953-040b-4e33-bf26-724db5381036=
%40isocpp.org</a>.<br />

------=_Part_5509_1674985697.1479943086100--

------=_Part_5508_1829031218.1479943086100--

.