Topic: calling templated operator() for functors as regular


Author: bastienpenava@gmail.com
Date: Mon, 18 Sep 2017 09:47:43 -0700 (PDT)
Raw View
------=_Part_4250_1021518366.1505753263722
Content-Type: multipart/alternative;
 boundary="----=_Part_4251_159867446.1505753263723"

------=_Part_4251_159867446.1505753263723
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi,

Now that the  Familiar template syntax for generic lambdas=20
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0428r2.pdf> propo=
sal=20
has been accepted in C++20,
I think it would be interesting to be able to call such lambdas (and=20
functors) with explicit template parameters using the same syntax as for=20
templated functions.
For now we must call explicitly .operator() to give said parameters which=
=20
defeats the purpose of operator().
auto f =3D []<class T>() { ... };
f<int>(); //error expected primary expression before 'int'
f.operator()<int>(); //the only way

What I propose is to update the postfix-expression part of the standard=20
(8.2) to allow :
*postfix-**expression* < *template-parameter-**listopt* > ( *expression**-*
*listopt* )

*iff* the type of *postfix-expression* ha*s* a templated *operator()* and=
=20
has* no* *operator< **.*

I've made a patch of 100 lines for *gcc-7.2* that implements this idea and =
you=20
can try a live version of the compiler here : compiler explorer=20
<http://ec2-52-56-164-249.eu-west-2.compute.amazonaws.com:10240/#g:!((g:!((=
g:!((h:codeEditor,i:(j:1,source:'struct+A%0A%7B%0A++++template%3Cclass+T%3E=
%0A++++void+operator()(T%26%26)+%7B%7D%0A%7D%3B%0A%0Astruct+B+:+A%0A%7B%0A+=
+++template%3Cclass+T%3E%0A++++bool+operator%3C(T%26%26)+%7B+return+true%3B=
+%7D%0A%7D%3B%0A%0A%23include+%3Ctype_traits%3E%0A%23include+%3Cutility%3E%=
0A%0Atemplate%3Csize_t+Or,+size_t+I%3E%0Aconcept+bool+is_ge+%3D+Or+%3E%3D+I=
%3B%0A%0Atemplate%3Csize_t+from,+is_ge%3Cfrom%3E+to%3E%0Aconstexpr+auto+mak=
e_index_sequence()%0A%7B%0A++++return+(%5B%5D%3Csize_t...+Is%3E(std::index_=
sequence%3CIs...%3E)+%3D%3E%0A++++++++std::index_sequence%3C(Is%2Bfrom)...%=
3E%7B%7D)(std::make_index_sequence%3Cto+-+from%3E%7B%7D)%3B%0A%7D%3B%0A%0Ai=
nt+main()%0A%7B++++%0A++++constexpr+auto+size_of+%3D+%5B%5D%3Cclass+T%3E()+=
%3D%3E+sizeof(T)%3B%0A++++static_assert(size_of%3Cint%3E()+%3D%3D+sizeof(in=
t))%3B%0A%0A++++make_index_sequence%3C0,+5%3E()%3B%0A%0A++++A+no_lt_op%3B%0=
A++++B+with_lt_op%3B%0A%0A++++no_lt_op%3Cint%3E(42)%3B+//ok%0A++++no_lt_op%=
3C42%3E(42)%3B+//try+to+call+method,+doesn!'t+match,+error%0A++++with_lt_op=
%3Cint%3E(42)%3B+//sees+operator%3C,+doesn!'t+try+to+interpret+as+!'.operat=
or()!'%0A%7D'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:51.64179104477=
612,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:gcclambda=
,filters:(___0:(),b:'0',commentOnly:'0',directives:'0',intel:'0',jquery:'3.=
2.1',length:1,prevObject:(___0:(sizzle1505748407615:(undefined:(legend:!(5,=
0,'1')))),length:1,prevObject:(___0:(jQuery321072884201659414741:(display:'=
'),sizzle1505748407615:(undefined:(legend:!(5,0,'1')))),length:1)),trim:'0'=
),options:'-fconcepts',source:1),l:'5',n:'0',o:'g%2B%2B+lambda+abriviated+(=
Editor+%231,+Compiler+%231)',t:'0')),k:50,l:'4',m:50,n:'0',o:'',s:0,t:'0'),=
(g:!((h:output,i:(compiler:1,editor:1),l:'5',n:'0',o:'%231+with+g%2B%2B+lam=
bda+abriviated',t:'0')),header:(),l:'4',m:50,n:'0',o:'',s:0,t:'0')),k:48.35=
820895522388,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4>
..

Here's an exemple:
struct A { template<class T> void operator()(T&&) {} };
struct B : A { template<class T> bool operator<(T&&) { return true; } };

int main()
{=20
 constexpr auto size_of =3D []<class T>() { return sizeof(T); };
 static_assert(size_of<int>() =3D=3D sizeof(int));

 A no_lt_op;
 B with_lt_op;

 no_lt_op<int>(42); //ok
 no_lt_op<42>(42); //try to call method, doesn't match, error
 with_lt_op<int>(42); //sees operator<, doesn't try to interpret as=20
'.operator()'
 [](){}<int>(); //no templated operator() so *postfix-expression* is=20
'[](){}', try to parse a *relational-expression*, error: expected=20
primary-expression before 'int'
}

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/8a389d85-515a-4ca8-8451-6e366f8e655e%40isocpp.or=
g.

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

<div dir=3D"ltr">Hi,<div><br></div><div>Now that the =C2=A0<a href=3D"http:=
//www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0428r2.pdf">Familiar te=
mplate syntax for generic lambdas</a>=C2=A0proposal has been accepted in C+=
+20,</div><div>I think it would be interesting to be able to call such lamb=
das (and functors) with explicit template parameters using the same syntax =
as for templated functions.</div><div>For now we must call explicitly .oper=
ator() to give said parameters which defeats the purpose of operator().</di=
v><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250);=
 border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; =
word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpretty=
print"><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> f </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">[]&lt;</span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&gt;()</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">...</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>f</span><span style=3D"color: =
#080;" class=3D"styled-by-prettify">&lt;int&gt;</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: #800;" class=3D=
"styled-by-prettify">//error expected primary expression before &#39;int&#3=
9;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>f</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">()&lt;</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&gt;();</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" c=
lass=3D"styled-by-prettify">//the only way</span></div></code></div><div><b=
r></div><div>What I propose is to update the postfix-expression part of the=
 standard (8.2) to allow :</div><div><div class=3D"prettyprint" style=3D"ba=
ckground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); borde=
r-style: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"p=
rettyprint"><div class=3D"subprettyprint"><i><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">postfix</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">-</span></i><i><span style=3D"color: #000;" class=
=3D"styled-by-prettify">expression</span></i><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><i><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">template</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">-</span><span style=3D"color: #000;" class=3D"styled-by-prettify">para=
meter</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</sp=
an></i><i><span style=3D"color: #000;" class=3D"styled-by-prettify">list</s=
pan><font size=3D"1"><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">opt</span></font></i><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=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: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><i><span style=3D=
"color: #000;" class=3D"styled-by-prettify">expression</span></i><i><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">-</span></i><i><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">list</span><font size=3D"1=
"><span style=3D"color: #000;" class=3D"styled-by-prettify">opt</span></fon=
t></i><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">)</span></div></code=
></div><div style=3D"font-weight: bold;"><b><br></b></div><div style=3D""><=
b style=3D"font-weight: bold;">iff</b> the type of <i style=3D"">postfix-ex=
pression</i><span style=3D"font-weight: bold;"><span style=3D"font-weight: =
normal;">=C2=A0</span>ha</span><b style=3D"font-weight: bold;">s</b><b> </b=
>a templated <i style=3D"font-weight: bold;">operator()</i><b style=3D"font=
-weight: bold;"> </b>and has<b style=3D"font-weight: bold;"> no</b><b>=C2=
=A0</b><i style=3D"">operator&lt; </i><i style=3D"font-weight: bold;">.</i>=
<br></div></div><div style=3D""><i style=3D"font-weight: bold;"><br></i></d=
iv><div style=3D""><span style=3D"color: rgb(0, 0, 0); font-family: arial, =
sans-serif; font-size: 14px; white-space: pre; background-color: rgb(255, 2=
55, 254);">I&#39;ve made a patch of 100 lines for </span><b style=3D"color:=
 rgb(0, 0, 0); font-family: arial, sans-serif; font-size: 14px; white-space=
: pre; background-color: rgb(255, 255, 254);">gcc-7.2</b><span style=3D"col=
or: rgb(0, 0, 0); font-family: arial, sans-serif; font-size: 14px; white-sp=
ace: pre; background-color: rgb(255, 255, 254);"> that implements this idea=
</span><b style=3D"color: rgb(0, 0, 0); font-family: arial, sans-serif; fon=
t-size: 14px; white-space: pre; background-color: rgb(255, 255, 254);"> </b=
><span style=3D"color: rgb(0, 0, 0); font-family: arial, sans-serif; font-s=
ize: 14px; white-space: pre; background-color: rgb(255, 255, 254);">and</sp=
an><b style=3D"color: rgb(0, 0, 0); font-family: arial, sans-serif; font-si=
ze: 14px; white-space: pre; background-color: rgb(255, 255, 254);"> </b><sp=
an style=3D"color: rgb(0, 0, 0); font-family: arial, sans-serif; font-size:=
 14px; white-space: pre; background-color: rgb(255, 255, 254);">you can try=
 a live version of the compiler here : </span><a href=3D"http://ec2-52-56-1=
64-249.eu-west-2.compute.amazonaws.com:10240/#g:!((g:!((g:!((h:codeEditor,i=
:(j:1,source:&#39;struct+A%0A%7B%0A++++template%3Cclass+T%3E%0A++++void+ope=
rator()(T%26%26)+%7B%7D%0A%7D%3B%0A%0Astruct+B+:+A%0A%7B%0A++++template%3Cc=
lass+T%3E%0A++++bool+operator%3C(T%26%26)+%7B+return+true%3B+%7D%0A%7D%3B%0=
A%0A%23include+%3Ctype_traits%3E%0A%23include+%3Cutility%3E%0A%0Atemplate%3=
Csize_t+Or,+size_t+I%3E%0Aconcept+bool+is_ge+%3D+Or+%3E%3D+I%3B%0A%0Atempla=
te%3Csize_t+from,+is_ge%3Cfrom%3E+to%3E%0Aconstexpr+auto+make_index_sequenc=
e()%0A%7B%0A++++return+(%5B%5D%3Csize_t...+Is%3E(std::index_sequence%3CIs..=
..%3E)+%3D%3E%0A++++++++std::index_sequence%3C(Is%2Bfrom)...%3E%7B%7D)(std::=
make_index_sequence%3Cto+-+from%3E%7B%7D)%3B%0A%7D%3B%0A%0Aint+main()%0A%7B=
++++%0A++++constexpr+auto+size_of+%3D+%5B%5D%3Cclass+T%3E()+%3D%3E+sizeof(T=
)%3B%0A++++static_assert(size_of%3Cint%3E()+%3D%3D+sizeof(int))%3B%0A%0A+++=
+make_index_sequence%3C0,+5%3E()%3B%0A%0A++++A+no_lt_op%3B%0A++++B+with_lt_=
op%3B%0A%0A++++no_lt_op%3Cint%3E(42)%3B+//ok%0A++++no_lt_op%3C42%3E(42)%3B+=
//try+to+call+method,+doesn!&#39;t+match,+error%0A++++with_lt_op%3Cint%3E(4=
2)%3B+//sees+operator%3C,+doesn!&#39;t+try+to+interpret+as+!&#39;.operator(=
)!&#39;%0A%7D&#39;),l:&#39;5&#39;,n:&#39;0&#39;,o:&#39;C%2B%2B+source+%231&=
#39;,t:&#39;0&#39;)),k:51.64179104477612,l:&#39;4&#39;,n:&#39;0&#39;,o:&#39=
;&#39;,s:0,t:&#39;0&#39;),(g:!((g:!((h:compiler,i:(compiler:gcclambda,filte=
rs:(___0:(),b:&#39;0&#39;,commentOnly:&#39;0&#39;,directives:&#39;0&#39;,in=
tel:&#39;0&#39;,jquery:&#39;3.2.1&#39;,length:1,prevObject:(___0:(sizzle150=
5748407615:(undefined:(legend:!(5,0,&#39;1&#39;)))),length:1,prevObject:(__=
_0:(jQuery321072884201659414741:(display:&#39;&#39;),sizzle1505748407615:(u=
ndefined:(legend:!(5,0,&#39;1&#39;)))),length:1)),trim:&#39;0&#39;),options=
:&#39;-fconcepts&#39;,source:1),l:&#39;5&#39;,n:&#39;0&#39;,o:&#39;g%2B%2B+=
lambda+abriviated+(Editor+%231,+Compiler+%231)&#39;,t:&#39;0&#39;)),k:50,l:=
&#39;4&#39;,m:50,n:&#39;0&#39;,o:&#39;&#39;,s:0,t:&#39;0&#39;),(g:!((h:outp=
ut,i:(compiler:1,editor:1),l:&#39;5&#39;,n:&#39;0&#39;,o:&#39;%231+with+g%2=
B%2B+lambda+abriviated&#39;,t:&#39;0&#39;)),header:(),l:&#39;4&#39;,m:50,n:=
&#39;0&#39;,o:&#39;&#39;,s:0,t:&#39;0&#39;)),k:48.35820895522388,l:&#39;3&#=
39;,n:&#39;0&#39;,o:&#39;&#39;,t:&#39;0&#39;)),l:&#39;2&#39;,n:&#39;0&#39;,=
o:&#39;&#39;,t:&#39;0&#39;)),version:4" style=3D"font-family: arial, sans-s=
erif; font-size: 14px; white-space: pre; background-color: rgb(255, 255, 25=
4);">compiler explorer</a><span style=3D"color: rgb(0, 0, 0); font-family: =
arial, sans-serif; font-size: 14px; white-space: pre; background-color: rgb=
(255, 255, 254);">.</span><i style=3D"font-weight: bold;"><br></i></div><di=
v><br></div><div>Here&#39;s an exemple:</div><div><div style=3D"background-=
color: rgb(255, 255, 254); line-height: 19px;"><div class=3D"prettyprint" s=
tyle=3D"color: rgb(0, 0, 0); font-size: 14px; white-space: pre; font-family=
: &quot;Fira Mono&quot;; background-color: rgb(250, 250, 250); border-color=
: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: br=
eak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span =
style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> A </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span styl=
e=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">&amp;&amp;)</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{}</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">struct<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> B </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> A </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">bool</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&lt;(</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">&amp;&amp;)</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">return</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">true<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> main</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> <br>=C2=A0</spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> size_of </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">[]&lt;</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">class</span><span style=3D"color: #000;" class=3D"s=
tyled-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-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">sizeof</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">);</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0</span><span style=3D"color: #008;" class=3D"styled-by-prettify">stat=
ic_assert</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">size_of</s=
pan><span style=3D"color: #080;" class=3D"styled-by-prettify">&lt;int&gt;</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">sizeof</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">int</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">));</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br><br>=C2=A0A no_lt_op</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>=C2=A0B with_lt_op</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br><br>=C2=A0no_lt_op</span><span style=3D"color: #080;" cl=
ass=3D"styled-by-prettify">&lt;int&gt;</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #066;" class=3D"s=
tyled-by-prettify">42</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//ok</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0no=
_lt_op</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;=
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">42</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;(</span><span =
style=3D"color: #066;" class=3D"styled-by-prettify">42</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: #800;" cl=
ass=3D"styled-by-prettify">//try to call method, doesn&#39;t match, error</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0wi=
th_lt_op</span><span style=3D"color: #080;" class=3D"styled-by-prettify">&l=
t;int&gt;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">42</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #800;" class=3D"styled-by-prettify">//sees operator&lt;, doesn&#39;t tr=
y to interpret as &#39;.operator()&#39;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>=C2=A0</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">[](){}&lt;</span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">int</span><span style=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-b=
y-prettify">//no templated operator() so </span><i><span style=3D"color: #8=
00;" class=3D"styled-by-prettify">postfix-expression</span></i><span style=
=3D"color: #800;" class=3D"styled-by-prettify"> is &#39;[](){}&#39;, try to=
 parse a </span><i><span style=3D"color: #800;" class=3D"styled-by-prettify=
">relational-expression</span></i><span style=3D"color: #800;" class=3D"sty=
led-by-prettify">, error: expected primary-expression before &#39;int&#39;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></c=
ode></div></div></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/8a389d85-515a-4ca8-8451-6e366f8e655e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/8a389d85-515a-4ca8-8451-6e366f8e655e=
%40isocpp.org</a>.<br />

------=_Part_4251_159867446.1505753263723--

------=_Part_4250_1021518366.1505753263722--

.