Topic: meta members: a 0+ cost properties & dot operator


Author: bastienpenava@gmail.com
Date: Sat, 27 Jan 2018 21:26:25 -0800 (PST)
Raw View
------=_Part_6987_1551178034.1517117185589
Content-Type: multipart/alternative;
 boundary="----=_Part_6988_1837822128.1517117185590"

------=_Part_6988_1837822128.1517117185590
Content-Type: text/plain; charset="UTF-8"

Hi,

So I was toying with the idea of named tuple when I remembered D's name
resolution operator
<https://dlang.org/spec/operatoroverloading.html#dispatch> and check if it
was possible to implement in C++.
For those not familiar to the idea it's manly an operator that receives the
unknown member access as a template non-type parameter instead of causing
an error.
To my surprise it is an is quite cheap to implement (50 lines for GCC) and
could quite powerful (particularly if combined with reflection).
To avoid creating a new operator i'm using the operator* with a template
non-type reference parameter as the 'new' operator :* template<auto&
memberName> auto operator*();*
One of the motivations to use this operator is because it allows
out-of-class definitions.
You can try and check some exemple here if you wish :
http://dispatch.gcc-future.tk/#

The reason why I bring this up is that I believe that It could solve a
bunch of demands that have been unsuccessful in the past (generally due to
their coast being to great compared to the supposed benefit. ie: new
operator, keyword, syntax, etc...).
Mainly the dot operator, properties, out of class method definition and UCS.

Here are a few examples.

logging class with reflection:
template<class T>
struct logger
{
    T _value;

    template<auto &Str>
    requires reflexpr(T).has_member_of_method(Str) //not actual syntax for
the reflection proposal.
    decltype(auto) operator*()
    {
      if constexpr (reflexpr(T).is_method(Str))
        return [&_value]<class... Args>(Args&&... args) -> decltype(auto)
          {
            scope_exit _out = []{ std::cout << "[out " << &_value << "]: "
<< Str << std::endl; };
            std::cout << "[in " << &_value << "]: " << Str;
            return reflexpr(_value).get_methods_by_name<Str>().call(std::
forward<Args>(args)...);
          };
      else
      {
        std::cout << "[using " << &_value << "]: " << Str << std::endl;
        return reflexpr(_value).get_member_by_name<Str>();
      }
    }
};

properties, simulate inheritance, multiple names:
struct A
{
   std::string x;

    template<auto &Str>
    requires (is_one_of<Str, "size", "length", "Size", "Length">)
    size_t operator*() { return x.size(); }
};

A tmp;
//tmp.size, tmp.length,tmp.Size and tmpl.Length usable.

standard layout, pod:
struct complex
{
   double alpha;
   double length;
};

template<auto &Str>
requires (is_one_of<Str, "real", "img">)
auto operator*(complex self) {
   if constexpr (is_same_ref_v<Str, "real">) return std::cos(self.alpha) *
self.length;
   else return std::sin(self.alpha) * self.length;
}

//complex remains standard layout/pod but has fake members 'real' and 'img'

Out of class method definition / templated this / UCS:
template<auto &Str, class T>
requires (is_same_ref_v<Str, "println">)
void operator*(T&& x)
{
   return [&x]{ std::cout << x << std::endl; };
}

std::string x:
x.println();


--
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/11f9c7ff-aa76-46a5-94b2-0692171ab0ff%40isocpp.org.

------=_Part_6988_1837822128.1517117185590
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,<div><br></div><div>So I was toying with the idea of na=
med tuple when I remembered <a href=3D"https://dlang.org/spec/operatoroverl=
oading.html#dispatch">D&#39;s name resolution operator</a>=C2=A0and check i=
f it was possible to implement in C++.</div><div>For those not familiar to =
the idea it&#39;s manly an operator that receives the unknown member access=
 as a template non-type parameter instead of causing an error.</div><div>To=
 my surprise it is an is quite cheap to implement (50 lines for GCC) and co=
uld quite powerful (particularly if combined with reflection).</div><div>To=
 avoid creating a new operator i&#39;m using the operator* with a template =
non-type reference parameter as the &#39;new&#39; operator :<b> template&lt=
;auto&amp; memberName&gt; auto operator*();</b></div><div>One of the motiva=
tions to use this operator is because it allows out-of-class definitions.</=
div><div>You can try and check some exemple here if you wish :=C2=A0<a href=
=3D"http://dispatch.gcc-future.tk/#">http://dispatch.gcc-future.tk/#</a><br=
></div><div><br></div><div>The reason why I bring this up is that I believe=
 that It could solve a bunch of demands that have been unsuccessful in the =
