Topic: Using sentences for aliasing functions at compile time


Author: theypsilon@gmail.com
Date: Mon, 25 Nov 2013 13:57:43 -0800 (PST)
Raw View
------=_Part_349_11202612.1385416663899
Content-Type: text/plain; charset=ISO-8859-1

Playing with tuples, I ended with a verbose code such like this one:

template <class T> T distance(std::tuple<T,T,T> lft, std::tuple<T,T,T> rgt)
{
    T d_x = std::get<0>(lft) > std::get<0>(rgt)?   std::get<0>(lft) - std::
get<0>(rgt):   std::get<0>(rgt) - std::get<0>(lft);
    T d_y = std::get<1>(lft) > std::get<1>(rgt)?   std::get<1>(lft) - std::
get<1>(rgt):   std::get<1>(rgt) - std::get<1>(lft);
    T d_z = std::get<2>(lft) > std::get<2>(rgt)?   std::get<2>(lft) - std::
get<2>(rgt):   std::get<2>(rgt) - std::get<2>(lft);


    return (d_x*d_x + d_z*d_z + d_y*d_y);
}

I think this is even hard to read for such a simple operation. It really
hurts when you compare it with the struct version.

Using-like declarations with functions names are already a tool the
language for avoiding some ADL problems (e.g.: using std::swap). My
question would be, why don't we push it a little further.

Consider this:

using x = std::get<0>; // Proposed syntax


That new syntax, being a natural extension to the previously commented use
case, and analogous to the using declarations for types, would make the
previous code much more terse than before:

template <class T> T distance(std::tuple<T,T,T> lft, std::tuple<T,T,T> rgt)
{
    using x = std::get<0>;
    using y = std::get<1>;
    using z = std::get<2>;

    T d_x = x(lft) > x(rgt)?   x(lft) - x(rgt):   x(rgt) - x(lft);
    T d_y = y(lft) > y(rgt)?   y(lft) - y(rgt):   y(rgt) - y(lft);
    T d_z = z(lft) > z(rgt)?   z(lft) - z(rgt):   z(rgt) - z(lft);

    return (d_x*d_x + d_z*d_z + d_y*d_y);
}

If you want to achieve this result in a similar way by now, the only way to
go would be a #define sentence, or writing this kind of boilerplate:

template <typename... Args>
auto x(Args&&... args) -> decltype(std::get<0>(std::forward<Args>(args)...))
{
  return std::get<0>(std::forward<Args>(args)...);
}


The application of this change on tuples can be really worthy, as it is
expected that the future compile-time reflection would force us to work a
lot more with this kind of data types. I guess we are all thinking in a
converter from structs to tuples.

Looking forward to discuss with you about this topic. I'm sure there should
be many considerations I'm missing right now :)

--

---
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_349_11202612.1385416663899
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Playing with tuples, I ended with a verbose code such like=
 this one:<div><br></div><div><div class=3D"prettyprint" style=3D"backgroun=
