220 36759 <1e9a4035-1363-463a-9b97-6c153c38ebd5@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: meta members: a 0+ cost properties & dot operator
Date: Sun, 28 Jan 2018 12:53:57 -0800 (PST)
Lines: 347
Approved: news@gmane.org
Message-ID: <1e9a4035-1363-463a-9b97-6c153c38ebd5@isocpp.org>
References: <11f9c7ff-aa76-46a5-94b2-0692171ab0ff@isocpp.org> <437c4139-06b9-4751-aa2f-dea9563266dd@isocpp.org>
 <CAOhm51ETF9sL+pUnec+bkt256LZOOX-y5PzaiX1Fr86PZpDtpw@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_9096_1643667663.1517172837391"
X-Trace: blaine.gmane.org 1517172721 18593 195.159.176.226 (28 Jan 2018 20:52:01 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 28 Jan 2018 20:52:01 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBZXQXDJQKGQEGHLBOPA@isocpp.org Sun Jan 28 21:51:57 2018
Return-path: <std-proposals+bncBCEKFTV6ZUMBBZXQXDJQKGQEGHLBOPA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f72.google.com ([209.85.213.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBZXQXDJQKGQEGHLBOPA@isocpp.org>)
	id 1eftvf-0004UR-8x
	for gclcip-std-proposals@m.gmane.org; Sun, 28 Jan 2018 21:51:55 +0100
Original-Received: by mail-vk0-f72.google.com with SMTP id u71sf3877698vkb.10
        for <gclcip-std-proposals@m.gmane.org>; Sun, 28 Jan 2018 12:54:00 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=SufpBTThAXFuJjLx7IGVby4JWafQ5lqag24ONk9EgAY=;
        b=XspSp5zDigNlPy49PbTxggPROybBzDFMDw9QQe4NHESXHLTDRIETXp5lnoq3JHVdKd
         i1TIG4fiN7dwQtoIcoM2qo7h14k4HwI0Z6s8XtOtZ4JO/GuYsuR55Pqd4ENp5vpclXIM
         8eqs2AMbHHK82BNJm6f4isunyCAd5D2uzQqf2c7ynU7qeZvbFMO5TJh06GPnuUuDEtQF
         aeHLysomdN6skjUr5Zh5F23hwTa24+e46BxwlIqzXWonVwjJ86GyY0vKlhF1L4irljB+
         /KvDYf7zwGvdELmL/WM6jAfAooi6tDkbP4LIjyMRrClk6fOHCk3ZEXhwjjyFzXYu9zlE
         3DRg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=SufpBTThAXFuJjLx7IGVby4JWafQ5lqag24ONk9EgAY=;
        b=GcTA9o/gsKLK8ud2A6lSwOUWI/9+iQpMihRVgYYSyGacK4CWz0k7bq5JiwS9uEYKwN
         eFKRZpbiP0WGlXuyzPv5Cetzj6wF2tN71Xg6rKfEmvVWkfE76h+2sET1bsV9ZB4jLXCv
         vQ+HHZHUI+yu0ShQGu43q4t/4mms5fI77hUnA7rk19ASN/obVaGTXEn0JzzZQLdo4XL2
         HBb4mxUtvHg9/cnTY3fg//5lOx8lxjHavGrqR/tRpc5jpMHb2xvBLYieDVV+rV+J3YiA
         qQauy45NiIHH29N2RfKAhm5/Ed+kRxiEYBBAZNQBzs56FU2D1dx1XWcxk0jzQMgJ14Tq
         Ct1g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=SufpBTThAXFuJjLx7IGVby4JWafQ5lqag24ONk9EgAY=;
        b=JfbXIzMVFSrcvaX9jLXUdnM3QNFMnOPDZVuzmzt3ttpC5ggthDrOpH2ti3vHS9umL3
         xQUFrQmfc5EC6poZiVsj/rVjI++6MRit8nNM3O+Xudk1WZZPWZ2Vn98O6SgBbzH029/7
         yWtcg7FWm1HWIyy/Ra4cpVrsuQJjSM0VH0XGycT2HYij4fpS+AgyhYWfkbcxWl3vC0wQ
         pwWCqRvbbfj4aNHRnodth05e9iNf1JchiO8JWjFjD9cZZvuj/NuN3rmAgNUFQtBg4pwi
         QZNbqj0+9s36PEfwh+6dtDhdvBcRzH/O1G7OyI+dII2ePEPTRhHCDjeKFGd1kbFvfZKU
         ezKg==
X-Gm-Message-State: AKwxyteg3miEvSk823a67BjP/6mUNyvWXB3F96qLtuyvo25Ejg/lHLX4
	iRa2LTb3lOfGQ20Yz5tIaN5+qg==
X-Google-Smtp-Source: AH8x227W0KBmL9ZUO9CeTNL3n5sx0GsH+5VoFqDFo4clK8h72a+MIeSotivdHRWSfplmvz5k/k5loQ==
X-Received: by 10.176.83.74 with SMTP id y10mr10371101uay.117.1517172839750;
        Sun, 28 Jan 2018 12:53:59 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.31.5.8 with SMTP id 8ls6879315vkf.12.gmail; Sun, 28 Jan 2018
 12:53:58 -0800 (PST)
X-Received: by 10.31.50.209 with SMTP id y200mr2265151vky.3.1517172837853;
        Sun, 28 Jan 2018 12:53:57 -0800 (PST)
In-Reply-To: <CAOhm51ETF9sL+pUnec+bkt256LZOOX-y5PzaiX1Fr86PZpDtpw@mail.gmail.com>
X-Original-Sender: jmckesson@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:36759
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/36759>

------=_Part_9096_1643667663.1517172837391
Content-Type: multipart/alternative; 
	boundary="----=_Part_9097_1202324820.1517172837392"

------=_Part_9097_1202324820.1517172837392
Content-Type: text/plain; charset="UTF-8"

On Sunday, January 28, 2018 at 1:15:48 PM UTC-5, Bastien penavayre wrote:
>
> 2018-01-28 16:29 GMT+01:00 Nicol Bolas <jmck...@gmail.com <javascript:>>:
>
>> On Sunday, January 28, 2018 at 12:26:25 AM UTC-5, bastie...@gmail.com 
>> wrote:
>>>
>>> Hi,
>>>
>>> So I was toying with the idea of named tuple when I remembered D's name 
>>> resolution operator 
>>> <https://dlang.org/spec/operatoroverloading.html#dispatch> and check if 
>>> it was possible to implement in C++.
>>> For those not familiar to the idea it's manly an operator that receives 
>>> the unknown member access as a template non-type parameter instead of 
>>> causing an error.
>>> To my surprise it is an is quite cheap to implement (50 lines for GCC) 
>>> and could quite powerful (particularly if combined with reflection).
>>> To avoid creating a new operator i'm using the operator* with a template 
>>> non-type reference parameter as the 'new' operator :* template<auto& 
>>> memberName> auto operator*();*
>>> One of the motivations to use this operator is because it allows 
>>> out-of-class definitions.
>>> You can try and check some exemple here if you wish : 
>>> http://dispatch.gcc-future.tk/#
>>>
>>> The reason why I bring this up is that I believe that It could solve a 
>>> bunch of demands that have been unsuccessful in the past (generally due to 
>>> their coast being to great compared to the supposed benefit. ie: new 
>>> operator, keyword, syntax, etc...).
>>> Mainly the dot operator, properties, out of class method definition and 
>>> UCS.
>>>
>>> Here are a few examples.
>>>
>>> logging class with reflection:
>>>
>>
>> This doesn't work on constructors/destructors. Or operators, unless the 
>> caller spelled out the operator name (maybe?).
>>
> Yes indeed it wouldn't. It could but i don't think that would be a good 
> thing.
>

If logging is important to you, why would you not want to log operators and 
constructors/destructors?
 

>  
>
properties, simulate inheritance, multiple names:
>>>
>>
>> I've seen a* lot* of syntaxes proposed for properties, but that is 
>> perhaps the worst. The fact that you have to declare all of the properties 
>> inside of a single function makes this a hideous beast if your class has a 
>> significant number of properties.
>>
> I agree, it would quite hideous but you're not required to define 
> everything inside one function.
> Instead of using "if constexpr" you can redeclare the function with a  
> different requirement on the ids you want.
>

Because that's so much better.
 

> That being able to regroup everything inside 
>
>>
>> standard layout, pod:
>>>
>>
>> std::complex doesn't need help being standard layout. It's already 
>> required to be standard layout, and with a very specific layout. Nobody is 
>> stopping you from having `real` and `img` member functions with that layout.
>>
> Woow I'm not claiming such a thing  at all. I just used this example to 
> illustrate that it can allow for properties on trivial/pod types without 
> changing the definition.
>

What you're talking about is about adding stuff to types* of any kind* 
without changing their definitions. Being "trivial/POD" has nothing to do 
with this.


>> Out of class method definition / templated this / UCS:
>>>
>>
>> We definitely do not want people to be able to inject methods into 
>> arbitrary classes like this. Besides, how would you find this operator? ADL 
>> is how out-of-member operators are normally found.
>>
> The point of UCS is just that isn't it ? Using the member access syntax 
> call on normal functions.
>

It depends on which version of UCS you're talking about.

UCS could be implemented on the library side with this and reflection with 
> a static operator defined in an header <ucs>.
>

UCS didn't fail because of the difficulty of implementing it in compilers. 
It failed because many people* didn't want it*. Making it theoretically 
writable as a library changes none of the reasons for not wanting it. And 
indeed, if your feature allows UCS, then that means all of those arguments 
against UCS become reasons not to allow your feature.

For the question I don't understand what you mean. It a normal operator 
> it's just that it is called as a fallback when a member access fails due to 
> the member not being found. There is no complexity to it.
>

My question was how do you associate a specific implementation of this 
`operator NAME` with an object type?

Let's say you have this:

struct Type
{...};

Type operator+(const Type &lhs, const Type &rhs);

Type t1{...};
Type t2{...};

If I do `t1+t2`, the compiler finds the `operator+` overload through the 
use of Argument Dependent Lookup. That is, this* only works* when the 
`Type` and `operator+` are in the same namespace (outside of `using` 
gymnastics).

You cannot create a generic, template `operator+` overload that works for 
all types without making it a function in the global namespace (which is 
rude). And the same would be true of your `operator NAME` template; the 
only way to associate it with a particular type is to declare it in the 
namespace of that type.

Even the member-version of UCS was based on ADL lookup (and, if I recall 
correctly, *only* ADL lookup. It wouldn't find functions via non-ADL means).

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1e9a4035-1363-463a-9b97-6c153c38ebd5%40isocpp.org.

------=_Part_9097_1202324820.1517172837392
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Sunday, January 28, 2018 at 1:15:48 PM UTC-5, Bastien p=
enavayre wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-=
left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr=
"><div><div class=3D"gmail_quote">2018-01-28 16:29 GMT+01:00 Nicol Bolas <s=
pan dir=3D"ltr">&lt;<a onmousedown=3D"this.href=3D&#39;javascript:&#39;;ret=
urn true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;" href=
=3D"javascript:" target=3D"_blank" rel=3D"nofollow" gdf-obfuscated-mailto=
=3D"SPjvV_B4BgAJ">jmck...@gmail.com</a>&gt;</span>:<br><blockquote class=3D=
"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding=
-left:1ex"><div dir=3D"ltr"><span>On Sunday, January 28, 2018 at 12:26:25 A=
M UTC-5, <a>bastie...@gmail.com</a> wrote:<blockquote class=3D"gmail_quote"=
 style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-lef=
t:1ex"><div dir=3D"ltr">Hi,<div><br></div><div>So I was toying with the ide=
a of named tuple when I remembered <a onmousedown=3D"this.href=3D&#39;https=
://www.google.com/url?q\x3dhttps%3A%2F%2Fdlang.org%2Fspec%2Foperatoroverloa=
ding.html%23dispatch\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzNFt_luOJfQw2=
_XmtkXz5O2qiiQ&#39;;return true;" onclick=3D"this.href=3D&#39;https://www.g=
oogle.com/url?q\x3dhttps%3A%2F%2Fdlang.org%2Fspec%2Foperatoroverloading.htm=
l%23dispatch\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEzNFt_luOJfQw2_XmtkXz5=
O2qiiQ&#39;;return true;" href=3D"https://dlang.org/spec/operatoroverloadin=
g.html#dispatch" target=3D"_blank" rel=3D"nofollow">D&#39;s name resolution=
 operator</a>=C2=A0and check if it was possible to implement in C++.</div><=
div>For those not familiar to the idea it&#39;s manly an operator that rece=
ives the unknown member access as a template non-type parameter instead of =
causing an error.</div><div>To my surprise it is an is quite cheap to imple=
ment (50 lines for GCC) and could quite powerful (particularly if combined =
with reflection).</div><div>To avoid creating a new operator i&#39;m using =
the operator* with a template non-type reference parameter as the &#39;new&=
#39; operator :<b> template&lt;auto&amp; memberName&gt; auto operator*();</=
b></div><div>One of the motivations to use this operator is because it allo=
ws out-of-class definitions.</div><div>You can try and check some exemple h=
ere if you wish :=C2=A0<a onmousedown=3D"this.href=3D&#39;http://www.google=
..com/url?q\x3dhttp%3A%2F%2Fdispatch.gcc-future.tk%2F%23\x26sa\x3dD\x26sntz\=
x3d1\x26usg\x3dAFQjCNE4UjYjHib_e_JiYSPeRbOqP_cF4g&#39;;return true;" onclic=
k=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fdispatch.=
gcc-future.tk%2F%23\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNE4UjYjHib_e_JiY=
SPeRbOqP_cF4g&#39;;return true;" href=3D"http://dispatch.gcc-future.tk/#" t=
arget=3D"_blank" rel=3D"nofollow">http://dispatch.gcc-future.<wbr>tk/#</a><=
br></div><div><br></div><div>The reason why I bring this up is that I belie=
ve that It could solve a bunch of demands that have been unsuccessful in th=
e past (generally due to their coast being to great compared to the suppose=
d benefit. ie: new operator, keyword, syntax, etc...).</div><div>Mainly the=
 dot operator, properties, out of class method definition and UCS.</div><di=
v><br></div><div>Here are a few examples.</div><div><br></div><div>logging =
class with reflection:</div></div></blockquote><div><br></div></span><div>T=
his doesn&#39;t work on constructors/destructors. Or operators, unless the =
caller spelled out the operator name (maybe?).</div></div></blockquote><div=
>Yes indeed it wouldn&#39;t. It could but i don&#39;t think that would be a=
 good thing.</div></div></div></div></blockquote><div><br></div><div>If log=
ging is important to you, why would you not want to log operators and const=
ructors/destructors?</div><div>=C2=A0</div><blockquote class=3D"gmail_quote=
" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding=
-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quote"><div>=C2=A0</=
div></div></div></div></blockquote><blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quote"><div><span></span></=
div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span><blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr"><div>properties, simulate inheritan=
ce, multiple names:<br></div></div></blockquote><div><br></div></span><div>=
I&#39;ve seen a<i> lot</i> of syntaxes proposed for properties, but that is=
 perhaps the worst. The fact that you have to declare all of the properties=
 inside of a single function makes this a hideous beast if your class has a=
 significant number of properties.</div></div></blockquote><div>I agree, it=
 would quite hideous but you&#39;re not required to define everything insid=
e one function.</div><div>Instead of using &quot;if constexpr&quot; you can=
 redeclare the function with a=C2=A0 different requirement on the ids you w=
ant.</div></div></div></div></blockquote><div><br></div><div>Because that&#=
39;s so much better.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote=
" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding=
-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quote"><div>That bei=
ng able to regroup everything inside=C2=A0</div><blockquote class=3D"gmail_=
quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1=
ex"><div dir=3D"ltr"><div><br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"=
><div dir=3D"ltr"><div>standard layout, pod:</div></div></blockquote><div><=
br></div><div>std::complex doesn&#39;t need help being standard layout. It&=
#39;s already required to be standard layout, and with a very specific layo=
ut. Nobody is stopping you from having `real` and `img` member functions wi=
th that layout.</div></div></blockquote><div>Woow I&#39;m not claiming such=
 a thing=C2=A0 at all. I just used this example to illustrate that it can a=
llow for properties on trivial/pod types without changing the definition.</=
div></div></div></div></blockquote><div><br></div><div>What you&#39;re talk=
ing about is about adding stuff to types<i> of any kind</i> without changin=
g their definitions. Being &quot;trivial/POD&quot; has nothing to do with t=
his.</div><div><i><br></i></div><blockquote class=3D"gmail_quote" style=3D"=
margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;=
"><div dir=3D"ltr"><div><div class=3D"gmail_quote"><blockquote class=3D"gma=
il_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-lef=
t:1ex"><div dir=3D"ltr"><span><div><font style=3D"background-color:rgb(250,=
250,250)"></font><br></div><blockquote class=3D"gmail_quote" style=3D"margi=
n:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"ltr"><div>Out of class method definition / templated this / UCS:</div><=
/div></blockquote><div><br></div></span><div>We definitely do not want peop=
le to be able to inject methods into arbitrary classes like this. Besides, =
how would you find this operator? ADL is how out-of-member operators are no=
rmally found.</div></div></blockquote><div>The point of UCS is just that is=
n&#39;t it ? Using the member access syntax call on normal functions.</div>=
</div></div></div></blockquote><div><br></div><div>It depends on which vers=
ion of UCS you&#39;re talking about.</div><div><br></div><blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quote=
"><div>UCS could be implemented on the library side with this and reflectio=
n with a static operator defined in an header &lt;ucs&gt;.</div></div></div=
></div></blockquote><div><br></div><div>UCS didn&#39;t fail because of the =
difficulty of implementing it in compilers. It failed because many people<i=
> didn&#39;t want it</i>. Making it theoretically writable as a library cha=
nges none of the reasons for not wanting it. And indeed, if your feature al=
lows UCS, then that means all of those arguments against UCS become reasons=
 not to allow your feature.</div><div><i><br></i></div><blockquote class=3D=
"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc s=
olid;padding-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quote"><=
div>For the question I don&#39;t understand what you mean. It a normal oper=
ator it&#39;s just that it is called as a fallback when a member access fai=
ls due to the member not being found. There is no complexity to it.</div></=
div></div></div></blockquote><div><br></div><div>My question was how do you=
 associate a specific implementation of this `operator NAME` with an object=
 type?</div><div><br></div><div>Let&#39;s say you have this:</div><div><br>=
</div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 1=
87); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code cl=
ass=3D"prettyprint"><div class=3D"subprettyprint"><span class=3D"styled-by-=
prettify" style=3D"color: #008;">struct</span><span class=3D"styled-by-pret=
tify" style=3D"color: #000;"> </span><span class=3D"styled-by-prettify" sty=
le=3D"color: #606;">Type</span><span class=3D"styled-by-prettify" style=3D"=
color: #000;"><br></span><span class=3D"styled-by-prettify" style=3D"color:=
 #660;">{...};</span><span class=3D"styled-by-prettify" style=3D"color: #00=
0;"><br><br></span><span class=3D"styled-by-prettify" style=3D"color: #606;=
">Type</span><span class=3D"styled-by-prettify" style=3D"color: #000;"> </s=
pan><span class=3D"styled-by-prettify" style=3D"color: #008;">operator</spa=
n><span class=3D"styled-by-prettify" style=3D"color: #660;">+(</span><span =
class=3D"styled-by-prettify" style=3D"color: #008;">const</span><span class=
=3D"styled-by-prettify" style=3D"color: #000;"> </span><span class=3D"style=
d-by-prettify" style=3D"color: #606;">Type</span><span class=3D"styled-by-p=
rettify" style=3D"color: #000;"> </span><span class=3D"styled-by-prettify" =
style=3D"color: #660;">&amp;</span><span class=3D"styled-by-prettify" style=
=3D"color: #000;">lhs</span><span class=3D"styled-by-prettify" style=3D"col=
or: #660;">,</span><span class=3D"styled-by-prettify" style=3D"color: #000;=
"> </span><span class=3D"styled-by-prettify" style=3D"color: #008;">const</=
span><span class=3D"styled-by-prettify" style=3D"color: #000;"> </span><spa=
n class=3D"styled-by-prettify" style=3D"color: #606;">Type</span><span clas=
s=3D"styled-by-prettify" style=3D"color: #000;"> </span><span class=3D"styl=
ed-by-prettify" style=3D"color: #660;">&amp;</span><span class=3D"styled-by=
-prettify" style=3D"color: #000;">rhs</span><span class=3D"styled-by-pretti=
fy" style=3D"color: #660;">);</span><span class=3D"styled-by-prettify" styl=
e=3D"color: #000;"><br><br></span><span class=3D"styled-by-prettify" style=
=3D"color: #606;">Type</span><span class=3D"styled-by-prettify" style=3D"co=
lor: #000;"> t1</span><span class=3D"styled-by-prettify" style=3D"color: #6=
60;">{...};</span><span class=3D"styled-by-prettify" style=3D"color: #000;"=
><br></span><span class=3D"styled-by-prettify" style=3D"color: #606;">Type<=
/span><span class=3D"styled-by-prettify" style=3D"color: #000;"> t2</span><=
span class=3D"styled-by-prettify" style=3D"color: #660;">{...};</span></div=
></code></div><div><br></div><div>If I do `t1+t2`, the compiler finds the `=
operator+` overload through the use of Argument Dependent Lookup. That is, =
this<i> only works</i> when the `Type` and `operator+` are in the same name=
space (outside of `using` gymnastics).</div><div><br></div><div>You cannot =
create a generic, template `operator+` overload that works for all types wi=
thout making it a function in the global namespace (which is rude). And the=
 same would be true of your `operator NAME` template; the only way to assoc=
iate it with a particular type is to declare it in the namespace of that ty=
pe.</div><div><br></div><div>Even the member-version of UCS was based on AD=
L lookup (and, if I recall correctly, <i>only</i> ADL lookup. It wouldn&#39=
;t find functions via non-ADL means).</div><div><br></div><blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;">
</blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/1e9a4035-1363-463a-9b97-6c153c38ebd5%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1e9a4035-1363-463a-9b97-6c153c38ebd5=
%40isocpp.org</a>.<br />

------=_Part_9097_1202324820.1517172837392--

------=_Part_9096_1643667663.1517172837391--

.