past (generally due to their coast being to great compared to the supposed =
benefit. ie: new operator, keyword, syntax, etc...).</div><div>Mainly the d=
ot operator, properties, out of class method definition and UCS.</div><div>=
<br></div><div>Here are a few examples.</div><div><br></div><div>logging cl=
ass with reflection:</div><div class=3D"prettyprint" style=3D"background-co=
lor: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: so=
lid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"=
><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled=
-by-prettify">template</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">class</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> logger<br></span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 T _value</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">template</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</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"> </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #=
606;" class=3D"styled-by-prettify">Str</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 requires reflexpr</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">T</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">).</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">has_member_of_method</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(</span><span style=3D"color: #606;" clas=
s=3D"styled-by-prettify">Str</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">=
//not actual syntax for the reflection proposal.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">decltype</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">auto</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"style=
d-by-prettify">operator</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">*()</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">if</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">constexpr</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">reflexpr</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">).</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">is_method</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">(</span><span style=3D"color: #606;" class=3D=
"styled-by-prettify">Str</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">))</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">[&amp;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">_value</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">]&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">class</span><span style=3D"color: #660;" class=3D"styled-by-prettify">...=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #606;" class=3D"styled-by-prettify">Args</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&gt;(</span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Args</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">&amp;&amp;...</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> args</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">-&gt;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">decltype</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 scope_exit _out </span><spa=
n 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=
: #660;" class=3D"styled-by-prettify">[]{</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">cout </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify"=
>&quot;[out &quot;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">_value </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #080;" class=3D"styled-by-prettify">&quot;]: &quot;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" =
class=3D"styled-by-prettify">Str</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">e=
ndl</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 std</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">c=
out </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&l=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #080;" class=3D"styled-by-prettify">&quot;[in &quot;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&amp;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">_value </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" clas=
s=3D"styled-by-prettify">&quot;]: &quot;</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">Str</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> reflexpr</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><font color=3D"#000000"><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">_value</span></font><span style=
=3D"color: #660;" class=3D"styled-by-prettify">).</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">get_methods_by_name</span><font colo=
r=3D"#666600"><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt=
;</span></font><span style=3D"color: #606;" class=3D"styled-by-prettify">St=
r</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;().</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">call</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">forward</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">Args</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&gt;(</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">args</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">)...);</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">else</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 std<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">cout </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #080;" class=3D"styled-by-prettify">&quot;[using &quot;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">_value </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-=
prettify">&quot;]: &quot;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Str</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">endl</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> reflexpr</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">_value</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">).</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">get_member_by_name</span><font color=3D"#666600"><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span></font><fon=
t color=3D"#666600"><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">Str</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;=
();</span></font><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}=
;</span></div></code></div><div><br></div><div>properties, simulate inherit=
ance, multiple names:<br></div><div class=3D"prettyprint" style=3D"backgrou=
nd-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-styl=
e: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyp=
rint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">struct</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> A<br></span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br>=C2=A0 =C2=A0std</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">::</span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">string</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"styled-by-prettify"><br><br>=C2=A0 =
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">tem=
plate</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;<=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><span style=3D=
"color: #606;" class=3D"styled-by-prettify">Str</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 requires </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">is_one_of</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #606=
;" class=3D"styled-by-prettify">Str</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-pre=
ttify">&quot;size&quot;</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&quot=
;length&quot;</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: #080;" class=3D"styled-by-prettify">&quot;Size&quot=
;</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: #080;" class=3D"styled-by-prettify">&quot;Length&quot;</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">&gt;)</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 size_t=
 </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"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> x</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">size</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </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"colo=
r: #000;" class=3D"styled-by-prettify"><br><br>A tmp</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></span><span style=3D"color: #800;" cl=
ass=3D"styled-by-prettify">//tmp.size, tmp.length,tmp.Size and tmpl.Length =
usable.</span></div></code></div><div><br></div><div>standard layout, pod:<=
/div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 25=
0); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1p=
x; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpre=
ttyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">struct<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> complex<br=
></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0<=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">double</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> alpha</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0</span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">double</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> length</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: #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">template</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;</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"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&amp;</span><span style=3D"color: #606;" class=3D"styled-by-prettify">St=
r</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>requires </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">is_one_of</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Str</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: #080;" class=
=3D"styled-by-prettify">&quot;real&quot;</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: #080;" class=3D"styled-b=
y-prettify">&quot;img&quot;</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&gt;)</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">auto</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">operator<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">*(</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">complex </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">self</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">)</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"><br>=C2=A0 =C2=A0</span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">if</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">constexpr</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">is_same_=
ref_v</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;<=
/span><span style=3D"color: #606;" class=3D"styled-by-prettify">Str</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #080;" class=3D"styled-by-prettify">&quot;real&quot;</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&gt;)</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">cos</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
self</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">alpha</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=
: #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">self</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">length</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
else</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </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"> std</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">sin</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">self</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">alpha</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">self</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">length</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br><br></span><span style=3D"color: #800;" class=3D"styled-by-prettify=
">//complex remains standard layout/pod but has fake members &#39;real&#39;=
 and &#39;img&#39;</span></div></code></div><div><br></div><div>Out of clas=
s method definition / templated this / UCS:</div><div class=3D"prettyprint"=
 style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187,=
 187); border-style: solid; border-width: 1px; word-wrap: break-word;"><cod=
e class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color:=
 #008;" class=3D"styled-by-prettify">template</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&amp;</span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">Str</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: #008;" class=3D"styled-by-prettify">class</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>requires </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">is_same_ref_v</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #606=