d-color: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-wra=
p: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><=
span style=3D"color: #008;" class=3D"styled-by-prettify">template</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">class</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> T distance</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">std</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>tuple</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #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">T</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> lft</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">tuple</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #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"style=
d-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 rgt</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; T d_x </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span sty=
le=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: #=
008;" class=3D"styled-by-prettify">get</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&lt;</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">0</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&gt;(</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">lft</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: #660;" class=3D"styled-by-prettify">&gt;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">get</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #066;" cl=
ass=3D"styled-by-prettify">0</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&gt;(</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">rgt</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">)?</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> &=
nbsp; std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:=
:</span><span style=3D"color: #008;" class=3D"styled-by-prettify">get</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span=
 style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&gt;(</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">lft</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: #660;" class=3D"style=
d-by-prettify">-</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #008;" class=3D"styled-by-prettify">get</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><spa=
n style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&gt;(</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">rgt</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">):</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> &nbsp; std</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">get</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&lt;</span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&g=
t;(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">rgt</sp=
an><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: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">get</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&lt;</span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&g=
t;(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">lft</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; T d_=
y </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">get</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #0=
66;" class=3D"styled-by-prettify">1</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">&gt;(</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">lft</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: #660;" class=3D"styled-by-prettify">&gt;<=
/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 st=
yle=3D"color: #008;" class=3D"styled-by-prettify">get</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color:=
 #066;" class=3D"styled-by-prettify">1</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&gt;(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">rgt</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">)?</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> &nbsp; std</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">::</span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">get</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;<=
/span><span style=3D"color: #066;" class=3D"styled-by-prettify">1</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&gt;(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">lft</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">-</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">::</span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">get</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;<=
/span><span style=3D"color: #066;" class=3D"styled-by-prettify">1</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&gt;(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">rgt</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">):</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> &nbsp; std</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">get</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&lt;</span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">1</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&gt;(</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>rgt</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">-</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">get</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&lt;</span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">1</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&gt;(</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>lft</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nb=
sp; T d_z </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">get</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"co=
lor: #066;" class=3D"styled-by-prettify">2</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&gt;(</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">lft</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: #660;" class=3D"styled-by-prettify=
">&gt;</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: #008;" class=3D"styled-by-prettify">get</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">2</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">&gt;(</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">rgt</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)?</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> &nbsp; std</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">::</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">get</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">&lt;</span><span style=3D"color: #066;" class=3D"styled-by-prettify">2</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;(</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">lft</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"co=
lor: #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;" class=3D"st=
yled-by-prettify">::</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">get</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&lt;</span><span style=3D"color: #066;" class=3D"styled-by-prettify">2</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;(</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">rgt</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">):</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> &nbsp; std</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">get</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">2</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&gt;(</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">rgt</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: #660;" class=3D"styled-by-prettify">-</span><span s=
tyle=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: #008;" class=3D"styled-by-prettify">get</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #066;" cla=
ss=3D"styled-by-prettify">2</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">lft</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
><br><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">return</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">d_x</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">d_x </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">+</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> d_z</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">d_z </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">+</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> d_y</span><span style=3D"color: #660;" class=3D"styled-by-prettify">*=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">d_y</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">}</span></div></code></div><div=
><br></div></div><div>I think this is even hard to read for such a simple o=
peration. It really hurts when you compare it with the struct version.</div=
><div><br></div><div>Using-like declarations with functions names are alrea=
dy a tool the language for avoiding some ADL problems (e.g.: using std::swa=
p). My question would be, why don't we push it a little further.</div><div>=
<br></div><div>Consider this:</div><div><br></div><div><div class=3D"pretty=
print" style=3D"background-color: rgb(250, 250, 250); border: 1px solid rgb=
(187, 187, 187); word-wrap: break-word;"><code class=3D"prettyprint"><div c=
lass=3D"subprettyprint"><font color=3D"#660066"><span style=3D"color: #008;=
" class=3D"styled-by-prettify">using</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> x </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">::</span><span style=3D"color: #008;" class=3D"styled-by-prettify">ge=
t</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</spa=
n><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">&gt;;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">// Proposed syntax</span></font></div=
></code></div><div><br></div><br>That new syntax, being a natural extension=
 to the previously commented use case, and analogous to the using declarati=
ons for types, would make the previous code much more terse than before:</d=
iv><div><font color=3D"#660066"><br></font><div class=3D"prettyprint" style=
=3D"background-color: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 1=
87); word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subp=
rettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">templ=
ate</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">class</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> T distance</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">std</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">tuple</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&lt;</span><span style=3D"color: #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">T</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"colo=
r: #000;" class=3D"styled-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-prettify"> lft</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">tuple=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">T</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #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">T</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> rgt</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: #660;" class=3D"styled-by-prettify">{</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">using</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> x </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">::</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">get</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">&lt;</span><span style=3D"color: #066;" class=3D"styled-=
by-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">&gt;;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
<br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">using</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> y </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D<=
/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 st=
yle=3D"color: #008;" class=3D"styled-by-prettify">get</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color:=
 #066;" class=3D"styled-by-prettify">1</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>&nbsp; &nbsp; </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">using</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> z </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">::</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
get</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span style=3D"color: #066;" class=3D"styled-by-prettify">2</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&gt;;</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; T d_x=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> x</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">lft</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> x</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">rgt</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">)?</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; x</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">lft</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">-</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">rgt</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">):</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; x</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">rgt</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">-</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> x</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">lft</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; T d_y=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> y</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">lft</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> y</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">rgt</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">)?</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; y</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">lft</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">-</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> y</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">rgt</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">):</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; y</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">rgt</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">-</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> y</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">lft</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; T d_z=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> z</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">lft</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> z</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">rgt</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">)?</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; z</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">lft</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">-</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> z</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">rgt</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">):</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; z</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">rgt</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">-</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> z</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">lft</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">return</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">d_x</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">d_x </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">+</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> d_z</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify">d_z =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">+</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> d_y</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">d_y</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">}</span></div></code></div><div class=3D"subprettyprint=
" style=3D"color: rgb(102, 0, 102); font-family: monospace; background-colo=
r: rgb(250, 250, 250);"><br></div></div><div class=3D"subprettyprint" style=
=3D"background-color: rgb(250, 250, 250);"><font color=3D"#000000" face=3D"=
arial, sans-serif">If you want to achieve this result in a similar way by n=
ow, the only way to go would be a #define sentence, or writing this kind of=
 boilerplate:</font></div><div class=3D"subprettyprint" style=3D"color: rgb=
(102, 0, 102); font-family: monospace; background-color: rgb(250, 250, 250)=
;"><br></div><div class=3D"subprettyprint" style=3D"background-color: rgb(2=
50, 250, 250);"><div class=3D"prettyprint" style=3D"background-color: rgb(2=
50, 250, 250); border: 1px solid rgb(187, 187, 187); 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"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">typename</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">...</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pr=
ettify">Args</span><span style=3D"color: #660;" class=3D"styled-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-prettify">auto</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> x</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"c=
olor: #606;" class=3D"styled-by-prettify">Args</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">&amp;&amp;...</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> args</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">-&gt;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </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: #000;" class=3D"styled-by-prettify">std</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">get</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">&gt;(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">std</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">forward</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&lt;</span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
Args</span><span style=3D"color: #660;" class=3D"styled-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-prettify">)...))</span><spa=
n 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"><br>&nbsp; </span><span style=3D"colo=
r: #008;" 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: #008;" class=3D=
"styled-by-prettify">get</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">&lt;</span><span style=3D"color: #066;" class=3D"styled-by-pr=
ettify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">std</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">forward</span><span s=
tyle=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"co=
lor: #660;" class=3D"styled-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-prettify">)...);</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">}</span></div></code></div><div class=3D"subprettyprint=
"><font color=3D"#660066" face=3D"monospace"><br></font></div><div class=3D=
"subprettyprint"><br></div><div class=3D"subprettyprint">The application of=
 this change on tuples can be really worthy, as it is expected that the fut=
ure compile-time reflection would force us to work a lot more with this kin=
d of data types. I guess we are all thinking in a converter from structs to=
 tuples.<br></div><div class=3D"subprettyprint"><br></div><div class=3D"sub=
prettyprint">Looking forward to discuss with you about this topic. I'm sure=
 there should be many considerations I'm missing right now :)</div></div></=
div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_349_11202612.1385416663899--

.


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Tue, 26 Nov 2013 00:47:25 +0100
Raw View
This is a multi-part message in MIME format.
--------------010104050909010000060504
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 25/11/13 22:57, theypsilon@gmail.com a =E9crit :
> Playing with tuples, I ended with a verbose code such like this one:
>
> |
> template<classT>T distance(std::tuple<T,T,T>lft,std::tuple<T,T,T>rgt){
>     T d_x =3Dstd::get<0>(lft)>std::get<0>(rgt)? =20
> std::get<0>(lft)-std::get<0>(rgt):  std::get<0>(rgt)-std::get<0>(lft);
>     T d_y =3Dstd::get<1>(lft)>std::get<1>(rgt)? =20
> std::get<1>(lft)-std::get<1>(rgt):  std::get<1>(rgt)-std::get<1>(lft);
>     T d_z =3Dstd::get<2>(lft)>std::get<2>(rgt)? =20
> std::get<2>(lft)-std::get<2>(rgt):  std::get<2>(rgt)-std::get<2>(lft);
>
>
> return(d_x*d_x +d_z*d_z +d_y*d_y);
> }
> |
>
> I think this is even hard to read for such a simple operation. It=20
> really hurts when you compare it with the struct version.
>
> Using-like declarations with functions names are already a tool the=20
> language for avoiding some ADL problems (e.g.: using std::swap). My=20
> question would be, why don't we push it a little further.
>
> Consider this:
>
> |
> usingx =3Dstd::get<0>;// Proposed syntax
> |
>
>
> That new syntax, being a natural extension to the previously commented=20
> use case, and analogous to the using declarations for types, would=20
> make the previous code much more terse than before:
>
> |
> template<classT>T distance(std::tuple<T,T,T>lft,std::tuple<T,T,T>rgt){
> usingx =3Dstd::get<0>;
> usingy =3Dstd::get<1>;
> usingz =3Dstd::get<2>;
>
>     T d_x =3Dx(lft)>x(rgt)?  x(lft)-x(rgt):  x(rgt)-x(lft);
>     T d_y =3Dy(lft)>y(rgt)?  y(lft)-y(rgt):  y(rgt)-y(lft);
>     T d_z =3Dz(lft)>z(rgt)?  z(lft)-z(rgt):  z(rgt)-z(lft);
>
> return(d_x*d_x +d_z*d_z +d_y*d_y);
> }
> |
>

Hi,

what about using generic lambdas


|
template<classT>T distance(std::tuple<T,T,T>lft,std::tuple<T,T,T>rgt){
|    autox =3D[](auto|t|) { return std::get<0>(t); }
||    autoy =3D[](||||auto|||t|) { return std::get<1>(t); }
||    autoz =3D[](||||auto|||t|) { return std::get<2>(t); }
|
     T d_x =3Dx(lft)>x(rgt)?  x(lft)-x(rgt):  x(rgt)-x(lft);
     T d_y =3Dy(lft)>y(rgt)?  y(lft)-y(rgt):  y(rgt)-y(lft);
     T d_z =3Dz(lft)>z(rgt)?  z(lft)-z(rgt):  z(rgt)-z(lft);

return(d_x*d_x +d_z*d_z +d_y*d_y);
}
|


It is quite close to your proposed syntax, isn't it?


Vicente

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--------------010104050909010000060504
Content-Type: text/html; charset=ISO-8859-1

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Le 25/11/13 22:57, <a class="moz-txt-link-abbreviated" href="mailto:theypsilon@gmail.com">theypsilon@gmail.com</a>
      a &eacute;crit&nbsp;:<br>
    </div>
    <blockquote
      cite="mid:b189f899-929e-4607-986a-00088b7bce5d@isocpp.org"
      type="cite">
      <div dir="ltr">Playing with tuples, I ended with a verbose code
        such like this one:
        <div><br>
        </div>
        <div>
          <div class="prettyprint" style="background-color: rgb(250,
            250, 250); border: 1px solid rgb(187, 187, 187); word-wrap:
            break-word;"><code class="prettyprint">
              <div class="subprettyprint"><span style="color: #008;"
                  class="styled-by-prettify">template</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #008;" class="styled-by-prettify">class</span><span
                  style="color: #000;" class="styled-by-prettify"> T</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;</span><span
                  style="color: #000;" class="styled-by-prettify"> T
                  distance</span><span style="color: #660;"
                  class="styled-by-prettify">(</span><span style="color:
                  #000;" class="styled-by-prettify">std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #000;" class="styled-by-prettify">tuple</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #000;" class="styled-by-prettify">T</span><span
                  style="color: #660;" class="styled-by-prettify">,</span><span
                  style="color: #000;" class="styled-by-prettify">T</span><span
                  style="color: #660;" class="styled-by-prettify">,</span><span
                  style="color: #000;" class="styled-by-prettify">T</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;</span><span
                  style="color: #000;" class="styled-by-prettify"> lft</span><span
                  style="color: #660;" class="styled-by-prettify">,</span><span
                  style="color: #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #000;" class="styled-by-prettify">tuple</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #000;" class="styled-by-prettify">T</span><span
                  style="color: #660;" class="styled-by-prettify">,</span><span
                  style="color: #000;" class="styled-by-prettify">T</span><span
                  style="color: #660;" class="styled-by-prettify">,</span><span
                  style="color: #000;" class="styled-by-prettify">T</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;</span><span
                  style="color: #000;" class="styled-by-prettify"> rgt</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">{</span><span
                  style="color: #000;" class="styled-by-prettify"><br>
                  &nbsp; &nbsp; T d_x </span><span style="color: #660;"
                  class="styled-by-prettify">=</span><span style="color:
                  #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">0</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">&gt;</span><span
                  style="color: #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">0</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">)?</span><span
                  style="color: #000;" class="styled-by-prettify"> &nbsp; std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">0</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">-</span><span
                  style="color: #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">0</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">):</span><span
                  style="color: #000;" class="styled-by-prettify"> &nbsp; std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">0</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">-</span><span
                  style="color: #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">0</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">);</span><span
                  style="color: #000;" class="styled-by-prettify"><br>
                  &nbsp; &nbsp; T d_y </span><span style="color: #660;"
                  class="styled-by-prettify">=</span><span style="color:
                  #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">1</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">&gt;</span><span
                  style="color: #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">1</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">)?</span><span
                  style="color: #000;" class="styled-by-prettify"> &nbsp; std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">1</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">-</span><span
                  style="color: #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">1</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">):</span><span
                  style="color: #000;" class="styled-by-prettify"> &nbsp; std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">1</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">-</span><span
                  style="color: #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">1</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">);</span><span
                  style="color: #000;" class="styled-by-prettify"><br>
                  &nbsp; &nbsp; T d_z </span><span style="color: #660;"
                  class="styled-by-prettify">=</span><span style="color:
                  #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">2</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">&gt;</span><span
                  style="color: #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">2</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">)?</span><span
                  style="color: #000;" class="styled-by-prettify"> &nbsp; std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">2</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">-</span><span
                  style="color: #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">2</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">):</span><span
                  style="color: #000;" class="styled-by-prettify"> &nbsp; std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">2</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">-</span><span
                  style="color: #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">2</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">);</span><span
                  style="color: #000;" class="styled-by-prettify"><br>
                  <br>
                  <br>
                  &nbsp; &nbsp; </span><span style="color: #008;"
                  class="styled-by-prettify">return</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">d_x</span><span
                  style="color: #660;" class="styled-by-prettify">*</span><span
                  style="color: #000;" class="styled-by-prettify">d_x </span><span
                  style="color: #660;" class="styled-by-prettify">+</span><span
                  style="color: #000;" class="styled-by-prettify"> d_z</span><span
                  style="color: #660;" class="styled-by-prettify">*</span><span
                  style="color: #000;" class="styled-by-prettify">d_z </span><span
                  style="color: #660;" class="styled-by-prettify">+</span><span
                  style="color: #000;" class="styled-by-prettify"> d_y</span><span
                  style="color: #660;" class="styled-by-prettify">*</span><span
                  style="color: #000;" class="styled-by-prettify">d_y</span><span
                  style="color: #660;" class="styled-by-prettify">);</span><span
                  style="color: #000;" class="styled-by-prettify"><br>
                </span><span style="color: #660;"
                  class="styled-by-prettify">}</span></div>
            </code></div>
          <div><br>
          </div>
        </div>
        <div>I think this is even hard to read for such a simple
          operation. It really hurts when you compare it with the struct
          version.</div>
        <div><br>
        </div>
        <div>Using-like declarations with functions names are already a
          tool the language for avoiding some ADL problems (e.g.: using
          std::swap). My question would be, why don't we push it a
          little further.</div>
        <div><br>
        </div>
        <div>Consider this:</div>
        <div><br>
        </div>
        <div>
          <div class="prettyprint" style="background-color: rgb(250,
            250, 250); border: 1px solid rgb(187, 187, 187); word-wrap:
            break-word;"><code class="prettyprint">
              <div class="subprettyprint"><font color="#660066"><span
                    style="color: #008;" class="styled-by-prettify">using</span><span
                    style="color: #000;" class="styled-by-prettify"> x </span><span
                    style="color: #660;" class="styled-by-prettify">=</span><span
                    style="color: #000;" class="styled-by-prettify"> std</span><span
                    style="color: #660;" class="styled-by-prettify">::</span><span
                    style="color: #008;" class="styled-by-prettify">get</span><span
                    style="color: #660;" class="styled-by-prettify">&lt;</span><span
                    style="color: #066;" class="styled-by-prettify">0</span><span
                    style="color: #660;" class="styled-by-prettify">&gt;;</span><span
                    style="color: #000;" class="styled-by-prettify"> </span><span
                    style="color: #800;" class="styled-by-prettify">//
                    Proposed syntax</span></font></div>
            </code></div>
          <div><br>
          </div>
          <br>
          That new syntax, being a natural extension to the previously
          commented use case, and analogous to the using declarations
          for types, would make the previous code much more terse than
          before:</div>
        <div><font color="#660066"><br>
          </font>
          <div class="prettyprint" style="background-color: rgb(250,
            250, 250); border: 1px solid rgb(187, 187, 187); word-wrap:
            break-word;"><code class="prettyprint">
              <div class="subprettyprint"><span style="color: #008;"
                  class="styled-by-prettify">template</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #008;" class="styled-by-prettify">class</span><span
                  style="color: #000;" class="styled-by-prettify"> T</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;</span><span
                  style="color: #000;" class="styled-by-prettify"> T
                  distance</span><span style="color: #660;"
                  class="styled-by-prettify">(</span><span style="color:
                  #000;" class="styled-by-prettify">std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #000;" class="styled-by-prettify">tuple</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #000;" class="styled-by-prettify">T</span><span
                  style="color: #660;" class="styled-by-prettify">,</span><span
                  style="color: #000;" class="styled-by-prettify">T</span><span
                  style="color: #660;" class="styled-by-prettify">,</span><span
                  style="color: #000;" class="styled-by-prettify">T</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;</span><span
                  style="color: #000;" class="styled-by-prettify"> lft</span><span
                  style="color: #660;" class="styled-by-prettify">,</span><span
                  style="color: #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #000;" class="styled-by-prettify">tuple</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #000;" class="styled-by-prettify">T</span><span
                  style="color: #660;" class="styled-by-prettify">,</span><span
                  style="color: #000;" class="styled-by-prettify">T</span><span
                  style="color: #660;" class="styled-by-prettify">,</span><span
                  style="color: #000;" class="styled-by-prettify">T</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;</span><span
                  style="color: #000;" class="styled-by-prettify"> rgt</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">{</span><span
                  style="color: #000;" class="styled-by-prettify"><br>
                  &nbsp; &nbsp; </span><span style="color: #008;"
                  class="styled-by-prettify">using</span><span
                  style="color: #000;" class="styled-by-prettify"> x </span><span
                  style="color: #660;" class="styled-by-prettify">=</span><span
                  style="color: #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">0</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;;</span><span
                  style="color: #000;" class="styled-by-prettify"> <br>
                  &nbsp; &nbsp; </span><span style="color: #008;"
                  class="styled-by-prettify">using</span><span
                  style="color: #000;" class="styled-by-prettify"> y </span><span
                  style="color: #660;" class="styled-by-prettify">=</span><span
                  style="color: #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">1</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;;</span><span
                  style="color: #000;" class="styled-by-prettify"> <br>
                  &nbsp; &nbsp; </span><span style="color: #008;"
                  class="styled-by-prettify">using</span><span
                  style="color: #000;" class="styled-by-prettify"> z </span><span
                  style="color: #660;" class="styled-by-prettify">=</span><span
                  style="color: #000;" class="styled-by-prettify"> std</span><span
                  style="color: #660;" class="styled-by-prettify">::</span><span
                  style="color: #008;" class="styled-by-prettify">get</span><span
                  style="color: #660;" class="styled-by-prettify">&lt;</span><span
                  style="color: #066;" class="styled-by-prettify">2</span><span
                  style="color: #660;" class="styled-by-prettify">&gt;;</span><span
                  style="color: #000;" class="styled-by-prettify"><br>
                  <br>
                  &nbsp; &nbsp; T d_x </span><span style="color: #660;"
                  class="styled-by-prettify">=</span><span style="color:
                  #000;" class="styled-by-prettify"> x</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">&gt;</span><span
                  style="color: #000;" class="styled-by-prettify"> x</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">)?</span><span
                  style="color: #000;" class="styled-by-prettify"> &nbsp; x</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">-</span><span
                  style="color: #000;" class="styled-by-prettify"> x</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">):</span><span
                  style="color: #000;" class="styled-by-prettify"> &nbsp; x</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">-</span><span
                  style="color: #000;" class="styled-by-prettify"> x</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">);</span><span
                  style="color: #000;" class="styled-by-prettify"><br>
                  &nbsp; &nbsp; T d_y </span><span style="color: #660;"
                  class="styled-by-prettify">=</span><span style="color:
                  #000;" class="styled-by-prettify"> y</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">&gt;</span><span
                  style="color: #000;" class="styled-by-prettify"> y</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">)?</span><span
                  style="color: #000;" class="styled-by-prettify"> &nbsp; y</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">-</span><span
                  style="color: #000;" class="styled-by-prettify"> y</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">):</span><span
                  style="color: #000;" class="styled-by-prettify"> &nbsp; y</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">-</span><span
                  style="color: #000;" class="styled-by-prettify"> y</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">);</span><span
                  style="color: #000;" class="styled-by-prettify"><br>
                  &nbsp; &nbsp; T d_z </span><span style="color: #660;"
                  class="styled-by-prettify">=</span><span style="color:
                  #000;" class="styled-by-prettify"> z</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">&gt;</span><span
                  style="color: #000;" class="styled-by-prettify"> z</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">)?</span><span
                  style="color: #000;" class="styled-by-prettify"> &nbsp; z</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">-</span><span
                  style="color: #000;" class="styled-by-prettify"> z</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">):</span><span
                  style="color: #000;" class="styled-by-prettify"> &nbsp; z</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">rgt</span><span
                  style="color: #660;" class="styled-by-prettify">)</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">-</span><span
                  style="color: #000;" class="styled-by-prettify"> z</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">lft</span><span
                  style="color: #660;" class="styled-by-prettify">);</span><span
                  style="color: #000;" class="styled-by-prettify"><br>
                  <br>
                  &nbsp; &nbsp; </span><span style="color: #008;"
                  class="styled-by-prettify">return</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #000;" class="styled-by-prettify">d_x</span><span
                  style="color: #660;" class="styled-by-prettify">*</span><span
                  style="color: #000;" class="styled-by-prettify">d_x </span><span
                  style="color: #660;" class="styled-by-prettify">+</span><span
                  style="color: #000;" class="styled-by-prettify"> d_z</span><span
                  style="color: #660;" class="styled-by-prettify">*</span><span
                  style="color: #000;" class="styled-by-prettify">d_z </span><span
                  style="color: #660;" class="styled-by-prettify">+</span><span
                  style="color: #000;" class="styled-by-prettify"> d_y</span><span
                  style="color: #660;" class="styled-by-prettify">*</span><span
                  style="color: #000;" class="styled-by-prettify">d_y</span><span
                  style="color: #660;" class="styled-by-prettify">);</span><span
                  style="color: #000;" class="styled-by-prettify"><br>
                </span><span style="color: #660;"
                  class="styled-by-prettify">}</span></div>
            </code></div>
          <div class="subprettyprint" style="color: rgb(102, 0, 102);
            font-family: monospace; background-color: rgb(250, 250,
            250);"><br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    <font face="arial, sans-serif">Hi,<br>
      <br>
      what about using generic lambdas<br>
      <br>
    </font><br>
    <div class="prettyprint" style="background-color: rgb(250, 250,
      250); border: 1px solid rgb(187, 187, 187); word-wrap:
      break-word;"><code class="prettyprint">
        <div class="subprettyprint"><span style="color: #008;"
            class="styled-by-prettify">template</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">&lt;</span><span
            style="color: #008;" class="styled-by-prettify">class</span><span
            style="color: #000;" class="styled-by-prettify"> T</span><span
            style="color: #660;" class="styled-by-prettify">&gt;</span><span
            style="color: #000;" class="styled-by-prettify"> T distance</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">std</span><span
            style="color: #660;" class="styled-by-prettify">::</span><span
            style="color: #000;" class="styled-by-prettify">tuple</span><span
            style="color: #660;" class="styled-by-prettify">&lt;</span><span
            style="color: #000;" class="styled-by-prettify">T</span><span
            style="color: #660;" class="styled-by-prettify">,</span><span
            style="color: #000;" class="styled-by-prettify">T</span><span
            style="color: #660;" class="styled-by-prettify">,</span><span
            style="color: #000;" class="styled-by-prettify">T</span><span
            style="color: #660;" class="styled-by-prettify">&gt;</span><span
            style="color: #000;" class="styled-by-prettify"> lft</span><span
            style="color: #660;" class="styled-by-prettify">,</span><span
            style="color: #000;" class="styled-by-prettify"> std</span><span
            style="color: #660;" class="styled-by-prettify">::</span><span
            style="color: #000;" class="styled-by-prettify">tuple</span><span
            style="color: #660;" class="styled-by-prettify">&lt;</span><span
            style="color: #000;" class="styled-by-prettify">T</span><span
            style="color: #660;" class="styled-by-prettify">,</span><span
            style="color: #000;" class="styled-by-prettify">T</span><span
            style="color: #660;" class="styled-by-prettify">,</span><span
            style="color: #000;" class="styled-by-prettify">T</span><span
            style="color: #660;" class="styled-by-prettify">&gt;</span><span
            style="color: #000;" class="styled-by-prettify"> rgt</span><span
            style="color: #660;" class="styled-by-prettify">)</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">{</span><span
            style="color: #000;" class="styled-by-prettify"><br>
          </span><code class="prettyprint"><span style="color: #000;"
              class="styled-by-prettify">&nbsp; &nbsp; auto</span><span
              style="color: #000;" class="styled-by-prettify"> x </span><span
              style="color: #660;" class="styled-by-prettify">=</span><span
              style="color: #000;" class="styled-by-prettify"> [](auto</span><span
              style="color: #000;" class="styled-by-prettify"><code
                class="prettyprint"><span style="color: #660;"
                  class="styled-by-prettify"> t</span></code>) { return
              std</span><span style="color: #660;"
              class="styled-by-prettify">::</span><span style="color:
              #008;" class="styled-by-prettify">get</span><span
              style="color: #660;" class="styled-by-prettify">&lt;</span><span
              style="color: #066;" class="styled-by-prettify">0</span><span
              style="color: #660;" class="styled-by-prettify">&gt;(t); }</span><span
              style="color: #000;" class="styled-by-prettify"> <br>
            </span></code><code class="prettyprint"><span style="color:
              #000;" class="styled-by-prettify">&nbsp; &nbsp; auto</span><span
              style="color: #000;" class="styled-by-prettify"> y </span><span
              style="color: #660;" class="styled-by-prettify">=</span><span
              style="color: #000;" class="styled-by-prettify"> [](</span></code><code
            class="prettyprint"><span style="color: #000;"
              class="styled-by-prettify"><code class="prettyprint"><code
                  class="prettyprint"><span style="color: #000;"
                    class="styled-by-prettify">auto</span></code></code></span><span
              style="color: #000;" class="styled-by-prettify"><code
                class="prettyprint"><span style="color: #660;"
                  class="styled-by-prettify"> t</span></code>) { return
              std</span><span style="color: #660;"
              class="styled-by-prettify">::</span><span style="color:
              #008;" class="styled-by-prettify">get</span><span
              style="color: #660;" class="styled-by-prettify">&lt;</span><span
              style="color: #066;" class="styled-by-prettify">1</span><span
              style="color: #660;" class="styled-by-prettify">&gt;(t); }</span><span
              style="color: #000;" class="styled-by-prettify"> <br>
            </span></code><code class="prettyprint"><span style="color:
              #000;" class="styled-by-prettify">&nbsp; &nbsp; auto</span><span
              style="color: #000;" class="styled-by-prettify"> z </span><span
              style="color: #660;" class="styled-by-prettify">=</span><span
              style="color: #000;" class="styled-by-prettify"> [](</span></code><code
            class="prettyprint"><span style="color: #000;"
              class="styled-by-prettify"><code class="prettyprint"><code
                  class="prettyprint"><span style="color: #000;"
                    class="styled-by-prettify">auto</span></code></code></span><span
              style="color: #000;" class="styled-by-prettify"><code
                class="prettyprint"><span style="color: #660;"
                  class="styled-by-prettify"> t</span></code>) { return
              std</span><span style="color: #660;"
              class="styled-by-prettify">::</span><span style="color:
              #008;" class="styled-by-prettify">get</span><span
              style="color: #660;" class="styled-by-prettify">&lt;</span><span
              style="color: #066;" class="styled-by-prettify">2</span><span
              style="color: #660;" class="styled-by-prettify">&gt;(t); }</span><span
              style="color: #000;" class="styled-by-prettify"> <br>
            </span></code><span style="color: #000;"
            class="styled-by-prettify"><br>
            &nbsp; &nbsp; T d_x </span><span style="color: #660;"
            class="styled-by-prettify">=</span><span style="color:
            #000;" class="styled-by-prettify"> x</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">lft</span><span
            style="color: #660;" class="styled-by-prettify">)</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">&gt;</span><span
            style="color: #000;" class="styled-by-prettify"> x</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">rgt</span><span
            style="color: #660;" class="styled-by-prettify">)?</span><span
            style="color: #000;" class="styled-by-prettify"> &nbsp; x</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">lft</span><span
            style="color: #660;" class="styled-by-prettify">)</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">-</span><span
            style="color: #000;" class="styled-by-prettify"> x</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">rgt</span><span
            style="color: #660;" class="styled-by-prettify">):</span><span
            style="color: #000;" class="styled-by-prettify"> &nbsp; x</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">rgt</span><span
            style="color: #660;" class="styled-by-prettify">)</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">-</span><span
            style="color: #000;" class="styled-by-prettify"> x</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">lft</span><span
            style="color: #660;" class="styled-by-prettify">);</span><span
            style="color: #000;" class="styled-by-prettify"><br>
            &nbsp; &nbsp; T d_y </span><span style="color: #660;"
            class="styled-by-prettify">=</span><span style="color:
            #000;" class="styled-by-prettify"> y</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">lft</span><span
            style="color: #660;" class="styled-by-prettify">)</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">&gt;</span><span
            style="color: #000;" class="styled-by-prettify"> y</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">rgt</span><span
            style="color: #660;" class="styled-by-prettify">)?</span><span
            style="color: #000;" class="styled-by-prettify"> &nbsp; y</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">lft</span><span
            style="color: #660;" class="styled-by-prettify">)</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">-</span><span
            style="color: #000;" class="styled-by-prettify"> y</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">rgt</span><span
            style="color: #660;" class="styled-by-prettify">):</span><span
            style="color: #000;" class="styled-by-prettify"> &nbsp; y</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">rgt</span><span
            style="color: #660;" class="styled-by-prettify">)</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">-</span><span
            style="color: #000;" class="styled-by-prettify"> y</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">lft</span><span
            style="color: #660;" class="styled-by-prettify">);</span><span
            style="color: #000;" class="styled-by-prettify"><br>
            &nbsp; &nbsp; T d_z </span><span style="color: #660;"
            class="styled-by-prettify">=</span><span style="color:
            #000;" class="styled-by-prettify"> z</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">lft</span><span
            style="color: #660;" class="styled-by-prettify">)</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">&gt;</span><span
            style="color: #000;" class="styled-by-prettify"> z</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">rgt</span><span
            style="color: #660;" class="styled-by-prettify">)?</span><span
            style="color: #000;" class="styled-by-prettify"> &nbsp; z</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">lft</span><span
            style="color: #660;" class="styled-by-prettify">)</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">-</span><span
            style="color: #000;" class="styled-by-prettify"> z</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">rgt</span><span
            style="color: #660;" class="styled-by-prettify">):</span><span
            style="color: #000;" class="styled-by-prettify"> &nbsp; z</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">rgt</span><span
            style="color: #660;" class="styled-by-prettify">)</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">-</span><span
            style="color: #000;" class="styled-by-prettify"> z</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">lft</span><span
            style="color: #660;" class="styled-by-prettify">);</span><span
            style="color: #000;" class="styled-by-prettify"><br>
            <br>
            &nbsp; &nbsp; </span><span style="color: #008;"
            class="styled-by-prettify">return</span><span style="color:
            #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">d_x</span><span
            style="color: #660;" class="styled-by-prettify">*</span><span
            style="color: #000;" class="styled-by-prettify">d_x </span><span
            style="color: #660;" class="styled-by-prettify">+</span><span
            style="color: #000;" class="styled-by-prettify"> d_z</span><span
            style="color: #660;" class="styled-by-prettify">*</span><span
            style="color: #000;" class="styled-by-prettify">d_z </span><span
            style="color: #660;" class="styled-by-prettify">+</span><span
            style="color: #000;" class="styled-by-prettify"> d_y</span><span
            style="color: #660;" class="styled-by-prettify">*</span><span
            style="color: #000;" class="styled-by-prettify">d_y</span><span
            style="color: #660;" class="styled-by-prettify">);</span><span
            style="color: #000;" class="styled-by-prettify"><br>
          </span><span style="color: #660;" class="styled-by-prettify">}</span></div>
      </code></div>
    <div class="subprettyprint" style="color: rgb(102, 0, 102);
      font-family: monospace; background-color: rgb(250, 250, 250);"><br>
    </div>
    <font face="arial, sans-serif"><br>
      It is quite close to your proposed syntax, isn't it?<br>
      <br>
      <br>
    </font><font face="arial, sans-serif">Vicente</font><br>
  </body>