;" class=3D"styled-by-prettify">Str</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-pre=
ttify">&quot;println&quot;</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&gt;)</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">void</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">operator</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">*(</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&amp;&amp;</span><span style=
=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"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0</span><span style=3D"color: #008;" class=
=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-by=
-prettify">[&amp;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">x</span><span style=3D"color: #660;" class=3D"styled-by-prettify">]{=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">cout </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> x </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">endl</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>std</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">string</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;" cla=
ss=3D"styled-by-prettify"><br>x</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">println</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br></span></div></code></div><div><br></div><div><br></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/11f9c7ff-aa76-46a5-94b2-0692171ab0ff%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/11f9c7ff-aa76-46a5-94b2-0692171ab0ff=
%40isocpp.org</a>.<br />

------=_Part_6988_1837822128.1517117185590--

------=_Part_6987_1551178034.1517117185589--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sun, 28 Jan 2018 07:29:56 -0800 (PST)
Raw View
------=_Part_8569_522868792.1517153396815
Content-Type: multipart/alternative;
 boundary="----=_Part_8570_549408834.1517153396815"

------=_Part_8570_549408834.1517153396815
Content-Type: text/plain; charset="UTF-8"

On Sunday, January 28, 2018 at 12:26:25 AM UTC-5, bastie...@gmail.com wrote:
>
> Hi,
>
> So I was toying with the idea of named tuple when I remembered D's name
> resolution operator
> <https://dlang.org/spec/operatoroverloading.html#dispatch> and check if
> it was possible to implement in C++.
> For those not familiar to the idea it's manly an operator that receives
> the unknown member access as a template non-type parameter instead of
> causing an error.
> To my surprise it is an is quite cheap to implement (50 lines for GCC) and
> could quite powerful (particularly if combined with reflection).
> To avoid creating a new operator i'm using the operator* with a template
> non-type reference parameter as the 'new' operator :* template<auto&
> memberName> auto operator*();*
> One of the motivations to use this operator is because it allows
> out-of-class definitions.
> You can try and check some exemple here if you wish :
> http://dispatch.gcc-future.tk/#
>
> The reason why I bring this up is that I believe that It could solve a
> bunch of demands that have been unsuccessful in the past (generally due to
> their coast being to great compared to the supposed benefit. ie: new
> operator, keyword, syntax, etc...).
> Mainly the dot operator, properties, out of class method definition and
> UCS.
>
> Here are a few examples.
>
> logging class with reflection:
>

This doesn't work on constructors/destructors. Or operators, unless the
caller spelled out the operator name (maybe?).

properties, simulate inheritance, multiple names:
>

I've seen a* lot* of syntaxes proposed for properties, but that is perhaps
the worst. The fact that you have to declare all of the properties inside
of a single function makes this a hideous beast if your class has a
significant number of properties.

standard layout, pod:
>

std::complex doesn't need help being standard layout. It's already required
to be standard layout, and with a very specific layout. Nobody is stopping
you from having `real` and `img` member functions with that layout.

Out of class method definition / templated this / UCS:
>

We definitely do not want people to be able to inject methods into
arbitrary classes like this. Besides, how would you find this operator? ADL
is how out-of-member operators are normally found.

--
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/437c4139-06b9-4751-aa2f-dea9563266dd%40isocpp.org.

------=_Part_8570_549408834.1517153396815
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Sunday, January 28, 2018 at 12:26:25 AM UTC-5, bastie..=
..@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"=
ltr">Hi,<div><br></div><div>So I was toying with the idea of named tuple wh=
en I remembered <a onmousedown=3D"this.href=3D&#39;https://www.google.com/u=
rl?q\x3dhttps%3A%2F%2Fdlang.org%2Fspec%2Foperatoroverloading.html%23dispatc=
h\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzNFt_luOJfQw2_XmtkXz5O2qiiQ&#39;=
;return true;" onclick=3D"this.href=3D&#39;https://www.google.com/url?q\x3d=
https%3A%2F%2Fdlang.org%2Fspec%2Foperatoroverloading.html%23dispatch\x26sa\=
x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzNFt_luOJfQw2_XmtkXz5O2qiiQ&#39;;return =
true;" href=3D"https://dlang.org/spec/operatoroverloading.html#dispatch" ta=
rget=3D"_blank" rel=3D"nofollow">D&#39;s name resolution operator</a>=C2=A0=
and check if it was possible to implement in C++.</div><div>For those not f=
amiliar to the idea it&#39;s manly an operator that receives the unknown me=
mber access as a template non-type parameter instead of causing an error.</=
div><div>To my surprise it is an is quite cheap to implement (50 lines for =
GCC) and could quite powerful (particularly if combined with reflection).</=
div><div>To avoid creating a new operator i&#39;m using the operator* with =
a template non-type reference parameter as the &#39;new&#39; operator :<b> =
template&lt;auto&amp; memberName&gt; auto operator*();</b></div><div>One of=
 the motivations to use this operator is because it allows out-of-class def=
initions.</div><div>You can try and check some exemple here if you wish :=
=C2=A0<a onmousedown=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhtt=
p%3A%2F%2Fdispatch.gcc-future.tk%2F%23\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNE4UjYjHib_e_JiYSPeRbOqP_cF4g&#39;;return true;" onclick=3D"this.href=3D=
&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdispatch.gcc-future.tk%2F%=
23\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE4UjYjHib_e_JiYSPeRbOqP_cF4g&#39=
;;return true;" href=3D"http://dispatch.gcc-future.tk/#" target=3D"_blank" =
rel=3D"nofollow">http://dispatch.gcc-future.<wbr>tk/#</a><br></div><div><br=
></div><div>The reason why I bring this up is that I believe that It could =
solve a bunch of demands that have been unsuccessful in the past (generally=
 due to their coast being to great compared to the supposed benefit. ie: ne=
w operator, keyword, syntax, etc...).</div><div>Mainly the dot operator, pr=
operties, out of class method definition and UCS.</div><div><br></div><div>=
Here are a few examples.</div><div><br></div><div>logging class with reflec=
tion:</div></div></blockquote><div><br></div><div>This doesn&#39;t work on =
constructors/destructors. Or operators, unless the caller spelled out the o=
perator name (maybe?).</div><div><br></div><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"><div>properties, simulate inheritance, multip=
le names:<br></div></div></blockquote><div><br></div><div>I&#39;ve seen a<i=
> lot</i> of syntaxes proposed for properties, but that is perhaps the wors=
t. The fact that you have to declare all of the properties inside of a sing=
le function makes this a hideous beast if your class has a significant numb=
er of properties.</div><div><br></div><blockquote class=3D"gmail_quote" sty=
le=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left=
: 1ex;"><div dir=3D"ltr"><div>standard layout, pod:</div></div></blockquote=
><div><br></div><div>std::complex doesn&#39;t need help being standard layo=
ut. It&#39;s already required to be standard layout, and with a very specif=
ic layout. Nobody is stopping you from having `real` and `img` member funct=
ions with that layout.</div><div><font style=3D"background-color: rgb(250, =
250, 250);"></font><br></div><blockquote class=3D"gmail_quote" style=3D"mar=
gin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><=
div dir=3D"ltr"><div>Out of class method definition / templated this / UCS:=
</div></div></blockquote><div><br></div><div>We definitely do not want peop=
le to be able to inject methods into arbitrary classes like this. Besides, =
how would you find this operator? ADL is how out-of-member operators are no=
rmally found.</div><div><br></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/437c4139-06b9-4751-aa2f-dea9563266dd%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/437c4139-06b9-4751-aa2f-dea9563266dd=
%40isocpp.org</a>.<br />

------=_Part_8570_549408834.1517153396815--

------=_Part_8569_522868792.1517153396815--

.


Author: Bastien penavayre <bastienpenava@gmail.com>
Date: Sun, 28 Jan 2018 19:15:45 +0100
Raw View
--f403045d5aec4921080563da1ef6
Content-Type: text/plain; charset="UTF-8"

2018-01-28 16:29 GMT+01:00 Nicol Bolas <jmckesson@gmail.com>:

> On Sunday, January 28, 2018 at 12:26:25 AM UTC-5, bastie...@gmail.com
> wrote:
>>
>> Hi,
>>
>> So I was toying with the idea of named tuple when I remembered D's name
>> resolution operator
>> <https://dlang.org/spec/operatoroverloading.html#dispatch> and check if
>> it was possible to implement in C++.
>> For those not familiar to the idea it's manly an operator that receives
>> the unknown member access as a template non-type parameter instead of
>> causing an error.
>> To my surprise it is an is quite cheap to implement (50 lines for GCC)
>> and could quite powerful (particularly if combined with reflection).
>> To avoid creating a new operator i'm using the operator* with a template
>> non-type reference parameter as the 'new' operator :* template<auto&
>> memberName> auto operator*();*
>> One of the motivations to use this operator is because it allows
>> out-of-class definitions.
>> You can try and check some exemple here if you wish :
>> http://dispatch.gcc-future.tk/#
>>
>> The reason why I bring this up is that I believe that It could solve a
>> bunch of demands that have been unsuccessful in the past (generally due to
>> their coast being to great compared to the supposed benefit. ie: new
>> operator, keyword, syntax, etc...).
>> Mainly the dot operator, properties, out of class method definition and
>> UCS.
>>
>> Here are a few examples.
>>
>> logging class with reflection:
>>
>
> This doesn't work on constructors/destructors. Or operators, unless the
> caller spelled out the operator name (maybe?).
>
Yes indeed it wouldn't. It could but i don't think that would be a good
thing.

>
> properties, simulate inheritance, multiple names:
>>
>
> I've seen a* lot* of syntaxes proposed for properties, but that is
> perhaps the worst. The fact that you have to declare all of the properties
> inside of a single function makes this a hideous beast if your class has a
> significant number of properties.
>
I agree, it would quite hideous but you're not required to define
everything inside one function.
Instead of using "if constexpr" you can redeclare the function with a
different requirement on the ids you want.
That being able to regroup everything inside

>
> standard layout, pod:
>>
>
> std::complex doesn't need help being standard layout. It's already
> required to be standard layout, and with a very specific layout. Nobody is
> stopping you from having `real` and `img` member functions with that layout.
>
Woow I'm not claiming such a thing  at all. I just used this example to
illustrate that it can allow for properties on trivial/pod types without
changing the definition.

>
> Out of class method definition / templated this / UCS:
>>
>
> We definitely do not want people to be able to inject methods into
> arbitrary classes like this. Besides, how would you find this operator? ADL
> is how out-of-member operators are normally found.
>
The point of UCS is just that isn't it ? Using the member access syntax
call on normal functions.
UCS could be implemented on the library side with this and reflection with
a static operator defined in an header <ucs>.

For the question I don't understand what you mean. It a normal operator
it's just that it is called as a fallback when a member access fails due to
the member not being found. There is no complexity to it.


> --
> You received this message because you are subscribed to a topic in the
> Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit https://groups.google.com/a/
> isocpp.org/d/topic/std-proposals/fFwL0jskVUA/unsubscribe.
> To unsubscribe from this group and all its topics, 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/437c4139-06b9-4751-
> aa2f-dea9563266dd%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/437c4139-06b9-4751-aa2f-dea9563266dd%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

--
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/CAOhm51ETF9sL%2BpUnec%2Bbkt256LZOOX-y5PzaiX1Fr86PZpDtpw%40mail.gmail.com.