</html>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />

--------------010104050909010000060504--

.


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Tue, 26 Nov 2013 01:40:05 +0100
Raw View
This is a multi-part message in MIME format.
--------------050404020508020806090605
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 26/11/13 00:47, Vicente J. Botet Escriba a =E9crit :
> Le 25/11/13 22:57, theypsilon@gmail.com a =E9crit :
>>
>> Consider this:
>>
>> |
>> usingx =3Dstd::get<0>;// Proposed syntax
>> |
>>
>>
>> That new syntax, being a natural extension to the previously=20
>> commented use case, and analogous to the using declarations for=20
>> types, would make the previous code much more terse than before:
>>
>> |
>> template<classT>T distance(std::tuple<T,T,T>lft,std::tuple<T,T,T>rgt){
>> usingx =3Dstd::get<0>;
>> usingy =3Dstd::get<1>;
>> usingz =3Dstd::get<2>;
>>
>>     T d_x =3Dx(lft)>x(rgt)?  x(lft)-x(rgt):  x(rgt)-x(lft);
>>     T d_y =3Dy(lft)>y(rgt)?  y(lft)-y(rgt):  y(rgt)-y(lft);
>>     T d_z =3Dz(lft)>z(rgt)?  z(lft)-z(rgt):  z(rgt)-z(lft);
>>
>> return(d_x*d_x +d_z*d_z +d_y*d_y);
>> }
>> |
>>
>
> Hi,
>
> what about using generic lambdas
>
>
> |
> template<classT>T distance(std::tuple<T,T,T>lft,std::tuple<T,T,T>rgt){
> |    autox =3D[](auto|t|) { return std::get<0>(t); }
> ||    autoy =3D[](||||auto|||t|) { return std::get<1>(t); }
> ||    autoz =3D[](||||auto|||t|) { return std::get<2>(t); }
> |
>     T d_x =3Dx(lft)>x(rgt)?  x(lft)-x(rgt):  x(rgt)-x(lft);
>     T d_y =3Dy(lft)>y(rgt)?  y(lft)-y(rgt):  y(rgt)-y(lft);
>     T d_z =3Dz(lft)>z(rgt)?  z(lft)-z(rgt):  z(rgt)-z(lft);
>
> return(d_x*d_x +d_z*d_z +d_y*d_y);
> }
> |
>
>
> It is quite close to your proposed syntax, isn't it?
>