--f403045d5aec4921080563da1ef6
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">2018-01-28 16:29 GMT+01:00 Nicol Bolas <span dir=3D"ltr">&lt;<a href=3D=
"mailto:jmckesson@gmail.com" target=3D"_blank">jmckesson@gmail.com</a>&gt;<=
/span>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bor=
der-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span class=3D""=
>On Sunday, January 28, 2018 at 12:26:25 AM UTC-5, <a href=3D"mailto:bastie=
....@gmail.com" target=3D"_blank">bastie...@gmail.com</a> wrote:<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">Hi,<div><br></div><div>So I wa=
s toying with the idea of named tuple when I remembered <a href=3D"https://=
dlang.org/spec/operatoroverloading.html#dispatch" rel=3D"nofollow" target=
=3D"_blank">D&#39;s name resolution operator</a>=C2=A0and check if it was p=
ossible to implement in C++.</div><div>For those not familiar to the idea i=
t&#39;s manly an operator that receives the unknown member access as a temp=
late non-type parameter instead of causing an error.</div><div>To my surpri=
se it is an is quite cheap to implement (50 lines for GCC) and could quite =
powerful (particularly if combined with reflection).</div><div>To avoid cre=
ating a new operator i&#39;m using the operator* with a template non-type r=
eference parameter as the &#39;new&#39; operator :<b> template&lt;auto&amp;=
 memberName&gt; auto operator*();</b></div><div>One of the motivations to u=
se this operator is because it allows out-of-class definitions.</div><div>Y=
ou can try and check some exemple here if you wish :=C2=A0<a href=3D"http:/=
/dispatch.gcc-future.tk/#" rel=3D"nofollow" target=3D"_blank">http://dispat=
ch.gcc-future.t<wbr>k/#</a><br></div><div><br></div><div>The reason why I b=
ring this up is that I believe that It could solve a bunch of demands that =
have been unsuccessful in the past (generally due to their coast being to g=
reat compared to the supposed benefit. ie: new operator, keyword, syntax, e=
tc...).</div><div>Mainly the dot operator, properties, out of class method =
definition and UCS.</div><div><br></div><div>Here are a few examples.</div>=
<div><br></div><div>logging class with reflection:</div></div></blockquote>=
<div><br></div></span><div>This doesn&#39;t work on constructors/destructor=
s. Or operators, unless the caller spelled out the operator name (maybe?).<=
/div></div></blockquote><div>Yes indeed it wouldn&#39;t. It could but i don=
&#39;t think that would be a good thing.=C2=A0</div><blockquote class=3D"gm=
ail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-le=
ft:1ex"><div dir=3D"ltr"><span class=3D""><div><br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr"><div>properties, simulate inheritan=
ce, multiple names:<br></div></div></blockquote><div><br></div></span><div>=
I&#39;ve seen a<i> lot</i> of syntaxes proposed for properties, but that is=
 perhaps the worst. The fact that you have to declare all of the properties=
 inside of a single function makes this a hideous beast if your class has a=
 significant number of properties.</div></div></blockquote><div>I agree, it=
 would quite hideous but you&#39;re not required to define everything insid=
e one function.</div><div>Instead of using &quot;if constexpr&quot; you can=
 redeclare the function with a=C2=A0 different requirement on the ids you w=
ant.</div><div>That being able to regroup everything inside=C2=A0</div><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c=
cc solid;padding-left:1ex"><div dir=3D"ltr"><div><br></div><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc =
solid;padding-left:1ex"><div dir=3D"ltr"><div>standard layout, pod:</div></=
div></blockquote><div><br></div><div>std::complex doesn&#39;t need help bei=
ng standard layout. It&#39;s already required to be standard layout, and wi=
th a very specific layout. Nobody is stopping you from having `real` and `i=
mg` member functions with that layout.</div></div></blockquote><div>Woow I&=
#39;m not claiming such a thing=C2=A0 at all. I just used this example to i=
llustrate that it can allow for properties on trivial/pod types without cha=
nging the definition.</div><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">=
<span class=3D""><div><font style=3D"background-color:rgb(250,250,250)"></f=
ont><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-le=
ft:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div=
>Out of class method definition / templated this / UCS:</div></div></blockq=
uote><div><br></div></span><div>We definitely do not want people to be able=
 to inject methods into arbitrary classes like this. Besides, how would you=
 find this operator? ADL is how out-of-member operators are normally found.=
</div></div></blockquote><div>The point of UCS is just that isn&#39;t it ? =
Using the member access syntax call on normal functions.</div><div>UCS coul=
d be implemented on the library side with this and reflection with a static=
 operator defined in an header &lt;ucs&gt;.</div><div><br></div><div>For th=
e question I don&#39;t understand what you mean. It a normal operator it&#3=
9;s just that it is called as a fallback when a member access fails due to =
the member not being found. There is no complexity to it.</div><div><br></d=
iv><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><br></div></div><sp=
an class=3D"">

<p></p>

-- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups &quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/fFwL0jskVUA/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/<wbr>isocpp.org/d/topic/std-<wbr>proposals/f=
FwL0jskVUA/<wbr>unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_blank">std-prop=
osals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/437c4139-06b9-4751-aa2f-dea9563266dd%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/437c=
4139-06b9-4751-<wbr>aa2f-dea9563266dd%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></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/CAOhm51ETF9sL%2BpUnec%2Bbkt256LZOOX-y=
5PzaiX1Fr86PZpDtpw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOhm51ETF9sL=
%2BpUnec%2Bbkt256LZOOX-y5PzaiX1Fr86PZpDtpw%40mail.gmail.com</a>.<br />

--f403045d5aec4921080563da1ef6--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sun, 28 Jan 2018 12:53:57 -0800 (PST)
Raw View
------=_Part_9096_1643667663.1517172837391
Content-Type: multipart/alternative;
 boundary="----=_Part_9097_1202324820.1517172837392"

------=_Part_9097_1202324820.1517172837392
Content-Type: text/plain; charset="UTF-8"

On Sunday, January 28, 2018 at 1:15:48 PM UTC-5, Bastien penavayre wrote:
>
> 2018-01-28 16:29 GMT+01:00 Nicol Bolas <jmck...@gmail.com <javascript:>>:
>
>> On Sunday, January 28, 2018 at 12:26:25 AM UTC-5, bastie...@gmail.com
>> wrote:
>>>
>>> Hi,
>>>
>>> So I was toying with the idea of named tuple when I remembered D's name
>>> resolution operator
>>> <https://dlang.org/spec/operatoroverloading.html#dispatch> and check if
>>> it was possible to implement in C++.
>>> For those not familiar to the idea it's manly an operator that receives
>>> the unknown member access as a template non-type parameter instead of
>>> causing an error.
>>> To my surprise it is an is quite cheap to implement (50 lines for GCC)
>>> and could quite powerful (particularly if combined with reflection).
>>> To avoid creating a new operator i'm using the operator* with a template
>>> non-type reference parameter as the 'new' operator :* template<auto&
>>> memberName> auto operator*();*
>>> One of the motivations to use this operator is because it allows
>>> out-of-class definitions.
>>> You can try and check some exemple here if you wish :
>>> http://dispatch.gcc-future.tk/#
>>>
>>> The reason why I bring this up is that I believe that It could solve a
>>> bunch of demands that have been unsuccessful in the past (generally due to
>>> their coast being to great compared to the supposed benefit. ie: new
>>> operator, keyword, syntax, etc...).
>>> Mainly the dot operator, properties, out of class method definition and
>>> UCS.
>>>
>>> Here are a few examples.
>>>
>>> logging class with reflection:
>>>
>>
>> This doesn't work on constructors/destructors. Or operators, unless the
>> caller spelled out the operator name (maybe?).
>>
> Yes indeed it wouldn't. It could but i don't think that would be a good
> thing.
>

If logging is important to you, why would you not want to log operators and
constructors/destructors?


>
>
properties, simulate inheritance, multiple names:
>>>
>>
>> I've seen a* lot* of syntaxes proposed for properties, but that is
>> perhaps the worst. The fact that you have to declare all of the properties
>> inside of a single function makes this a hideous beast if your class has a
>> significant number of properties.
>>
> I agree, it would quite hideous but you're not required to define
> everything inside one function.
> Instead of using "if constexpr" you can redeclare the function with a
> different requirement on the ids you want.
>

Because that's so much better.


> That being able to regroup everything inside
>
>>
>> standard layout, pod:
>>>
>>
>> std::complex doesn't need help being standard layout. It's already
>> required to be standard layout, and with a very specific layout. Nobody is
>> stopping you from having `real` and `img` member functions with that layout.
>>
> Woow I'm not claiming such a thing  at all. I just used this example to
> illustrate that it can allow for properties on trivial/pod types without
> changing the definition.
>

What you're talking about is about adding stuff to types* of any kind*
without changing their definitions. Being "trivial/POD" has nothing to do
with this.


>> Out of class method definition / templated this / UCS:
>>>
>>
>> We definitely do not want people to be able to inject methods into
>> arbitrary classes like this. Besides, how would you find this operator? ADL
>> is how out-of-member operators are normally found.
>>
> The point of UCS is just that isn't it ? Using the member access syntax
> call on normal functions.
>

It depends on which version of UCS you're talking about.

UCS could be implemented on the library side with this and reflection with
> a static operator defined in an header <ucs>.
>

UCS didn't fail because of the difficulty of implementing it in compilers.
It failed because many people* didn't want it*. Making it theoretically
writable as a library changes none of the reasons for not wanting it. And
indeed, if your feature allows UCS, then that means all of those arguments
against UCS become reasons not to allow your feature.

For the question I don't understand what you mean. It a normal operator
> it's just that it is called as a fallback when a member access fails due to
> the member not being found. There is no complexity to it.
>

My question was how do you associate a specific implementation of this
`operator NAME` with an object type?

Let's say you have this:

struct Type
{...};

Type operator+(const Type &lhs, const Type &rhs);

Type t1{...};
Type t2{...};

If I do `t1+t2`, the compiler finds the `operator+` overload through the
use of Argument Dependent Lookup. That is, this* only works* when the
`Type` and `operator+` are in the same namespace (outside of `using`
gymnastics).

You cannot create a generic, template `operator+` overload that works for
all types without making it a function in the global namespace (which is
rude). And the same would be true of your `operator NAME` template; the
only way to associate it with a particular type is to declare it in the
namespace of that type.