Boost.QVM uses a syntax that I'm sure you will appreciate=20
http://www.revergestudios.com/boost-qvm/accessing_vector_elements.html.=20
With such operations applied to tuples<T,T,T>, your example could become

|
template<classT>T distance(std::tuple<T,T,T>lft,std::tuple<T,T,T>rgt){

|    T d_x =3Dlft%X>rgt%X?lft%X-rgt%X:rgt%X-lft%X;
||    T d_y =3Dlft%Y>rgt%Y?lft%Y-rgt%Y:rgt%Y-lft%Y;
||    T d_z =3Dlft%Z>rgt%Z?lft%Z-rgt%Z:rgt%Z-lft%Z;

|
return(d_x*d_x +d_z*d_z +d_y*d_y);
}
|



Best,
Vicente

P.S.  a modulo function would help also ;-).

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--------------050404020508020806090605
Content-Type: text/html; charset=ISO-8859-1

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Le 26/11/13 00:47, Vicente J. Botet
      Escriba a &eacute;crit&nbsp;:<br>
    </div>
    <blockquote cite="mid:5293E18D.5050906@wanadoo.fr" type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      <div class="moz-cite-prefix">Le 25/11/13 22:57, <a
          moz-do-not-send="true" class="moz-txt-link-abbreviated"
          href="mailto:theypsilon@gmail.com">theypsilon@gmail.com</a> a
        &eacute;crit&nbsp;:<br>
      </div>
      <blockquote
        cite="mid:b189f899-929e-4607-986a-00088b7bce5d@isocpp.org"
        type="cite">
        <div dir="ltr"><br>
          <div>Consider this:</div>
          <div><br>
          </div>
          <div>
            <div class="prettyprint" style="background-color: rgb(250,
              250, 250); border: 1px solid rgb(187, 187, 187);
              word-wrap: break-word;"><code class="prettyprint">
                <div class="subprettyprint"><font color="#660066"><span
                      style="color: #008;" class="styled-by-prettify">using</span><span
                      style="color: #000;" class="styled-by-prettify"> x
                    </span><span style="color: #660;"
                      class="styled-by-prettify">=</span><span
                      style="color: #000;" class="styled-by-prettify">
                      std</span><span style="color: #660;"
                      class="styled-by-prettify">::</span><span
                      style="color: #008;" class="styled-by-prettify">get</span><span
                      style="color: #660;" class="styled-by-prettify">&lt;</span><span
                      style="color: #066;" class="styled-by-prettify">0</span><span
                      style="color: #660;" class="styled-by-prettify">&gt;;</span><span
                      style="color: #000;" class="styled-by-prettify"> </span><span
                      style="color: #800;" class="styled-by-prettify">//
                      Proposed syntax</span></font></div>
              </code></div>
            <div><br>
            </div>
            <br>
            That new syntax, being a natural extension to the previously
            commented use case, and analogous to the using declarations
            for types, would make the previous code much more terse than
            before:</div>
          <div><font color="#660066"><br>
            </font>
            <div class="prettyprint" style="background-color: rgb(250,
              250, 250); border: 1px solid rgb(187, 187, 187);
              word-wrap: break-word;"><code class="prettyprint">
                <div class="subprettyprint"><span style="color: #008;"
                    class="styled-by-prettify">template</span><span
                    style="color: #000;" class="styled-by-prettify"> </span><span
                    style="color: #660;" class="styled-by-prettify">&lt;</span><span
                    style="color: #008;" class="styled-by-prettify">class</span><span
                    style="color: #000;" class="styled-by-prettify"> T</span><span
                    style="color: #660;" class="styled-by-prettify">&gt;</span><span
                    style="color: #000;" class="styled-by-prettify"> T
                    distance</span><span style="color: #660;"
                    class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">std</span><span
                    style="color: #660;" class="styled-by-prettify">::</span><span
                    style="color: #000;" class="styled-by-prettify">tuple</span><span
                    style="color: #660;" class="styled-by-prettify">&lt;</span><span
                    style="color: #000;" class="styled-by-prettify">T</span><span
                    style="color: #660;" class="styled-by-prettify">,</span><span
                    style="color: #000;" class="styled-by-prettify">T</span><span
                    style="color: #660;" class="styled-by-prettify">,</span><span
                    style="color: #000;" class="styled-by-prettify">T</span><span
                    style="color: #660;" class="styled-by-prettify">&gt;</span><span
                    style="color: #000;" class="styled-by-prettify"> lft</span><span
                    style="color: #660;" class="styled-by-prettify">,</span><span
                    style="color: #000;" class="styled-by-prettify"> std</span><span
                    style="color: #660;" class="styled-by-prettify">::</span><span
                    style="color: #000;" class="styled-by-prettify">tuple</span><span
                    style="color: #660;" class="styled-by-prettify">&lt;</span><span
                    style="color: #000;" class="styled-by-prettify">T</span><span
                    style="color: #660;" class="styled-by-prettify">,</span><span
                    style="color: #000;" class="styled-by-prettify">T</span><span
                    style="color: #660;" class="styled-by-prettify">,</span><span
                    style="color: #000;" class="styled-by-prettify">T</span><span
                    style="color: #660;" class="styled-by-prettify">&gt;</span><span
                    style="color: #000;" class="styled-by-prettify"> rgt</span><span
                    style="color: #660;" class="styled-by-prettify">)</span><span
                    style="color: #000;" class="styled-by-prettify"> </span><span
                    style="color: #660;" class="styled-by-prettify">{</span><span
                    style="color: #000;" class="styled-by-prettify"><br>
                    &nbsp; &nbsp; </span><span style="color: #008;"
                    class="styled-by-prettify">using</span><span
                    style="color: #000;" class="styled-by-prettify"> x </span><span
                    style="color: #660;" class="styled-by-prettify">=</span><span
                    style="color: #000;" class="styled-by-prettify"> std</span><span
                    style="color: #660;" class="styled-by-prettify">::</span><span
                    style="color: #008;" class="styled-by-prettify">get</span><span
                    style="color: #660;" class="styled-by-prettify">&lt;</span><span
                    style="color: #066;" class="styled-by-prettify">0</span><span
                    style="color: #660;" class="styled-by-prettify">&gt;;</span><span
                    style="color: #000;" class="styled-by-prettify"> <br>
                    &nbsp; &nbsp; </span><span style="color: #008;"
                    class="styled-by-prettify">using</span><span
                    style="color: #000;" class="styled-by-prettify"> y </span><span
                    style="color: #660;" class="styled-by-prettify">=</span><span
                    style="color: #000;" class="styled-by-prettify"> std</span><span
                    style="color: #660;" class="styled-by-prettify">::</span><span
                    style="color: #008;" class="styled-by-prettify">get</span><span
                    style="color: #660;" class="styled-by-prettify">&lt;</span><span
                    style="color: #066;" class="styled-by-prettify">1</span><span
                    style="color: #660;" class="styled-by-prettify">&gt;;</span><span
                    style="color: #000;" class="styled-by-prettify"> <br>
                    &nbsp; &nbsp; </span><span style="color: #008;"
                    class="styled-by-prettify">using</span><span
                    style="color: #000;" class="styled-by-prettify"> z </span><span
                    style="color: #660;" class="styled-by-prettify">=</span><span
                    style="color: #000;" class="styled-by-prettify"> std</span><span
                    style="color: #660;" class="styled-by-prettify">::</span><span
                    style="color: #008;" class="styled-by-prettify">get</span><span
                    style="color: #660;" class="styled-by-prettify">&lt;</span><span
                    style="color: #066;" class="styled-by-prettify">2</span><span
                    style="color: #660;" class="styled-by-prettify">&gt;;</span><span
                    style="color: #000;" class="styled-by-prettify"><br>
                    <br>
                    &nbsp; &nbsp; T d_x </span><span style="color: #660;"
                    class="styled-by-prettify">=</span><span
                    style="color: #000;" class="styled-by-prettify"> x</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">lft</span><span
                    style="color: #660;" class="styled-by-prettify">)</span><span
                    style="color: #000;" class="styled-by-prettify"> </span><span
                    style="color: #660;" class="styled-by-prettify">&gt;</span><span
                    style="color: #000;" class="styled-by-prettify"> x</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">rgt</span><span
                    style="color: #660;" class="styled-by-prettify">)?</span><span
                    style="color: #000;" class="styled-by-prettify"> &nbsp; x</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">lft</span><span
                    style="color: #660;" class="styled-by-prettify">)</span><span
                    style="color: #000;" class="styled-by-prettify"> </span><span
                    style="color: #660;" class="styled-by-prettify">-</span><span
                    style="color: #000;" class="styled-by-prettify"> x</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">rgt</span><span
                    style="color: #660;" class="styled-by-prettify">):</span><span
                    style="color: #000;" class="styled-by-prettify"> &nbsp; x</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">rgt</span><span
                    style="color: #660;" class="styled-by-prettify">)</span><span
                    style="color: #000;" class="styled-by-prettify"> </span><span
                    style="color: #660;" class="styled-by-prettify">-</span><span
                    style="color: #000;" class="styled-by-prettify"> x</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">lft</span><span
                    style="color: #660;" class="styled-by-prettify">);</span><span
                    style="color: #000;" class="styled-by-prettify"><br>
                    &nbsp; &nbsp; T d_y </span><span style="color: #660;"
                    class="styled-by-prettify">=</span><span
                    style="color: #000;" class="styled-by-prettify"> y</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">lft</span><span
                    style="color: #660;" class="styled-by-prettify">)</span><span
                    style="color: #000;" class="styled-by-prettify"> </span><span
                    style="color: #660;" class="styled-by-prettify">&gt;</span><span
                    style="color: #000;" class="styled-by-prettify"> y</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">rgt</span><span
                    style="color: #660;" class="styled-by-prettify">)?</span><span
                    style="color: #000;" class="styled-by-prettify"> &nbsp; y</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">lft</span><span
                    style="color: #660;" class="styled-by-prettify">)</span><span
                    style="color: #000;" class="styled-by-prettify"> </span><span
                    style="color: #660;" class="styled-by-prettify">-</span><span
                    style="color: #000;" class="styled-by-prettify"> y</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">rgt</span><span
                    style="color: #660;" class="styled-by-prettify">):</span><span
                    style="color: #000;" class="styled-by-prettify"> &nbsp; y</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">rgt</span><span
                    style="color: #660;" class="styled-by-prettify">)</span><span
                    style="color: #000;" class="styled-by-prettify"> </span><span
                    style="color: #660;" class="styled-by-prettify">-</span><span
                    style="color: #000;" class="styled-by-prettify"> y</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">lft</span><span
                    style="color: #660;" class="styled-by-prettify">);</span><span
                    style="color: #000;" class="styled-by-prettify"><br>
                    &nbsp; &nbsp; T d_z </span><span style="color: #660;"
                    class="styled-by-prettify">=</span><span
                    style="color: #000;" class="styled-by-prettify"> z</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">lft</span><span
                    style="color: #660;" class="styled-by-prettify">)</span><span
                    style="color: #000;" class="styled-by-prettify"> </span><span
                    style="color: #660;" class="styled-by-prettify">&gt;</span><span
                    style="color: #000;" class="styled-by-prettify"> z</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">rgt</span><span
                    style="color: #660;" class="styled-by-prettify">)?</span><span
                    style="color: #000;" class="styled-by-prettify"> &nbsp; z</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">lft</span><span
                    style="color: #660;" class="styled-by-prettify">)</span><span
                    style="color: #000;" class="styled-by-prettify"> </span><span
                    style="color: #660;" class="styled-by-prettify">-</span><span
                    style="color: #000;" class="styled-by-prettify"> z</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">rgt</span><span
                    style="color: #660;" class="styled-by-prettify">):</span><span
                    style="color: #000;" class="styled-by-prettify"> &nbsp; z</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">rgt</span><span
                    style="color: #660;" class="styled-by-prettify">)</span><span
                    style="color: #000;" class="styled-by-prettify"> </span><span
                    style="color: #660;" class="styled-by-prettify">-</span><span
                    style="color: #000;" class="styled-by-prettify"> z</span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">lft</span><span
                    style="color: #660;" class="styled-by-prettify">);</span><span
                    style="color: #000;" class="styled-by-prettify"><br>
                    <br>
                    &nbsp; &nbsp; </span><span style="color: #008;"
                    class="styled-by-prettify">return</span><span
                    style="color: #000;" class="styled-by-prettify"> </span><span
                    style="color: #660;" class="styled-by-prettify">(</span><span
                    style="color: #000;" class="styled-by-prettify">d_x</span><span
                    style="color: #660;" class="styled-by-prettify">*</span><span
                    style="color: #000;" class="styled-by-prettify">d_x
                  </span><span style="color: #660;"
                    class="styled-by-prettify">+</span><span
                    style="color: #000;" class="styled-by-prettify"> d_z</span><span
                    style="color: #660;" class="styled-by-prettify">*</span><span
                    style="color: #000;" class="styled-by-prettify">d_z
                  </span><span style="color: #660;"
                    class="styled-by-prettify">+</span><span
                    style="color: #000;" class="styled-by-prettify"> d_y</span><span
                    style="color: #660;" class="styled-by-prettify">*</span><span
                    style="color: #000;" class="styled-by-prettify">d_y</span><span
                    style="color: #660;" class="styled-by-prettify">);</span><span
                    style="color: #000;" class="styled-by-prettify"><br>
                  </span><span style="color: #660;"
                    class="styled-by-prettify">}</span></div>
              </code></div>
            <div class="subprettyprint" style="color: rgb(102, 0, 102);
              font-family: monospace; background-color: rgb(250, 250,
              250);"><br>
            </div>
          </div>
        </div>
      </blockquote>
      <br>
      <font face="arial, sans-serif">Hi,<br>
        <br>
        what about using generic lambdas<br>
        <br>
      </font><br>
      <div class="prettyprint" style="background-color: rgb(250, 250,
        250); border: 1px solid rgb(187, 187, 187); word-wrap:
        break-word;"><code class="prettyprint">
          <div class="subprettyprint"><span style="color: #008;"
              class="styled-by-prettify">template</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">&lt;</span><span
              style="color: #008;" class="styled-by-prettify">class</span><span
              style="color: #000;" class="styled-by-prettify"> T</span><span
              style="color: #660;" class="styled-by-prettify">&gt;</span><span
              style="color: #000;" class="styled-by-prettify"> T
              distance</span><span style="color: #660;"
              class="styled-by-prettify">(</span><span style="color:
              #000;" class="styled-by-prettify">std</span><span
              style="color: #660;" class="styled-by-prettify">::</span><span
              style="color: #000;" class="styled-by-prettify">tuple</span><span
              style="color: #660;" class="styled-by-prettify">&lt;</span><span
              style="color: #000;" class="styled-by-prettify">T</span><span
              style="color: #660;" class="styled-by-prettify">,</span><span
              style="color: #000;" class="styled-by-prettify">T</span><span
              style="color: #660;" class="styled-by-prettify">,</span><span
              style="color: #000;" class="styled-by-prettify">T</span><span
              style="color: #660;" class="styled-by-prettify">&gt;</span><span
              style="color: #000;" class="styled-by-prettify"> lft</span><span
              style="color: #660;" class="styled-by-prettify">,</span><span
              style="color: #000;" class="styled-by-prettify"> std</span><span
              style="color: #660;" class="styled-by-prettify">::</span><span
              style="color: #000;" class="styled-by-prettify">tuple</span><span
              style="color: #660;" class="styled-by-prettify">&lt;</span><span
              style="color: #000;" class="styled-by-prettify">T</span><span
              style="color: #660;" class="styled-by-prettify">,</span><span
              style="color: #000;" class="styled-by-prettify">T</span><span
              style="color: #660;" class="styled-by-prettify">,</span><span
              style="color: #000;" class="styled-by-prettify">T</span><span
              style="color: #660;" class="styled-by-prettify">&gt;</span><span
              style="color: #000;" class="styled-by-prettify"> rgt</span><span
              style="color: #660;" class="styled-by-prettify">)</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">{</span><span
              style="color: #000;" class="styled-by-prettify"><br>
            </span><code class="prettyprint"><span style="color: #000;"
                class="styled-by-prettify">&nbsp; &nbsp; auto</span><span
                style="color: #000;" class="styled-by-prettify"> x </span><span
                style="color: #660;" class="styled-by-prettify">=</span><span
                style="color: #000;" class="styled-by-prettify"> [](auto</span><span
                style="color: #000;" class="styled-by-prettify"><code
                  class="prettyprint"><span style="color: #660;"
                    class="styled-by-prettify"> t</span></code>) {
                return std</span><span style="color: #660;"
                class="styled-by-prettify">::</span><span style="color:
                #008;" class="styled-by-prettify">get</span><span
                style="color: #660;" class="styled-by-prettify">&lt;</span><span
                style="color: #066;" class="styled-by-prettify">0</span><span
                style="color: #660;" class="styled-by-prettify">&gt;(t);
                }</span><span style="color: #000;"
                class="styled-by-prettify"> <br>
              </span></code><code class="prettyprint"><span
                style="color: #000;" class="styled-by-prettify">&nbsp; &nbsp; auto</span><span
                style="color: #000;" class="styled-by-prettify"> y </span><span
                style="color: #660;" class="styled-by-prettify">=</span><span
                style="color: #000;" class="styled-by-prettify"> [](</span></code><code
              class="prettyprint"><span style="color: #000;"
                class="styled-by-prettify"><code class="prettyprint"><code
                    class="prettyprint"><span style="color: #000;"
                      class="styled-by-prettify">auto</span></code></code></span><span
                style="color: #000;" class="styled-by-prettify"><code
                  class="prettyprint"><span style="color: #660;"
                    class="styled-by-prettify"> t</span></code>) {
                return std</span><span style="color: #660;"
                class="styled-by-prettify">::</span><span style="color:
                #008;" class="styled-by-prettify">get</span><span
                style="color: #660;" class="styled-by-prettify">&lt;</span><span
                style="color: #066;" class="styled-by-prettify">1</span><span
                style="color: #660;" class="styled-by-prettify">&gt;(t);
                }</span><span style="color: #000;"
                class="styled-by-prettify"> <br>
              </span></code><code class="prettyprint"><span
                style="color: #000;" class="styled-by-prettify">&nbsp; &nbsp; auto</span><span
                style="color: #000;" class="styled-by-prettify"> z </span><span
                style="color: #660;" class="styled-by-prettify">=</span><span
                style="color: #000;" class="styled-by-prettify"> [](</span></code><code
              class="prettyprint"><span style="color: #000;"
                class="styled-by-prettify"><code class="prettyprint"><code
                    class="prettyprint"><span style="color: #000;"
                      class="styled-by-prettify">auto</span></code></code></span><span
                style="color: #000;" class="styled-by-prettify"><code
                  class="prettyprint"><span style="color: #660;"
                    class="styled-by-prettify"> t</span></code>) {
                return std</span><span style="color: #660;"
                class="styled-by-prettify">::</span><span style="color:
                #008;" class="styled-by-prettify">get</span><span
                style="color: #660;" class="styled-by-prettify">&lt;</span><span
                style="color: #066;" class="styled-by-prettify">2</span><span
                style="color: #660;" class="styled-by-prettify">&gt;(t);
                }</span><span style="color: #000;"
                class="styled-by-prettify"> <br>
              </span></code><span style="color: #000;"
              class="styled-by-prettify"><br>
              &nbsp; &nbsp; T d_x </span><span style="color: #660;"
              class="styled-by-prettify">=</span><span style="color:
              #000;" class="styled-by-prettify"> x</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">lft</span><span
              style="color: #660;" class="styled-by-prettify">)</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">&gt;</span><span
              style="color: #000;" class="styled-by-prettify"> x</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">rgt</span><span
              style="color: #660;" class="styled-by-prettify">)?</span><span
              style="color: #000;" class="styled-by-prettify"> &nbsp; x</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">lft</span><span
              style="color: #660;" class="styled-by-prettify">)</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">-</span><span
              style="color: #000;" class="styled-by-prettify"> x</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">rgt</span><span
              style="color: #660;" class="styled-by-prettify">):</span><span
              style="color: #000;" class="styled-by-prettify"> &nbsp; x</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">rgt</span><span
              style="color: #660;" class="styled-by-prettify">)</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">-</span><span
              style="color: #000;" class="styled-by-prettify"> x</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">lft</span><span
              style="color: #660;" class="styled-by-prettify">);</span><span
              style="color: #000;" class="styled-by-prettify"><br>
              &nbsp; &nbsp; T d_y </span><span style="color: #660;"
              class="styled-by-prettify">=</span><span style="color:
              #000;" class="styled-by-prettify"> y</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">lft</span><span
              style="color: #660;" class="styled-by-prettify">)</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">&gt;</span><span
              style="color: #000;" class="styled-by-prettify"> y</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">rgt</span><span
              style="color: #660;" class="styled-by-prettify">)?</span><span
              style="color: #000;" class="styled-by-prettify"> &nbsp; y</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">lft</span><span
              style="color: #660;" class="styled-by-prettify">)</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">-</span><span
              style="color: #000;" class="styled-by-prettify"> y</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">rgt</span><span
              style="color: #660;" class="styled-by-prettify">):</span><span
              style="color: #000;" class="styled-by-prettify"> &nbsp; y</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">rgt</span><span
              style="color: #660;" class="styled-by-prettify">)</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">-</span><span
              style="color: #000;" class="styled-by-prettify"> y</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">lft</span><span
              style="color: #660;" class="styled-by-prettify">);</span><span
              style="color: #000;" class="styled-by-prettify"><br>
              &nbsp; &nbsp; T d_z </span><span style="color: #660;"
              class="styled-by-prettify">=</span><span style="color:
              #000;" class="styled-by-prettify"> z</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">lft</span><span
              style="color: #660;" class="styled-by-prettify">)</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">&gt;</span><span
              style="color: #000;" class="styled-by-prettify"> z</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">rgt</span><span
              style="color: #660;" class="styled-by-prettify">)?</span><span
              style="color: #000;" class="styled-by-prettify"> &nbsp; z</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">lft</span><span
              style="color: #660;" class="styled-by-prettify">)</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">-</span><span
              style="color: #000;" class="styled-by-prettify"> z</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">rgt</span><span
              style="color: #660;" class="styled-by-prettify">):</span><span
              style="color: #000;" class="styled-by-prettify"> &nbsp; z</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">rgt</span><span
              style="color: #660;" class="styled-by-prettify">)</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">-</span><span
              style="color: #000;" class="styled-by-prettify"> z</span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">lft</span><span
              style="color: #660;" class="styled-by-prettify">);</span><span
              style="color: #000;" class="styled-by-prettify"><br>
              <br>
              &nbsp; &nbsp; </span><span style="color: #008;"
              class="styled-by-prettify">return</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">(</span><span
              style="color: #000;" class="styled-by-prettify">d_x</span><span
              style="color: #660;" class="styled-by-prettify">*</span><span
              style="color: #000;" class="styled-by-prettify">d_x </span><span
              style="color: #660;" class="styled-by-prettify">+</span><span
              style="color: #000;" class="styled-by-prettify"> d_z</span><span
              style="color: #660;" class="styled-by-prettify">*</span><span
              style="color: #000;" class="styled-by-prettify">d_z </span><span
              style="color: #660;" class="styled-by-prettify">+</span><span
              style="color: #000;" class="styled-by-prettify"> d_y</span><span
              style="color: #660;" class="styled-by-prettify">*</span><span
              style="color: #000;" class="styled-by-prettify">d_y</span><span
              style="color: #660;" class="styled-by-prettify">);</span><span
              style="color: #000;" class="styled-by-prettify"><br>
            </span><span style="color: #660;" class="styled-by-prettify">}</span></div>
        </code></div>
      <div class="subprettyprint" style="color: rgb(102, 0, 102);
        font-family: monospace; background-color: rgb(250, 250, 250);"><br>
      </div>
      <font face="arial, sans-serif"><br>
        It is quite close to your proposed syntax, isn't it?<br>
      </font><br>
    </blockquote>
    <br>
    Boost.QVM uses a syntax that I'm sure you will appreciate
    <a class="moz-txt-link-freetext" href="http://www.revergestudios.com/boost-qvm/accessing_vector_elements.html">http://www.revergestudios.com/boost-qvm/accessing_vector_elements.html</a>.
    With such operations applied to tuples&lt;T,T,T&gt;, your example
    could become<br>
    <br>
    <div class="prettyprint" style="background-color: rgb(250, 250,
      250); border: 1px solid rgb(187, 187, 187); word-wrap:
      break-word;"><code class="prettyprint">
        <div class="subprettyprint"><span style="color: #008;"
            class="styled-by-prettify">template</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">&lt;</span><span
            style="color: #008;" class="styled-by-prettify">class</span><span
            style="color: #000;" class="styled-by-prettify"> T</span><span
            style="color: #660;" class="styled-by-prettify">&gt;</span><span
            style="color: #000;" class="styled-by-prettify"> T distance</span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">std</span><span
            style="color: #660;" class="styled-by-prettify">::</span><span
            style="color: #000;" class="styled-by-prettify">tuple</span><span
            style="color: #660;" class="styled-by-prettify">&lt;</span><span
            style="color: #000;" class="styled-by-prettify">T</span><span
            style="color: #660;" class="styled-by-prettify">,</span><span
            style="color: #000;" class="styled-by-prettify">T</span><span
            style="color: #660;" class="styled-by-prettify">,</span><span
            style="color: #000;" class="styled-by-prettify">T</span><span
            style="color: #660;" class="styled-by-prettify">&gt;</span><span
            style="color: #000;" class="styled-by-prettify"> lft</span><span
            style="color: #660;" class="styled-by-prettify">,</span><span
            style="color: #000;" class="styled-by-prettify"> std</span><span
            style="color: #660;" class="styled-by-prettify">::</span><span
            style="color: #000;" class="styled-by-prettify">tuple</span><span
            style="color: #660;" class="styled-by-prettify">&lt;</span><span
            style="color: #000;" class="styled-by-prettify">T</span><span
            style="color: #660;" class="styled-by-prettify">,</span><span
            style="color: #000;" class="styled-by-prettify">T</span><span
            style="color: #660;" class="styled-by-prettify">,</span><span
            style="color: #000;" class="styled-by-prettify">T</span><span
            style="color: #660;" class="styled-by-prettify">&gt;</span><span
            style="color: #000;" class="styled-by-prettify"> rgt</span><span
            style="color: #660;" class="styled-by-prettify">)</span><span
            style="color: #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">{</span><span
            style="color: #000;" class="styled-by-prettify"><br>
          </span><span style="color: #000;" class="styled-by-prettify"><br>
          </span><code class="prettyprint"><span style="color: #000;"
              class="styled-by-prettify"> &nbsp; &nbsp; T d_x </span><span
              style="color: #660;" class="styled-by-prettify">=</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #000;" class="styled-by-prettify">lft%X</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">&gt;</span><span
              style="color: #000;" class="styled-by-prettify">&nbsp;</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify">rgt%X</span><span
              style="color: #660;" class="styled-by-prettify">?</span><span
              style="color: #000;" class="styled-by-prettify"> &nbsp; </span><span
              style="color: #000;" class="styled-by-prettify">lft%X</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">-</span><span
              style="color: #000;" class="styled-by-prettify">&nbsp;</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify">rgt%X</span><span
              style="color: #660;" class="styled-by-prettify">:</span><span
              style="color: #000;" class="styled-by-prettify"> &nbsp;&nbsp;</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify">rgt</span>%X<span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">-</span><span
              style="color: #000;" class="styled-by-prettify">&nbsp;</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify">lft%X</span><span
              style="color: #660;" class="styled-by-prettify">;</span><span
              style="color: #000;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify"><br>
            </span></code><code class="prettyprint"><span style="color:
              #000;" class="styled-by-prettify"> &nbsp; &nbsp; T d_y </span><span
              style="color: #660;" class="styled-by-prettify">=</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #000;" class="styled-by-prettify">lft%Y</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">&gt;</span><span
              style="color: #000;" class="styled-by-prettify">&nbsp;</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify">rgt%Y</span><span
              style="color: #660;" class="styled-by-prettify">?</span><span
              style="color: #000;" class="styled-by-prettify"> &nbsp; </span><span
              style="color: #000;" class="styled-by-prettify">lft%Y</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">-</span><span
              style="color: #000;" class="styled-by-prettify">&nbsp;</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify">rgt%Y</span><span
              style="color: #660;" class="styled-by-prettify">:</span><span
              style="color: #000;" class="styled-by-prettify"> &nbsp;&nbsp;</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify">rgt</span>%Y<span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">-</span><span
              style="color: #000;" class="styled-by-prettify">&nbsp;</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify">lft%Y</span><span
              style="color: #660;" class="styled-by-prettify">;</span><span
              style="color: #000;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify"><br>
            </span></code><code class="prettyprint"><span style="color:
              #000;" class="styled-by-prettify"> &nbsp; &nbsp; T d_z </span><span
              style="color: #660;" class="styled-by-prettify">=</span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #000;" class="styled-by-prettify">lft%Z</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">&gt;</span><span
              style="color: #000;" class="styled-by-prettify">&nbsp;</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify">rgt%Z</span><span
              style="color: #660;" class="styled-by-prettify">?</span><span
              style="color: #000;" class="styled-by-prettify"> &nbsp; </span><span
              style="color: #000;" class="styled-by-prettify">lft%Z</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">-</span><span
              style="color: #000;" class="styled-by-prettify">&nbsp;</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify">rgt%Z</span><span
              style="color: #660;" class="styled-by-prettify">:</span><span
              style="color: #000;" class="styled-by-prettify"> &nbsp;&nbsp;</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify">rgt</span>%Z<span
              style="color: #000;" class="styled-by-prettify"> </span><span
              style="color: #660;" class="styled-by-prettify">-</span><span
              style="color: #000;" class="styled-by-prettify">&nbsp;</span><span
              style="color: #660;" class="styled-by-prettify"></span><span
              style="color: #000;" class="styled-by-prettify">lft%Z</span><span
              style="color: #660;" class="styled-by-prettify">;</span><span
              style="color: #000;" class="styled-by-prettify"><br>
            </span><span style="color: #000;" class="styled-by-prettify"><br>
            </span></code><span style="color: #000;"
            class="styled-by-prettify"><br>
            &nbsp; &nbsp; </span><span style="color: #008;"
            class="styled-by-prettify">return</span><span style="color:
            #000;" class="styled-by-prettify"> </span><span
            style="color: #660;" class="styled-by-prettify">(</span><span
            style="color: #000;" class="styled-by-prettify">d_x</span><span
            style="color: #660;" class="styled-by-prettify">*</span><span
            style="color: #000;" class="styled-by-prettify">d_x </span><span
            style="color: #660;" class="styled-by-prettify">+</span><span
            style="color: #000;" class="styled-by-prettify"> d_z</span><span
            style="color: #660;" class="styled-by-prettify">*</span><span
            style="color: #000;" class="styled-by-prettify">d_z </span><span
            style="color: #660;" class="styled-by-prettify">+</span><span
            style="color: #000;" class="styled-by-prettify"> d_y</span><span
            style="color: #660;" class="styled-by-prettify">*</span><span
            style="color: #000;" class="styled-by-prettify">d_y</span><span
            style="color: #660;" class="styled-by-prettify">);</span><span
            style="color: #000;" class="styled-by-prettify"><br>
          </span><span style="color: #660;" class="styled-by-prettify">}</span></div>
      </code></div>
    <div class="subprettyprint" style="color: rgb(102, 0, 102);
      font-family: monospace; background-color: rgb(250, 250, 250);"><br>
    </div>
    <font face="arial, sans-serif"><br>
      <br>
    </font>Best,<br>
    Vicente<br>
    <br>
    <font face="arial, sans-serif">P.S.&nbsp; a modulo function would help
      also ;-).<br>
    </font><br>
  </body>