Even the member-version of UCS was based on ADL lookup (and, if I recall
correctly, *only* ADL lookup. It wouldn't find functions via non-ADL means).

--
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/1e9a4035-1363-463a-9b97-6c153c38ebd5%40isocpp.org.

------=_Part_9097_1202324820.1517172837392
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Sunday, January 28, 2018 at 1:15:48 PM UTC-5, Bastien p=
enavayre wrote:<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=
"><div><div class=3D"gmail_quote">2018-01-28 16:29 GMT+01:00 Nicol Bolas <s=
pan dir=3D"ltr">&lt;<a onmousedown=3D"this.href=3D&#39;javascript:&#39;;ret=
urn true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;" href=
=3D"javascript:" target=3D"_blank" rel=3D"nofollow" gdf-obfuscated-mailto=
=3D"SPjvV_B4BgAJ">jmck...@gmail.com</a>&gt;</span>:<br><blockquote class=3D=
"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding=
-left:1ex"><div dir=3D"ltr"><span>On Sunday, January 28, 2018 at 12:26:25 A=
M UTC-5, <a>bastie...@gmail.com</a> wrote:<blockquote class=3D"gmail_quote"=
 style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-lef=
t:1ex"><div dir=3D"ltr">Hi,<div><br></div><div>So I was toying with the ide=
a of named tuple when I remembered <a onmousedown=3D"this.href=3D&#39;https=
://www.google.com/url?q\x3dhttps%3A%2F%2Fdlang.org%2Fspec%2Foperatoroverloa=
ding.html%23dispatch\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzNFt_luOJfQw2=
_XmtkXz5O2qiiQ&#39;;return true;" onclick=3D"this.href=3D&#39;https://www.g=
oogle.com/url?q\x3dhttps%3A%2F%2Fdlang.org%2Fspec%2Foperatoroverloading.htm=
l%23dispatch\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzNFt_luOJfQw2_XmtkXz5=
O2qiiQ&#39;;return true;" href=3D"https://dlang.org/spec/operatoroverloadin=
g.html#dispatch" target=3D"_blank" rel=3D"nofollow">D&#39;s name resolution=
 operator</a>=C2=A0and check if it was possible to implement in C++.</div><=
div>For those not familiar to the idea it&#39;s manly an operator that rece=
ives the unknown member access as a template non-type parameter instead of =
causing an error.</div><div>To my surprise it is an is quite cheap to imple=
ment (50 lines for GCC) and could quite powerful (particularly if combined =
with reflection).</div><div>To avoid creating a new operator i&#39;m using =
the operator* with a template non-type reference parameter as the &#39;new&=
#39; operator :<b> template&lt;auto&amp; memberName&gt; auto operator*();</=
b></div><div>One of the motivations to use this operator is because it allo=
ws out-of-class definitions.</div><div>You can try and check some exemple h=
ere if you wish :=C2=A0<a onmousedown=3D"this.href=3D&#39;http://www.google=
..com/url?q\x3dhttp%3A%2F%2Fdispatch.gcc-future.tk%2F%23\x26sa\x3dD\x26sntz\=
x3d1\x26usg\x3dAFQjCNE4UjYjHib_e_JiYSPeRbOqP_cF4g&#39;;return true;" onclic=
k=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdispatch.=
gcc-future.tk%2F%23\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE4UjYjHib_e_JiY=
SPeRbOqP_cF4g&#39;;return true;" href=3D"http://dispatch.gcc-future.tk/#" t=
arget=3D"_blank" rel=3D"nofollow">http://dispatch.gcc-future.<wbr>tk/#</a><=
br></div><div><br></div><div>The reason why I bring this up is that I belie=
ve that It could solve a bunch of demands that have been unsuccessful in th=
e past (generally due to their coast being to great compared to the suppose=
d benefit. ie: new operator, keyword, syntax, etc...).</div><div>Mainly the=
 dot operator, properties, out of class method definition and UCS.</div><di=
v><br></div><div>Here are a few examples.</div><div><br></div><div>logging =
class with reflection:</div></div></blockquote><div><br></div></span><div>T=
his doesn&#39;t work on constructors/destructors. Or operators, unless the =
caller spelled out the operator name (maybe?).</div></div></blockquote><div=
>Yes indeed it wouldn&#39;t. It could but i don&#39;t think that would be a=
 good thing.</div></div></div></div></blockquote><div><br></div><div>If log=
ging is important to you, why would you not want to log operators and const=
ructors/destructors?</div><div>=C2=A0</div><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"><div><div class=3D"gmail_quote"><div>=C2=A0</=
div></div></div></div></blockquote><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"><div><div class=3D"gmail_quote"><div><span></span></=
div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span><blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr"><div>properties, simulate inheritan=
ce, multiple names:<br></div></div></blockquote><div><br></div></span><div>=
I&#39;ve seen a<i> lot</i> of syntaxes proposed for properties, but that is=
 perhaps the worst. The fact that you have to declare all of the properties=
 inside of a single function makes this a hideous beast if your class has a=
 significant number of properties.</div></div></blockquote><div>I agree, it=
 would quite hideous but you&#39;re not required to define everything insid=
e one function.</div><div>Instead of using &quot;if constexpr&quot; you can=
 redeclare the function with a=C2=A0 different requirement on the ids you w=
ant.</div></div></div></div></blockquote><div><br></div><div>Because that&#=
39;s so much better.</div><div>=C2=A0</div><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"><div><div class=3D"gmail_quote"><div>That bei=
ng able to regroup everything inside=C2=A0</div><blockquote class=3D"gmail_=
quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1=
ex"><div dir=3D"ltr"><div><br></div><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"><div>standard layout, pod:</div></div></blockquote><div><=
br></div><div>std::complex doesn&#39;t need help being standard layout. It&=
#39;s already required to be standard layout, and with a very specific layo=
ut. Nobody is stopping you from having `real` and `img` member functions wi=
th that layout.</div></div></blockquote><div>Woow I&#39;m not claiming such=
 a thing=C2=A0 at all. I just used this example to illustrate that it can a=
llow for properties on trivial/pod types without changing the definition.</=
div></div></div></div></blockquote><div><br></div><div>What you&#39;re talk=
ing about is about adding stuff to types<i> of any kind</i> without changin=
g their definitions. Being &quot;trivial/POD&quot; has nothing to do with t=
his.</div><div><i><br></i></div><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"><div><div class=3D"gmail_quote"><blockquote class=3D"gma=
il_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-lef=
t:1ex"><div dir=3D"ltr"><span><div><font style=3D"background-color:rgb(250,=
250,250)"></font><br></div><blockquote class=3D"gmail_quote" style=3D"margi=
n:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"ltr"><div>Out of class method definition / templated this / UCS:</div><=
/div></blockquote><div><br></div></span><div>We definitely do not want peop=
le to be able to inject methods into arbitrary classes like this. Besides, =
how would you find this operator? ADL is how out-of-member operators are no=
rmally found.</div></div></blockquote><div>The point of UCS is just that is=
n&#39;t it ? Using the member access syntax call on normal functions.</div>=
</div></div></div></blockquote><div><br></div><div>It depends on which vers=
ion of UCS you&#39;re talking about.</div><div><br></div><blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quote=
"><div>UCS could be implemented on the library side with this and reflectio=
n with a static operator defined in an header &lt;ucs&gt;.</div></div></div=
></div></blockquote><div><br></div><div>UCS didn&#39;t fail because of the =
difficulty of implementing it in compilers. It failed because many people<i=
> didn&#39;t want it</i>. Making it theoretically writable as a library cha=
nges none of the reasons for not wanting it. And indeed, if your feature al=
lows UCS, then that means all of those arguments against UCS become reasons=
 not to allow your feature.</div><div><i><br></i></div><blockquote class=3D=
"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc s=
olid;padding-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quote"><=
div>For the question I don&#39;t understand what you mean. It a normal oper=
ator it&#39;s just that it is called as a fallback when a member access fai=
ls due to the member not being found. There is no complexity to it.</div></=
div></div></div></blockquote><div><br></div><div>My question was how do you=
 associate a specific implementation of this `operator NAME` with an object=
 type?</div><div><br></div><div>Let&#39;s say you have this:</div><div><br>=
</div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 1=
87); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code cl=
ass=3D"prettyprint"><div class=3D"subprettyprint"><span class=3D"styled-by-=
prettify" style=3D"color: #008;">struct</span><span class=3D"styled-by-pret=
tify" style=3D"color: #000;"> </span><span class=3D"styled-by-prettify" sty=
le=3D"color: #606;">Type</span><span class=3D"styled-by-prettify" style=3D"=
color: #000;"><br></span><span class=3D"styled-by-prettify" style=3D"color:=
 #660;">{...};</span><span class=3D"styled-by-prettify" style=3D"color: #00=