</html>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />

--------------050404020508020806090605--

.


Author: Richard Smith <richard@metafoo.co.uk>
Date: Mon, 25 Nov 2013 17:10:26 -0800
Raw View
--047d7b6dc22448686204ec0a2508
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Mon, Nov 25, 2013 at 4:40 PM, Vicente J. Botet Escriba <
vicente.botet@wanadoo.fr> wrote:

>  Le 26/11/13 00:47, Vicente J. Botet Escriba a =E9crit :
>
> Le 25/11/13 22:57, theypsilon@gmail.com a =E9crit :
>
>
> Consider this:
>
>   using x =3D std::get<0>; // Proposed syntax
>
>
> That new syntax, being a natural extension to the previously commented us=
e
> case, and analogous to the using declarations for types, would make the
> previous code much more terse than before:
>
>  template <class T> T distance(std::tuple<T,T,T> lft, std::tuple<T,T,T>rg=
t
> ) {
>     using x =3D std::get<0>;
>     using y =3D std::get<1>;
>     using z =3D std::get<2>;
>
>     T d_x =3D x(lft) > x(rgt)?   x(lft) - x(rgt):   x(rgt) - x(lft);
>     T d_y =3D y(lft) > y(rgt)?   y(lft) - y(rgt):   y(rgt) - y(lft);
>     T d_z =3D z(lft) > z(rgt)?   z(lft) - z(rgt):   z(rgt) - z(lft);
>
>     return (d_x*d_x + d_z*d_z + d_y*d_y);
> }
>
>
> Hi,
>
> what about using generic lambdas
>
>
>  template <class T> T distance(std::tuple<T,T,T> lft, std::tuple<T,T,T>rg=
t
> ) {
>     auto x =3D [](auto t) { return std::get<0>(t); }
>     auto y =3D [](auto t) { return std::get<1>(t); }
>     auto z =3D [](auto t) { return std::get<2>(t); }
>
>     T d_x =3D x(lft) > x(rgt)?   x(lft) - x(rgt):   x(rgt) - x(lft);
>     T d_y =3D y(lft) > y(rgt)?   y(lft) - y(rgt):   y(rgt) - y(lft);
>     T d_z =3D z(lft) > z(rgt)?   z(lft) - z(rgt):   z(rgt) - z(lft);
>
>     return (d_x*d_x + d_z*d_z + d_y*d_y);
> }
>
>
> It is quite close to your proposed syntax, isn't it?
>
>
> Boost.QVM uses a syntax that I'm sure you will appreciate
> http://www.revergestudios.com/boost-qvm/accessing_vector_elements.html.
> With such operations applied to tuples<T,T,T>, your example could become
>
>  template <class T> T distance(std::tuple<T,T,T> lft, std::tuple<T,T,T>rg=
t
> ) {
>
>      T d_x =3D lft%X > rgt%X?   lft%X - rgt%X:   rgt%X - lft%X;
>      T d_y =3D lft%Y > rgt%Y?   lft%Y - rgt%Y:   rgt%Y - lft%Y;
>      T d_z =3D lft%Z > rgt%Z?   lft%Z - rgt%Z:   rgt%Z - lft%Z;
>
>
>     return (d_x*d_x + d_z*d_z + d_y*d_y);
> }
>
>
>
How about something like:

template<unsigned N> using n =3D std::integral_constant<unsigned, N>;
template<typename T> T distance(std::tuple<T, T, T> lft, std::tuple<T, T,
T> rgt) {
  auto d2 =3D [&](auto dir) {
    T l =3D std::get<dir()>(lft), r =3D std::get<dir()>(rgt);
    T d =3D l > r ? l - r : r - l;
    return d * d;
  }
  return d2(n<0>()) + d2(n<1>()) + d2(n<2>());
}


> Best,
> Vicente
>
> P.S.  a modulo function would help also ;-).
>
>  --
>
> ---
> 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/.
>

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--047d7b6dc22448686204ec0a2508
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Mon, Nov 25, 2013 at 4:40 PM, Vicente J. Botet Escriba =
<span dir=3D"ltr">&lt;<a href=3D"mailto:vicente.botet@wanadoo.fr" target=3D=
"_blank">vicente.botet@wanadoo.fr</a>&gt;</span> wrote:<br><div class=3D"gm=
ail_extra">
<div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margi=
n:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204=
);border-left-style:solid;padding-left:1ex">
 =20
   =20
 =20
  <div text=3D"#000000" bgcolor=3D"#FFFFFF">
    <div>Le 26/11/13 00:47, Vicente J. Botet
      Escriba a =E9crit=A0:<br>
    </div>
    <blockquote type=3D"cite"><div class=3D"im">
     =20
      <div>Le 25/11/13 22:57, <a href=3D"mailto:theypsilon@gmail.com" targe=
t=3D"_blank">theypsilon@gmail.com</a> a
        =E9crit=A0:<br>
      </div>
      </div><blockquote type=3D"cite">
        <div dir=3D"ltr"><br><div class=3D"im">
          <div>Consider this:</div>
          <div><br>
          </div>
          <div>
            <div style=3D"background-color:rgb(250,250,250);border:1px soli=
d rgb(187,187,187);word-wrap:break-word"><code>
                <div><font color=3D"#660066"><span style=3D"color:rgb(0,0,1=
36)">using</span><span style> x
                    </span><span style=3D"color:rgb(102,102,0)">=3D</span><=
span style>
                      std</span><span style=3D"color:rgb(102,102,0)">::</sp=