0;"><br><br></span><span class=3D"styled-by-prettify" style=3D"color: #606;=
">Type</span><span class=3D"styled-by-prettify" style=3D"color: #000;"> </s=
pan><span class=3D"styled-by-prettify" style=3D"color: #008;">operator</spa=
n><span class=3D"styled-by-prettify" style=3D"color: #660;">+(</span><span =
class=3D"styled-by-prettify" style=3D"color: #008;">const</span><span class=
=3D"styled-by-prettify" style=3D"color: #000;"> </span><span class=3D"style=
d-by-prettify" style=3D"color: #606;">Type</span><span class=3D"styled-by-p=
rettify" style=3D"color: #000;"> </span><span class=3D"styled-by-prettify" =
style=3D"color: #660;">&amp;</span><span class=3D"styled-by-prettify" style=
=3D"color: #000;">lhs</span><span class=3D"styled-by-prettify" style=3D"col=
or: #660;">,</span><span class=3D"styled-by-prettify" style=3D"color: #000;=
"> </span><span class=3D"styled-by-prettify" style=3D"color: #008;">const</=
span><span class=3D"styled-by-prettify" style=3D"color: #000;"> </span><spa=
n class=3D"styled-by-prettify" style=3D"color: #606;">Type</span><span clas=
s=3D"styled-by-prettify" style=3D"color: #000;"> </span><span class=3D"styl=
ed-by-prettify" style=3D"color: #660;">&amp;</span><span class=3D"styled-by=
-prettify" style=3D"color: #000;">rhs</span><span class=3D"styled-by-pretti=
fy" style=3D"color: #660;">);</span><span class=3D"styled-by-prettify" styl=
e=3D"color: #000;"><br><br></span><span class=3D"styled-by-prettify" style=
=3D"color: #606;">Type</span><span class=3D"styled-by-prettify" style=3D"co=
lor: #000;"> t1</span><span class=3D"styled-by-prettify" style=3D"color: #6=
60;">{...};</span><span class=3D"styled-by-prettify" style=3D"color: #000;"=
><br></span><span class=3D"styled-by-prettify" style=3D"color: #606;">Type<=
/span><span class=3D"styled-by-prettify" style=3D"color: #000;"> t2</span><=
span class=3D"styled-by-prettify" style=3D"color: #660;">{...};</span></div=
></code></div><div><br></div><div>If I do `t1+t2`, the compiler finds the `=
operator+` overload through the use of Argument Dependent Lookup. That is, =
this<i> only works</i> when the `Type` and `operator+` are in the same name=
space (outside of `using` gymnastics).</div><div><br></div><div>You cannot =
create a generic, template `operator+` overload that works for all types wi=
thout making it a function in the global namespace (which is rude). And the=
 same would be true of your `operator NAME` template; the only way to assoc=
iate it with a particular type is to declare it in the namespace of that ty=
pe.</div><div><br></div><div>Even the member-version of UCS was based on AD=
L lookup (and, if I recall correctly, <i>only</i> ADL lookup. It wouldn&#39=
;t find functions via non-ADL means).</div><div><br></div><blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;">
</blockquote></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/1e9a4035-1363-463a-9b97-6c153c38ebd5%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1e9a4035-1363-463a-9b97-6c153c38ebd5=
%40isocpp.org</a>.<br />

------=_Part_9097_1202324820.1517172837392--

------=_Part_9096_1643667663.1517172837391--

.