an><span style=3D"color:rgb(0,0,136)">get</span><span style=3D"color:rgb(10=
2,102,0)">&lt;</span><span style=3D"color:rgb(0,102,102)">0</span><span sty=
le=3D"color:rgb(102,102,0)">&gt;;</span><span style> </span><span style=3D"=
color:rgb(136,0,0)">//
                      Proposed syntax</span></font></div>
              </code></div>
            <div><br>
            </div>
            <br>
            That new syntax, being a natural extension to the previously
            commented use case, and analogous to the using declarations
            for types, would make the previous code much more terse than
            before:</div>
          <div><font color=3D"#660066"><br>
            </font>
            <div style=3D"background-color:rgb(250,250,250);border:1px soli=
d rgb(187,187,187);word-wrap:break-word"><code>
                <div><span style=3D"color:rgb(0,0,136)">template</span><spa=
n style> </span><span style=3D"color:rgb(102,102,0)">&lt;</span><span style=
=3D"color:rgb(0,0,136)">class</span><span style> T</span><span style=3D"col=
or:rgb(102,102,0)">&gt;</span><span style> T
                    distance</span><span style=3D"color:rgb(102,102,0)">(</=
span><span style>std</span><span style=3D"color:rgb(102,102,0)">::</span><s=
pan style>tuple</span><span style=3D"color:rgb(102,102,0)">&lt;</span><span=
 style>T</span><span style=3D"color:rgb(102,102,0)">,</span><span style>T</=
span><span style=3D"color:rgb(102,102,0)">,</span><span style>T</span><span=
 style=3D"color:rgb(102,102,0)">&gt;</span><span style> lft</span><span sty=
le=3D"color:rgb(102,102,0)">,</span><span style> std</span><span style=3D"c=
olor:rgb(102,102,0)">::</span><span style>tuple</span><span style=3D"color:=
rgb(102,102,0)">&lt;</span><span style>T</span><span style=3D"color:rgb(102=
,102,0)">,</span><span style>T</span><span style=3D"color:rgb(102,102,0)">,=
</span><span style>T</span><span style=3D"color:rgb(102,102,0)">&gt;</span>=
<span style> rgt</span><span style=3D"color:rgb(102,102,0)">)</span><span s=
tyle> </span><span style=3D"color:rgb(102,102,0)">{</span><span style><br>

                    =A0 =A0 </span><span style=3D"color:rgb(0,0,136)">using=
</span><span style> x </span><span style=3D"color:rgb(102,102,0)">=3D</span=
><span style> std</span><span style=3D"color:rgb(102,102,0)">::</span><span=
 style=3D"color:rgb(0,0,136)">get</span><span style=3D"color:rgb(102,102,0)=
">&lt;</span><span style=3D"color:rgb(0,102,102)">0</span><span style=3D"co=
lor:rgb(102,102,0)">&gt;;</span><span style> <br>

                    =A0 =A0 </span><span style=3D"color:rgb(0,0,136)">using=
</span><span style> y </span><span style=3D"color:rgb(102,102,0)">=3D</span=
><span style> std</span><span style=3D"color:rgb(102,102,0)">::</span><span=
 style=3D"color:rgb(0,0,136)">get</span><span style=3D"color:rgb(102,102,0)=
">&lt;</span><span style=3D"color:rgb(0,102,102)">1</span><span style=3D"co=
lor:rgb(102,102,0)">&gt;;</span><span style> <br>

                    =A0 =A0 </span><span style=3D"color:rgb(0,0,136)">using=
</span><span style> z </span><span style=3D"color:rgb(102,102,0)">=3D</span=
><span style> std</span><span style=3D"color:rgb(102,102,0)">::</span><span=
 style=3D"color:rgb(0,0,136)">get</span><span style=3D"color:rgb(102,102,0)=
">&lt;</span><span style=3D"color:rgb(0,102,102)">2</span><span style=3D"co=
lor:rgb(102,102,0)">&gt;;</span><span style><br>

                    <br>
                    =A0 =A0 T d_x </span><span style=3D"color:rgb(102,102,0=
)">=3D</span><span style> x</span><span style=3D"color:rgb(102,102,0)">(</s=
pan><span style>lft</span><span style=3D"color:rgb(102,102,0)">)</span><spa=
n style> </span><span style=3D"color:rgb(102,102,0)">&gt;</span><span style=
> x</span><span style=3D"color:rgb(102,102,0)">(</span><span style>rgt</spa=
n><span style=3D"color:rgb(102,102,0)">)?</span><span style> =A0 x</span><s=
pan style=3D"color:rgb(102,102,0)">(</span><span style>lft</span><span styl=
e=3D"color:rgb(102,102,0)">)</span><span style> </span><span style=3D"color=
:rgb(102,102,0)">-</span><span style> x</span><span style=3D"color:rgb(102,=
102,0)">(</span><span style>rgt</span><span style=3D"color:rgb(102,102,0)">=
):</span><span style> =A0 x</span><span style=3D"color:rgb(102,102,0)">(</s=
pan><span style>rgt</span><span style=3D"color:rgb(102,102,0)">)</span><spa=
n style> </span><span style=3D"color:rgb(102,102,0)">-</span><span style> x=
</span><span style=3D"color:rgb(102,102,0)">(</span><span style>lft</span><=
span style=3D"color:rgb(102,102,0)">);</span><span style><br>

                    =A0 =A0 T d_y </span><span style=3D"color:rgb(102,102,0=
)">=3D</span><span style> y</span><span style=3D"color:rgb(102,102,0)">(</s=
pan><span style>lft</span><span style=3D"color:rgb(102,102,0)">)</span><spa=
n style> </span><span style=3D"color:rgb(102,102,0)">&gt;</span><span style=
> y</span><span style=3D"color:rgb(102,102,0)">(</span><span style>rgt</spa=
n><span style=3D"color:rgb(102,102,0)">)?</span><span style> =A0 y</span><s=
pan style=3D"color:rgb(102,102,0)">(</span><span style>lft</span><span styl=
e=3D"color:rgb(102,102,0)">)</span><span style> </span><span style=3D"color=
:rgb(102,102,0)">-</span><span style> y</span><span style=3D"color:rgb(102,=
102,0)">(</span><span style>rgt</span><span style=3D"color:rgb(102,102,0)">=
):</span><span style> =A0 y</span><span style=3D"color:rgb(102,102,0)">(</s=
pan><span style>rgt</span><span style=3D"color:rgb(102,102,0)">)</span><spa=
n style> </span><span style=3D"color:rgb(102,102,0)">-</span><span style> y=
</span><span style=3D"color:rgb(102,102,0)">(</span><span style>lft</span><=
span style=3D"color:rgb(102,102,0)">);</span><span style><br>

                    =A0 =A0 T d_z </span><span style=3D"color:rgb(102,102,0=
)">=3D</span><span style> z</span><span style=3D"color:rgb(102,102,0)">(</s=
pan><span style>lft</span><span style=3D"color:rgb(102,102,0)">)</span><spa=
n style> </span><span style=3D"color:rgb(102,102,0)">&gt;</span><span style=
> z</span><span style=3D"color:rgb(102,102,0)">(</span><span style>rgt</spa=
n><span style=3D"color:rgb(102,102,0)">)?</span><span style> =A0 z</span><s=
pan style=3D"color:rgb(102,102,0)">(</span><span style>lft</span><span styl=
e=3D"color:rgb(102,102,0)">)</span><span style> </span><span style=3D"color=
:rgb(102,102,0)">-</span><span style> z</span><span style=3D"color:rgb(102,=
102,0)">(</span><span style>rgt</span><span style=3D"color:rgb(102,102,0)">=
):</span><span style> =A0 z</span><span style=3D"color:rgb(102,102,0)">(</s=
pan><span style>rgt</span><span style=3D"color:rgb(102,102,0)">)</span><spa=
n style> </span><span style=3D"color:rgb(102,102,0)">-</span><span style> z=
</span><span style=3D"color:rgb(102,102,0)">(</span><span style>lft</span><=
span style=3D"color:rgb(102,102,0)">);</span><span style><br>

                    <br>
                    =A0 =A0 </span><span style=3D"color:rgb(0,0,136)">retur=
n</span><span style> </span><span style=3D"color:rgb(102,102,0)">(</span><s=
pan style>d_x</span><span style=3D"color:rgb(102,102,0)">*</span><span styl=
e>d_x
                  </span><span style=3D"color:rgb(102,102,0)">+</span><span=
 style> d_z</span><span style=3D"color:rgb(102,102,0)">*</span><span style>=
d_z
                  </span><span style=3D"color:rgb(102,102,0)">+</span><span=
 style> d_y</span><span style=3D"color:rgb(102,102,0)">*</span><span style>=
d_y</span><span style=3D"color:rgb(102,102,0)">);</span><span style><br>
                  </span><span style=3D"color:rgb(102,102,0)">}</span></div=
>
              </code></div>
            <div style=3D"color:rgb(102,0,102);font-family:monospace;backgr=
ound-color:rgb(250,250,250)"><br>
            </div>
          </div>
        </div></div>
      </blockquote><div class=3D"im">
      <br>
      <font face=3D"arial, sans-serif">Hi,<br>
        <br>
        what about using generic lambdas<br>
        <br>
      </font><br>
      <div style=3D"background-color:rgb(250,250,250);border:1px solid rgb(=
187,187,187);word-wrap:break-word"><code>
          <div><span style=3D"color:rgb(0,0,136)">template</span><span styl=
e> </span><span style=3D"color:rgb(102,102,0)">&lt;</span><span style=3D"co=
lor:rgb(0,0,136)">class</span><span style> T</span><span style=3D"color:rgb=
(102,102,0)">&gt;</span><span style> T
              distance</span><span style=3D"color:rgb(102,102,0)">(</span><=
span style>std</span><span style=3D"color:rgb(102,102,0)">::</span><span st=
yle>tuple</span><span style=3D"color:rgb(102,102,0)">&lt;</span><span style=
>T</span><span style=3D"color:rgb(102,102,0)">,</span><span style>T</span><=
span style=3D"color:rgb(102,102,0)">,</span><span style>T</span><span style=
=3D"color:rgb(102,102,0)">&gt;</span><span style> lft</span><span style=3D"=
color:rgb(102,102,0)">,</span><span style> std</span><span style=3D"color:r=
gb(102,102,0)">::</span><span style>tuple</span><span style=3D"color:rgb(10=
2,102,0)">&lt;</span><span style>T</span><span style=3D"color:rgb(102,102,0=
)">,</span><span style>T</span><span style=3D"color:rgb(102,102,0)">,</span=
><span style>T</span><span style=3D"color:rgb(102,102,0)">&gt;</span><span =
style> rgt</span><span style=3D"color:rgb(102,102,0)">)</span><span style> =
</span><span style=3D"color:rgb(102,102,0)">{</span><span style><br>

            </span><code><span style>=A0 =A0 auto</span><span style> x </sp=
an><span style=3D"color:rgb(102,102,0)">=3D</span><span style> [](auto</spa=
n><span style><code><span style=3D"color:rgb(102,102,0)"> t</span></code>) =
{
                return std</span><span style=3D"color:rgb(102,102,0)">::</s=
pan><span style=3D"color:rgb(0,0,136)">get</span><span style=3D"color:rgb(1=
02,102,0)">&lt;</span><span style=3D"color:rgb(0,102,102)">0</span><span st=
yle=3D"color:rgb(102,102,0)">&gt;(t);
                }</span><span style> <br>
              </span></code><code><span style>=A0 =A0 auto</span><span styl=
e> y </span><span style=3D"color:rgb(102,102,0)">=3D</span><span style> [](=
</span></code><code><span style><code><code><span style>auto</span></code><=
/code></span><span style><code><span style=3D"color:rgb(102,102,0)"> t</spa=
n></code>) {
                return std</span><span style=3D"color:rgb(102,102,0)">::</s=
pan><span style=3D"color:rgb(0,0,136)">get</span><span style=3D"color:rgb(1=
02,102,0)">&lt;</span><span style=3D"color:rgb(0,102,102)">1</span><span st=
yle=3D"color:rgb(102,102,0)">&gt;(t);
                }</span><span style> <br>
              </span></code><code><span style>=A0 =A0 auto</span><span styl=
e> z </span><span style=3D"color:rgb(102,102,0)">=3D</span><span style> [](=
</span></code><code><span style><code><code><span style>auto</span></code><=
/code></span><span style><code><span style=3D"color:rgb(102,102,0)"> t</spa=
n></code>) {
                return std</span><span style=3D"color:rgb(102,102,0)">::</s=
pan><span style=3D"color:rgb(0,0,136)">get</span><span style=3D"color:rgb(1=
02,102,0)">&lt;</span><span style=3D"color:rgb(0,102,102)">2</span><span st=
yle=3D"color:rgb(102,102,0)">&gt;(t);
                }</span><span style> <br>
              </span></code><span style><br>
              =A0 =A0 T d_x </span><span style=3D"color:rgb(102,102,0)">=3D=
</span><span style> x</span><span style=3D"color:rgb(102,102,0)">(</span><s=
pan style>lft</span><span style=3D"color:rgb(102,102,0)">)</span><span styl=
e> </span><span style=3D"color:rgb(102,102,0)">&gt;</span><span style> x</s=
pan><span style=3D"color:rgb(102,102,0)">(</span><span style>rgt</span><spa=
n style=3D"color:rgb(102,102,0)">)?</span><span style> =A0 x</span><span st=
yle=3D"color:rgb(102,102,0)">(</span><span style>lft</span><span style=3D"c=
olor:rgb(102,102,0)">)</span><span style> </span><span style=3D"color:rgb(1=
02,102,0)">-</span><span style> x</span><span style=3D"color:rgb(102,102,0)=
">(</span><span style>rgt</span><span style=3D"color:rgb(102,102,0)">):</sp=
an><span style> =A0 x</span><span style=3D"color:rgb(102,102,0)">(</span><s=
pan style>rgt</span><span style=3D"color:rgb(102,102,0)">)</span><span styl=
e> </span><span style=3D"color:rgb(102,102,0)">-</span><span style> x</span=
><span style=3D"color:rgb(102,102,0)">(</span><span style>lft</span><span s=
tyle=3D"color:rgb(102,102,0)">);</span><span style><br>

              =A0 =A0 T d_y </span><span style=3D"color:rgb(102,102,0)">=3D=
</span><span style> y</span><span style=3D"color:rgb(102,102,0)">(</span><s=
pan style>lft</span><span style=3D"color:rgb(102,102,0)">)</span><span styl=
e> </span><span style=3D"color:rgb(102,102,0)">&gt;</span><span style> y</s=
pan><span style=3D"color:rgb(102,102,0)">(</span><span style>rgt</span><spa=
n style=3D"color:rgb(102,102,0)">)?</span><span style> =A0 y</span><span st=
yle=3D"color:rgb(102,102,0)">(</span><span style>lft</span><span style=3D"c=
olor:rgb(102,102,0)">)</span><span style> </span><span style=3D"color:rgb(1=
02,102,0)">-</span><span style> y</span><span style=3D"color:rgb(102,102,0)=
">(</span><span style>rgt</span><span style=3D"color:rgb(102,102,0)">):</sp=
an><span style> =A0 y</span><span style=3D"color:rgb(102,102,0)">(</span><s=
pan style>rgt</span><span style=3D"color:rgb(102,102,0)">)</span><span styl=
e> </span><span style=3D"color:rgb(102,102,0)">-</span><span style> y</span=
><span style=3D"color:rgb(102,102,0)">(</span><span style>lft</span><span s=
tyle=3D"color:rgb(102,102,0)">);</span><span style><br>

              =A0 =A0 T d_z </span><span style=3D"color:rgb(102,102,0)">=3D=
</span><span style> z</span><span style=3D"color:rgb(102,102,0)">(</span><s=
pan style>lft</span><span style=3D"color:rgb(102,102,0)">)</span><span styl=
e> </span><span style=3D"color:rgb(102,102,0)">&gt;</span><span style> z</s=
pan><span style=3D"color:rgb(102,102,0)">(</span><span style>rgt</span><spa=
n style=3D"color:rgb(102,102,0)">)?</span><span style> =A0 z</span><span st=
yle=3D"color:rgb(102,102,0)">(</span><span style>lft</span><span style=3D"c=
olor:rgb(102,102,0)">)</span><span style> </span><span style=3D"color:rgb(1=
02,102,0)">-</span><span style> z</span><span style=3D"color:rgb(102,102,0)=
">(</span><span style>rgt</span><span style=3D"color:rgb(102,102,0)">):</sp=
an><span style> =A0 z</span><span style=3D"color:rgb(102,102,0)">(</span><s=
pan style>rgt</span><span style=3D"color:rgb(102,102,0)">)</span><span styl=
e> </span><span style=3D"color:rgb(102,102,0)">-</span><span style> z</span=
><span style=3D"color:rgb(102,102,0)">(</span><span style>lft</span><span s=
tyle=3D"color:rgb(102,102,0)">);</span><span style><br>

              <br>
              =A0 =A0 </span><span style=3D"color:rgb(0,0,136)">return</spa=
n><span style> </span><span style=3D"color:rgb(102,102,0)">(</span><span st=
yle>d_x</span><span style=3D"color:rgb(102,102,0)">*</span><span style>d_x =
</span><span style=3D"color:rgb(102,102,0)">+</span><span style> d_z</span>=
<span style=3D"color:rgb(102,102,0)">*</span><span style>d_z </span><span s=
tyle=3D"color:rgb(102,102,0)">+</span><span style> d_y</span><span style=3D=
"color:rgb(102,102,0)">*</span><span style>d_y</span><span style=3D"color:r=
gb(102,102,0)">);</span><span style><br>

            </span><span style=3D"color:rgb(102,102,0)">}</span></div>
        </code></div>
      <div style=3D"color:rgb(102,0,102);font-family:monospace;background-c=
olor:rgb(250,250,250)"><br>
      </div>
      <font face=3D"arial, sans-serif"><br>
        It is quite close to your proposed syntax, isn&#39;t it?<br>
      </font><br>
    </div></blockquote>
    <br>
    Boost.QVM uses a syntax that I&#39;m sure you will appreciate
    <a href=3D"http://www.revergestudios.com/boost-qvm/accessing_vector_ele=
ments.html" target=3D"_blank">http://www.revergestudios.com/boost-qvm/acces=
sing_vector_elements.html</a>.
    With such operations applied to tuples&lt;T,T,T&gt;, your example
    could become<br>
    <br>
    <div style=3D"background-color:rgb(250,250,250);border:1px solid rgb(18=
7,187,187);word-wrap:break-word"><code>
        <div><div class=3D"im"><span style=3D"color:rgb(0,0,136)">template<=
/span><span style> </span><span style=3D"color:rgb(102,102,0)">&lt;</span><=
span style=3D"color:rgb(0,0,136)">class</span><span style> T</span><span st=
yle=3D"color:rgb(102,102,0)">&gt;</span><span style> T distance</span><span=
 style=3D"color:rgb(102,102,0)">(</span><span style>std</span><span style=
=3D"color:rgb(102,102,0)">::</span><span style>tuple</span><span style=3D"c=
olor:rgb(102,102,0)">&lt;</span><span style>T</span><span style=3D"color:rg=
b(102,102,0)">,</span><span style>T</span><span style=3D"color:rgb(102,102,=
0)">,</span><span style>T</span><span style=3D"color:rgb(102,102,0)">&gt;</=
span><span style> lft</span><span style=3D"color:rgb(102,102,0)">,</span><s=
pan style> std</span><span style=3D"color:rgb(102,102,0)">::</span><span st=
yle>tuple</span><span style=3D"color:rgb(102,102,0)">&lt;</span><span style=
>T</span><span style=3D"color:rgb(102,102,0)">,</span><span style>T</span><=
span style=3D"color:rgb(102,102,0)">,</span><span style>T</span><span style=
=3D"color:rgb(102,102,0)">&gt;</span><span style> rgt</span><span style=3D"=
color:rgb(102,102,0)">)</span><span style> </span><span style=3D"color:rgb(=
102,102,0)">{</span><span style><br>

          </span><span style><br>
          </span></div><code><span style> =A0 =A0 T d_x </span><span style=
=3D"color:rgb(102,102,0)">=3D</span><span style> </span><span style>lft%X</=
span><span style=3D"color:rgb(102,102,0)"></span><span style> </span><span =
style=3D"color:rgb(102,102,0)">&gt;</span><span style>=A0</span><span style=
=3D"color:rgb(102,102,0)"></span><span style>rgt%X</span><span style=3D"col=
or:rgb(102,102,0)">?</span><span style> =A0 </span><span style>lft%X</span>=
<span style=3D"color:rgb(102,102,0)"></span><span style> </span><span style=
=3D"color:rgb(102,102,0)">-</span><span style>=A0</span><span style=3D"colo=
r:rgb(102,102,0)"></span><span style>rgt%X</span><span style=3D"color:rgb(1=
02,102,0)">:</span><span style> =A0=A0</span><span style=3D"color:rgb(102,1=
02,0)"></span><span style>rgt</span>%X<span style> </span><span style=3D"co=
lor:rgb(102,102,0)">-</span><span style>=A0</span><span style=3D"color:rgb(=
102,102,0)"></span><span style>lft%X</span><span style=3D"color:rgb(102,102=
,0)">;</span><span style></span><span style><br>

            </span></code><code><span style> =A0 =A0 T d_y </span><span sty=
le=3D"color:rgb(102,102,0)">=3D</span><span style> </span><span style>lft%Y=
</span><span style=3D"color:rgb(102,102,0)"></span><span style> </span><spa=
n style=3D"color:rgb(102,102,0)">&gt;</span><span style>=A0</span><span sty=
le=3D"color:rgb(102,102,0)"></span><span style>rgt%Y</span><span style=3D"c=
olor:rgb(102,102,0)">?</span><span style> =A0 </span><span style>lft%Y</spa=
n><span style=3D"color:rgb(102,102,0)"></span><span style> </span><span sty=
le=3D"color:rgb(102,102,0)">-</span><span style>=A0</span><span style=3D"co=
lor:rgb(102,102,0)"></span><span style>rgt%Y</span><span style=3D"color:rgb=
(102,102,0)">:</span><span style> =A0=A0</span><span style=3D"color:rgb(102=
,102,0)"></span><span style>rgt</span>%Y<span style> </span><span style=3D"=
color:rgb(102,102,0)">-</span><span style>=A0</span><span style=3D"color:rg=
b(102,102,0)"></span><span style>lft%Y</span><span style=3D"color:rgb(102,1=
02,0)">;</span><span style></span><span style><br>

            </span></code><code><span style> =A0 =A0 T d_z </span><span sty=
le=3D"color:rgb(102,102,0)">=3D</span><span style> </span><span style>lft%Z=
</span><span style=3D"color:rgb(102,102,0)"></span><span style> </span><spa=
n style=3D"color:rgb(102,102,0)">&gt;</span><span style>=A0</span><span sty=
le=3D"color:rgb(102,102,0)"></span><span style>rgt%Z</span><span style=3D"c=
olor:rgb(102,102,0)">?</span><span style> =A0 </span><span style>lft%Z</spa=
n><span style=3D"color:rgb(102,102,0)"></span><span style> </span><span sty=
le=3D"color:rgb(102,102,0)">-</span><span style>=A0</span><span style=3D"co=
lor:rgb(102,102,0)"></span><span style>rgt%Z</span><span style=3D"color:rgb=
(102,102,0)">:</span><span style> =A0=A0</span><span style=3D"color:rgb(102=
,102,0)"></span><span style>rgt</span>%Z<span style> </span><span style=3D"=
color:rgb(102,102,0)">-</span><span style>=A0</span><span style=3D"color:rg=
b(102,102,0)"></span><span style>lft%Z</span><span style=3D"color:rgb(102,1=
02,0)">;</span><span style><br>

            </span><span style><br>
            </span></code><div class=3D"im"><span style><br>
            =A0 =A0 </span><span style=3D"color:rgb(0,0,136)">return</span>=
<span style> </span><span style=3D"color:rgb(102,102,0)">(</span><span styl=
e>d_x</span><span style=3D"color:rgb(102,102,0)">*</span><span style>d_x </=
span><span style=3D"color:rgb(102,102,0)">+</span><span style> d_z</span><s=
pan style=3D"color:rgb(102,102,0)">*</span><span style>d_z </span><span sty=
le=3D"color:rgb(102,102,0)">+</span><span style> d_y</span><span style=3D"c=
olor:rgb(102,102,0)">*</span><span style>d_y</span><span style=3D"color:rgb=
(102,102,0)">);</span><span style><br>

          </span><span style=3D"color:rgb(102,102,0)">}</span></div></div>
      </code></div>
    <div style=3D"color:rgb(102,0,102);font-family:monospace;background-col=
or:rgb(250,250,250)"><br>
    </div>
    <font face=3D"arial, sans-serif"><br></font></div></blockquote><div><br=
></div><div>How about something like:</div><div><br></div><div>template&lt;=
unsigned N&gt; using n =3D std::integral_constant&lt;unsigned, N&gt;;</div>
<div>template&lt;typename T&gt; T distance(std::tuple&lt;T, T, T&gt; lft, s=
td::tuple&lt;T, T, T&gt; rgt) {<br></div><div>=A0 auto d2 =3D [&amp;](auto =
dir) {</div><div>=A0 =A0 T l =3D std::get&lt;dir()&gt;(lft), r =3D std::get=
&lt;dir()&gt;(rgt);</div>
<div>=A0 =A0 T d =3D l &gt; r ? l - r : r - l;</div><div>=A0 =A0 return d *=
 d;</div><div>=A0 }</div><div>=A0 return d2(n&lt;0&gt;()) + d2(n&lt;1&gt;()=
) + d2(n&lt;2&gt;());</div><div>}</div><div>=A0<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;bo=
rder-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div text=3D"#000000" bgcolor=3D"#FFFFFF"><font face=3D"arial, sans-serif">
    </font>Best,<br>
    Vicente<br>
    <br>
    <font face=3D"arial, sans-serif">P.S.=A0 a modulo function would help
      also ;-).<br>
    </font><br>
  </div><div class=3D""><div class=3D"h5">


<p></p>

-- <br>
=A0<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%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--047d7b6dc22448686204ec0a2508--

.