Topic: probing interest: extended class interface
Author: =?UTF-8?Q?Andrzej_Krzemie=C5=84ski?= <akrzemi1@gmail.com>
Date: Sat, 2 Feb 2013 05:59:28 -0800 (PST)
Raw View
------=_Part_260_14060523.1359813568876
Content-Type: text/plain; charset=ISO-8859-1
I would like to throw an idea at people in this forum, and check if you
consider it a useful addition to C++ language. It is an elaboration on the
idea suggested by Vicente J. Botet Escriba:
https://groups.google.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/FJeR8QL3pBcJ
..
It is based on observation that the interface of a class type consists not
only of its member functions, but also of some non-member functions:
class Seq
{
// ...
};
Seq operator+(Seq, Seq); // also class interface
void swap(Seq&, Seq&); // also class interface
ostream& operator<<(ostream&, Seq); // also class interface
Iter begin(Seq &); // also class interface
Iter end(Seq &); // also class interface
// ...
bool has_duplicates(Seq const&) // not an interface
"Being a class interface" means when I use my class, I also want these
functions to be considered in overload resolution. ADL does enable this,
however it also imports anything from our namespace, which is often far too
much.
N3490 proposes to disable ADL in a controlled way. But for functions that
we consider an "extended class interface", we still would like the ADL to
work.
The idea here is to give a tool for programmers to indicate that some
functions are part of class's interface, even though they are member
functions. One possible syntax for it is the following.
class Seq
{
// ...
}
friend
{
Seq operator+(Seq, Seq);
void swap(Seq&, Seq&);
ostream& operator<<(ostream&, Seq);
Iter begin(Seq &);
Iter end(Seq &);
}
; // the semicolon that ends class definition
// ...
bool has_duplicates(Seq const&) // not an interface
The "friend namespace" needs to be declared just after the closing brace of
the class scope, but before the semicolon. This way we guarantee that only
the class author decides which functions constitute the extended interface.
It does not introduce any new scope. It only groups functions. These
functions are different from other functions in the namespace in the
following way:
1. They are picked by the overload resolution even if ADL is disabled,
as per N3490 ("Controlling Argument-Dependent Lookup")
2. They are automatically inherited by opaque aliases, as proposed in
N3515("Toward Opaque Typedefs for C++1Y")
The same logic for being promoted to extended class interface could be
enabled for friend functions declared without scope qualification:
class Seq
{
friend ostream& operator<<(ostream&, Seq); // also class interface
friend Iter begin(Seq &); // also class interface
friend Iter end(Seq &); // also class interface
};
At first glance, it looks as a useful compliment to N3490 and N3515. I
wonder what you think?
Regards,
&rzej
--
---
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/?hl=en.
------=_Part_260_14060523.1359813568876
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
I would like to throw an idea at people in this forum, and check if you=20
consider it a useful addition to C++ language. It is an elaboration on=20
the idea suggested by Vicente J. Botet Escriba: <a href=3D"https://groups.g=
oogle.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/FJeR8QL3pBcJ" target=
=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msg/std-<wbr>prop=
osals/-u6e-rohWXM/<wbr>FJeR8QL3pBcJ</a>.<br><br>It
is based on observation that the interface of a class type consists not
only of its member functions, but also of some non-member functions:<br><b=
r><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">class</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #606;" class=3D"styled-by-prettify">Seq</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> </span><span style=3D"color: #800;"=
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><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br><br></span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">Seq</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">operat=
or</span><span style=3D"color: #660;" class=3D"styled-by-prettify">+(</span=
><span style=3D"color: #606;" class=3D"styled-by-prettify">Seq</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: #6=
06;" class=3D"styled-by-prettify">Seq</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-=
prettify">// also class interface</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> swap</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Se=
q</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&,</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</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">// also class interface</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>ostream</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">&</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">operator</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify"><<(</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">ostream</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">&,</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">Seq</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// also =
class interface</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br></span><span style=3D"color: #606;" class=3D"styled-by-prettify">I=
ter</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">begin</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </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: #800;" class=3D"s=
tyled-by-prettify">// also class interface</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #606;" cla=
ss=3D"styled-by-prettify">Iter</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">end</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Seq</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">&);</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #800;" class=3D"styled-by-prettify">// also class interface</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span=
style=3D"color: #800;" class=3D"styled-by-prettify">// ...</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">bool</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> has_duplicates</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #60=
6;" class=3D"styled-by-prettify">Seq</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">const</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">&)</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/=
/ not an interface</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br></span></div></code></div><br>"Being
a class interface" means when I use my class, I also want these=20
functions to be considered in overload resolution. ADL does enable this,
however it also imports anything from our namespace, which is often far
too much.<br><br>N3490 proposes to disable ADL in a controlled way. But
for functions that we consider an "extended class interface", we still=20
would like the ADL to work. <br><br>The idea here is to give a tool for=20
programmers to indicate that some functions are part of class's=20
interface, even though they are member functions. One possible syntax=20
for it is the following.<br><br><div class=3D"prettyprint" style=3D"backgro=
und-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-sty=
le: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"pretty=
print"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"=
styled-by-prettify">class</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pret=
tify">Seq</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> </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">// ...</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">friend</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br> </span><span style=3D"color: #606;" class=3D"sty=
led-by-prettify">Seq</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>operator</span><span style=3D"color: #660;" class=3D"styled-by-prettify">+=
(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Seq</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #606;" class=3D"styled-by-prettify">Seq</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: #008;" cl=
ass=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> swap</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(</span><span style=3D"color: #606;" class=3D"styled-by-pre=
ttify">Seq</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&);</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> <br> ostream</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><<(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">ostream</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">&,</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;=
" class=3D"styled-by-prettify">Seq</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> <br> </span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">Iter</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">begin</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(<=
/span><span style=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&);</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> <br> </span><span sty=
le=3D"color: #606;" class=3D"styled-by-prettify">Iter</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">end</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">Seq</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></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n 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">// the semicolon that ends class defi=
nition</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
<br></span><span style=3D"color: #800;" class=3D"styled-by-prettify">// ...=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> has_duplicates</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">const</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&)</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">// not an interface</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span></div></code></div><br>The
"friend namespace" needs to be declared just after the closing brace of
the class scope, but before the semicolon. This way we guarantee that=20
only the class author decides which functions constitute the extended=20
interface.<br>It does not introduce any new scope. It only groups=20
functions. These functions are different from other functions in the=20
namespace in the following way:<br><br><ol><li>They are picked by the overl=
oad resolution even if ADL is disabled, as per N3490 ("Controlling Argument=
-Dependent Lookup")</li><li>They are automatically inherited by opaque alia=
ses, as proposed in N3515("Toward Opaque Typedefs for C++1Y")</li></ol>The =
same logic for being promoted to extended class interface could be enabled =
for friend functions declared without scope qualification:<br><br><div clas=
s=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-col=
or: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: =
break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">class</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #606;" class=3D"styled-by-prettify">Seq</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br> </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">friend</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> ostream</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">o=
perator</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><=
;<(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">ostr=
eam</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: #606;" class=3D"styled-by-prettify">Seq</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">// also class interface</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br><br> </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">friend</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">Iter</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">begin</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">Seq</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </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">// also class inte=
rface</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&=
nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">frie=
nd</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #606;" class=3D"styled-by-prettify">Iter</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">end</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #606;" cl=
ass=3D"styled-by-prettify">Seq</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-pr=
ettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/=
/ also class interface</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span></div></code></div><br><br>At first glance, it looks as a useful c=
ompliment to N3490 and N3515. I wonder what you think?<br><br>Regards,<br>&=
amp;rzej<br>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_260_14060523.1359813568876--
.
Author: Arthur Tchaikovsky <atch.cpp@gmail.com>
Date: Sat, 2 Feb 2013 08:03:18 -0800 (PST)
Raw View
------=_Part_114_462482.1359820998707
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Cze=C5=9B=C4=87 Andrzej,
Wydaje mi si=C4=99... oops sorry, go back to EN mode,
OK, that's better,
Andrew I think that the idea is certainly worth considering but I for once=
=20
don't like the constraint that it has to be exactly next to class def/decl.=
=20
It is not in the C++ spirit to tell people that something has to be right=
=20
next to such declaration and nowhere else.
What I would see:
class Seq
{
// ...
};//Business/SEMICOLON AS USUAL
//possibly in different file:
friend class Seq
{
Seq operator+(Seq, Seq);
void swap(Seq&, Seq&);=20
ostream& operator<<(ostream&, Seq);=20
Iter begin(Seq &);=20
Iter end(Seq &);=20
}
; // the semicolon that ends class definition ISN'T NECESSARY HERE
On Saturday, 2 February 2013 13:59:28 UTC, Andrzej Krzemie=C5=84ski wrote:
>
> I would like to throw an idea at people in this forum, and check if you=
=20
> consider it a useful addition to C++ language. It is an elaboration on th=
e=20
> idea suggested by Vicente J. Botet Escriba:=20
> https://groups.google.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/FJ=
eR8QL3pBcJ
> .
>
> It is based on observation that the interface of a class type consists no=
t=20
> only of its member functions, but also of some non-member functions:
>
> class Seq
> {
> // ...
> };
>
> Seq operator+(Seq, Seq); // also class interface
> void swap(Seq&, Seq&); // also class interface
> ostream& operator<<(ostream&, Seq); // also class interface
> Iter begin(Seq &); // also class interface
> Iter end(Seq &); // also class interface
>
> // ...
> bool has_duplicates(Seq const&) // not an interface
>
> "Being a class interface" means when I use my class, I also want these=20
> functions to be considered in overload resolution. ADL does enable this,=
=20
> however it also imports anything from our namespace, which is often far t=
oo=20
> much.
>
> N3490 proposes to disable ADL in a controlled way. But for functions that=
=20
> we consider an "extended class interface", we still would like the ADL to=
=20
> work.=20
>
> The idea here is to give a tool for programmers to indicate that some=20
> functions are part of class's interface, even though they are member=20
> functions. One possible syntax for it is the following.
>
> class Seq
> {
> // ...
> }
> friend
> {
> Seq operator+(Seq, Seq);
> void swap(Seq&, Seq&);=20
> ostream& operator<<(ostream&, Seq);=20
> Iter begin(Seq &);=20
> Iter end(Seq &);=20
> }
> ; // the semicolon that ends class definition
>
> // ...
> bool has_duplicates(Seq const&) // not an interface
>
> The "friend namespace" needs to be declared just after the closing brace=
=20
> of the class scope, but before the semicolon. This way we guarantee that=
=20
> only the class author decides which functions constitute the extended=20
> interface.
> It does not introduce any new scope. It only groups functions. These=20
> functions are different from other functions in the namespace in the=20
> following way:
>
>
> 1. They are picked by the overload resolution even if ADL is disabled,=
=20
> as per N3490 ("Controlling Argument-Dependent Lookup")
> 2. They are automatically inherited by opaque aliases, as proposed in=
=20
> N3515("Toward Opaque Typedefs for C++1Y")
>
> The same logic for being promoted to extended class interface could be=20
> enabled for friend functions declared without scope qualification:
>
> class Seq
> {
> friend ostream& operator<<(ostream&, Seq); // also class interface
>
> friend Iter begin(Seq &); // also class interface
> friend Iter end(Seq &); // also class interface
> };
>
>
> At first glance, it looks as a useful compliment to N3490 and N3515. I=20
> wonder what you think?
>
> Regards,
> &rzej
>
--=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/?hl=3Den.
------=_Part_114_462482.1359820998707
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div>Cze=C5=9B=C4=87 Andrzej,<br></div><div>Wydaje mi si=C4=99... oops sorr=
y, go back to EN mode,</div><div>OK, that's better,</div><div>Andrew I thin=
k that the idea is certainly worth considering but I for once don't like th=
e constraint that it has to be exactly next to class def/decl. It is not in=
the C++ spirit to tell people that something has to be right next to such =
declaration and nowhere else.</div><div>What I would see:</div><div><br></d=
iv><div>class Seq<br>{<br> // ...<br>};//Business/SEMICOLON AS USUAL</div>=
<div><br></div><div>//possibly in different file:<br>friend class Seq<br>{<=
br> Seq operator+(Seq, Seq);<br> void swap(Seq&, Seq&); <br> ost=
ream& operator<<(ostream&, Seq); <br> Iter begin(Seq &);=
<br> Iter end(Seq &); <br>}<br>; // the semicolon that ends class def=
inition ISN'T NECESSARY HERE</div><br>On Saturday, 2 February 2013 13:59:28=
UTC, Andrzej Krzemie=C5=84ski wrote:<blockquote class=3D"gmail_quote" sty=
le=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left=
: 1ex;">I would like to throw an idea at people in this forum, and check if=
you=20
consider it a useful addition to C++ language. It is an elaboration on=20
the idea suggested by Vicente J. Botet Escriba: <a href=3D"https://groups.g=
oogle.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/FJeR8QL3pBcJ" target=
=3D"_blank">https://groups.google.com/a/isocpp.org/d/msg/std-proposals/-u6e=
-rohWXM/FJeR8QL3pBcJ</a>.<br><br>It
is based on observation that the interface of a class type consists not
only of its member functions, but also of some non-member functions:<br><b=
r><div 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><div><=
span style=3D"color:#008">class</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#606">Seq</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#660">{</span><span style=3D"color:#000"><br> </sp=
an><span style=3D"color:#800">// ...</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br><b=
r></span><span style=3D"color:#606">Seq</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">operator</span><span style=3D"color:#660">=
+(</span><span style=3D"color:#606">Seq</span><span style=3D"color:#660">,<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#606">Seq</sp=
an><span style=3D"color:#660">);</span><span style=3D"color:#000"> </span><=
span style=3D"color:#800">// also class interface</span><span style=3D"colo=
r:#000"><br></span><span style=3D"color:#008">void</span><span style=3D"col=
or:#000"> swap</span><span style=3D"color:#660">(</span><span style=3D"colo=
r:#606">Seq</span><span style=3D"color:#660">&,</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#606">Seq</span><span style=3D"color=
:#660">&);</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#800">// also class interface</span><span style=3D"color:#000"><br>ostrea=
m</span><span style=3D"color:#660">&</span><span style=3D"color:#000"> =
</span><span style=3D"color:#008">operator</span><span style=3D"color:#660"=
><<(</span><span style=3D"color:#000">ostream</span><span style=3D"co=
lor:#660">&,</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#606">Seq</span><span style=3D"color:#660">);</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#800">// also class interface</span><s=
pan style=3D"color:#000"><br></span><span style=3D"color:#606">Iter</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">begin</span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#606">Seq</span><span=
style=3D"color:#000"> </span><span style=3D"color:#660">&);</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#800">// also class int=
erface</span><span style=3D"color:#000"><br></span><span style=3D"color:#60=
6">Iter</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>end</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Se=
q</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&=
);</span><span style=3D"color:#000"> </span><span style=3D"color:#800">// a=
lso class interface</span><span style=3D"color:#000"><br><br></span><span s=
tyle=3D"color:#800">// ...</span><span style=3D"color:#000"><br></span><spa=
n style=3D"color:#008">bool</span><span style=3D"color:#000"> has_duplicate=
s</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Seq</=
span><span style=3D"color:#000"> </span><span style=3D"color:#008">const</s=
pan><span style=3D"color:#660">&)</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#800">// not an interface</span><span style=3D"col=
or:#000"><br></span></div></code></div><br>"Being
a class interface" means when I use my class, I also want these=20
functions to be considered in overload resolution. ADL does enable this,
however it also imports anything from our namespace, which is often far
too much.<br><br>N3490 proposes to disable ADL in a controlled way. But
for functions that we consider an "extended class interface", we still=20
would like the ADL to work. <br><br>The idea here is to give a tool for=20
programmers to indicate that some functions are part of class's=20
interface, even though they are member functions. One possible syntax=20
for it is the following.<br><br><div 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><div><span style=3D"color:#008">class</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#606">Seq</span><span styl=
e=3D"color:#000"><br></span><span style=3D"color:#660">{</span><span style=
=3D"color:#000"><br> </span><span style=3D"color:#800">// ...</span><=
span style=3D"color:#000"><br></span><span style=3D"color:#660">}</span><sp=
an style=3D"color:#000"><br></span><span style=3D"color:#008">friend</span>=
<span style=3D"color:#000"><br></span><span style=3D"color:#660">{</span><s=
pan style=3D"color:#000"><br> </span><span style=3D"color:#606">Seq</=
span><span style=3D"color:#000"> </span><span style=3D"color:#008">operator=
</span><span style=3D"color:#660">+(</span><span style=3D"color:#606">Seq</=
span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#606">Seq</span><span style=3D"color:#660">);</span><s=
pan style=3D"color:#000"><br> </span><span style=3D"color:#008">void<=
/span><span style=3D"color:#000"> swap</span><span style=3D"color:#660">(</=
span><span style=3D"color:#606">Seq</span><span style=3D"color:#660">&,=
</span><span style=3D"color:#000"> </span><span style=3D"color:#606">Seq</s=
pan><span style=3D"color:#660">&);</span><span style=3D"color:#000"> <b=
r> ostream</span><span style=3D"color:#660">&</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">operator</span><span sty=
le=3D"color:#660"><<(</span><span style=3D"color:#000">ostream</span>=
<span style=3D"color:#660">&,</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#606">Seq</span><span style=3D"color:#660">);</span><s=
pan style=3D"color:#000"> <br> </span><span style=3D"color:#606">Iter=
</span><span style=3D"color:#000"> </span><span style=3D"color:#008">begin<=
/span><span style=3D"color:#660">(</span><span style=3D"color:#606">Seq</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#660">&);</s=
pan><span style=3D"color:#000"> <br> </span><span style=3D"color:#606=
">Iter</span><span style=3D"color:#000"> </span><span style=3D"color:#008">=
end</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Seq=
</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&)=
;</span><span style=3D"color:#000"> <br></span><span style=3D"color:#660">}=
</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">;</=
span><span style=3D"color:#000"> </span><span style=3D"color:#800">// the s=
emicolon that ends class definition</span><span style=3D"color:#000"><br><b=
r></span><span style=3D"color:#800">// ...</span><span style=3D"color:#000"=
><br></span><span style=3D"color:#008">bool</span><span style=3D"color:#000=
"> has_duplicates</span><span style=3D"color:#660">(</span><span style=3D"c=
olor:#606">Seq</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#008">const</span><span style=3D"color:#660">&)</span><span style=3D"=
color:#000"> </span><span style=3D"color:#800">// not an interface</span><s=
pan style=3D"color:#000"><br></span></div></code></div><br>The
"friend namespace" needs to be declared just after the closing brace of
the class scope, but before the semicolon. This way we guarantee that=20
only the class author decides which functions constitute the extended=20
interface.<br>It does not introduce any new scope. It only groups=20
functions. These functions are different from other functions in the=20
namespace in the following way:<br><br><ol><li>They are picked by the overl=
oad resolution even if ADL is disabled, as per N3490 ("Controlling Argument=
-Dependent Lookup")</li><li>They are automatically inherited by opaque alia=
ses, as proposed in N3515("Toward Opaque Typedefs for C++1Y")</li></ol>The =
same logic for being promoted to extended class interface could be enabled =
for friend functions declared without scope qualification:<br><br><div styl=
e=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);border=
-style:solid;border-width:1px;word-wrap:break-word"><code><div><span style=
=3D"color:#008">class</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">Seq</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#660">{</span><span style=3D"color:#000"><br> </span><span =
style=3D"color:#008">friend</span><span style=3D"color:#000"> ostream</span=
><span style=3D"color:#660">&</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#008">operator</span><span style=3D"color:#660"><&l=
t;(</span><span style=3D"color:#000">ostream</span><span style=3D"color:#66=
0">&,</span><span style=3D"color:#000"> </span><span style=3D"color:#60=
6">Seq</span><span style=3D"color:#660">);</span><span style=3D"color:#000"=
> </span><span style=3D"color:#800">// also class interface</span><span sty=
le=3D"color:#000"><br><br> </span><span style=3D"color:#008">friend</=
span><span style=3D"color:#000"> </span><span style=3D"color:#606">Iter</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#008">begin</spa=
n><span style=3D"color:#660">(</span><span style=3D"color:#606">Seq</span><=
span style=3D"color:#000"> </span><span style=3D"color:#660">&);</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#800">// also class=
interface</span><span style=3D"color:#000"><br> </span><span style=
=3D"color:#008">friend</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">Iter</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">end</span><span style=3D"color:#660">(</span><span style=3D=
"color:#606">Seq</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#660">&);</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#800">// also class interface</span><span style=3D"color:#000"><br></s=
pan><span style=3D"color:#660">};</span><span style=3D"color:#000"><br></sp=
an></div></code></div><br><br>At first glance, it looks as a useful complim=
ent to N3490 and N3515. I wonder what you think?<br><br>Regards,<br>&rz=
ej<br></blockquote>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_114_462482.1359820998707--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Sat, 02 Feb 2013 19:56:42 +0200
Raw View
----- Original message -----
> functions. One possible syntax for it is the following.
> class Seq
> {
>=A0 =A0 // ...
> }
> friend
> {
The idea in general is interesting, but
using friend to denote it is illogical.
Remember that "Part of the interface" and=20
"has access to the guts" are orthogonal.
--=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/?hl=3Den.
.
Author: =?UTF-8?Q?Micha=C5=82_=22Griwes=22_Dominiak?= <griwes@griwes.info>
Date: Sat, 2 Feb 2013 19:01:18 +0100
Raw View
--f46d0401f93797c0f404d4c1a570
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Hi,
> //possibly in different file:
> friend class Seq
> {
> Seq operator+(Seq, Seq);
> void swap(Seq&, Seq&);
> ostream& operator<<(ostream&, Seq);
> Iter begin(Seq &);
> Iter end(Seq &);
> }
> ; // the semicolon that ends class definition ISN'T NECESSARY HERE
That definitely makes sense, although "friend class Seq" looks a bit
surprising. I would consider leaving the syntax from OP, but also
introducing the possibility to extend the interface in this way:
class Seq
{
//...
}
friend
{
//...
};
// somewhere else
class Seq friend
{
//...
}; // I would leave this semicolon here
(At least for me) this looks less surprising (it's not declaration of
friend member class, but "friends" (=3D "non-member interface functions") o=
f
the class), is consistent with itself and allows a bit shorter syntax when
declaring non-member interface "in place".
Also, I agree with Ville on the fact that "friend" is a little awkward here=
..
On 2 February 2013 17:03, Arthur Tchaikovsky <atch.cpp@gmail.com> wrote:
> Cze=C5=9B=C4=87 Andrzej,
> Wydaje mi si=C4=99... oops sorry, go back to EN mode,
> OK, that's better,
> Andrew I think that the idea is certainly worth considering but I for onc=
e
> don't like the constraint that it has to be exactly next to class def/dec=
l.
> It is not in the C++ spirit to tell people that something has to be right
> next to such declaration and nowhere else.
> What I would see:
>
> class Seq
> {
> // ...
> };//Business/SEMICOLON AS USUAL
>
> //possibly in different file:
> friend class Seq
>
> {
> Seq operator+(Seq, Seq);
> void swap(Seq&, Seq&);
> ostream& operator<<(ostream&, Seq);
> Iter begin(Seq &);
> Iter end(Seq &);
> }
> ; // the semicolon that ends class definition ISN'T NECESSARY HERE
>
> On Saturday, 2 February 2013 13:59:28 UTC, Andrzej Krzemie=C5=84ski wrote=
:
>>
>> I would like to throw an idea at people in this forum, and check if you
>> consider it a useful addition to C++ language. It is an elaboration on t=
he
>> idea suggested by Vicente J. Botet Escriba:
>> https://groups.google.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/F=
JeR8QL3pBcJ
>> .
>>
>> It is based on observation that the interface of a class type consists
>> not only of its member functions, but also of some non-member functions:
>>
>> class Seq
>> {
>> // ...
>> };
>>
>> Seq operator+(Seq, Seq); // also class interface
>> void swap(Seq&, Seq&); // also class interface
>> ostream& operator<<(ostream&, Seq); // also class interface
>> Iter begin(Seq &); // also class interface
>> Iter end(Seq &); // also class interface
>>
>> // ...
>> bool has_duplicates(Seq const&) // not an interface
>>
>> "Being a class interface" means when I use my class, I also want these
>> functions to be considered in overload resolution. ADL does enable this,
>> however it also imports anything from our namespace, which is often far =
too
>> much.
>>
>> N3490 proposes to disable ADL in a controlled way. But for functions tha=
t
>> we consider an "extended class interface", we still would like the ADL t=
o
>> work.
>>
>> The idea here is to give a tool for programmers to indicate that some
>> functions are part of class's interface, even though they are member
>> functions. One possible syntax for it is the following.
>>
>> class Seq
>> {
>> // ...
>> }
>> friend
>> {
>> Seq operator+(Seq, Seq);
>> void swap(Seq&, Seq&);
>> ostream& operator<<(ostream&, Seq);
>> Iter begin(Seq &);
>> Iter end(Seq &);
>> }
>> ; // the semicolon that ends class definition
>>
>> // ...
>> bool has_duplicates(Seq const&) // not an interface
>>
>> The "friend namespace" needs to be declared just after the closing brace
>> of the class scope, but before the semicolon. This way we guarantee that
>> only the class author decides which functions constitute the extended
>> interface.
>> It does not introduce any new scope. It only groups functions. These
>> functions are different from other functions in the namespace in the
>> following way:
>>
>>
>> 1. They are picked by the overload resolution even if ADL is
>> disabled, as per N3490 ("Controlling Argument-Dependent Lookup")
>> 2. They are automatically inherited by opaque aliases, as proposed in
>> N3515("Toward Opaque Typedefs for C++1Y")
>>
>> The same logic for being promoted to extended class interface could be
>> enabled for friend functions declared without scope qualification:
>>
>> class Seq
>> {
>> friend ostream& operator<<(ostream&, Seq); // also class interface
>>
>> friend Iter begin(Seq &); // also class interface
>> friend Iter end(Seq &); // also class interface
>> };
>>
>>
>> At first glance, it looks as a useful compliment to N3490 and N3515. I
>> wonder what you think?
>>
>> Regards,
>> &rzej
>>
> --
>
> ---
> 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/?hl=3Den.
>
>
>
--=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/?hl=3Den.
--f46d0401f93797c0f404d4c1a570
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hi,<div><br></div><div>>=C2=A0<span style=3D"font-famil=
y:arial,sans-serif;font-size:13px">//possibly in different file:</span></di=
v><div style=3D"font-family:arial,sans-serif;font-size:13px">> friend cl=
ass Seq<div class=3D"im">
> {<br>> Seq operator+(Seq, Seq);<br>> void swap(Seq&, Seq&=
;);=C2=A0<br>> ostream& operator<<(ostream&, Seq);=C2=A0<b=
r>> Iter begin(Seq &);=C2=A0<br>> Iter end(Seq &);=C2=A0<br>&=
gt; }<br></div>> ; // the semicolon that ends class definition ISN'T=
NECESSARY HERE</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><div s=
tyle=3D"font-family:arial,sans-serif;font-size:13px">That definitely makes =
sense, although "friend class Seq" looks a bit surprising. I woul=
d consider leaving the syntax from OP, but also introducing the possibility=
to extend the interface in this way:</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><div s=
tyle=3D"font-family:arial,sans-serif;font-size:13px">class Seq</div><div st=
yle=3D"font-family:arial,sans-serif;font-size:13px">{</div><div style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">
//...</div><div style=3D"font-family:arial,sans-serif;font-size:13px">}</di=
v><div style=3D"font-family:arial,sans-serif;font-size:13px">friend</div><d=
iv style=3D"font-family:arial,sans-serif;font-size:13px">{</div><div style=
=3D"font-family:arial,sans-serif;font-size:13px">
//...</div><div style=3D"font-family:arial,sans-serif;font-size:13px">};</d=
iv><div style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><di=
v style=3D"font-family:arial,sans-serif;font-size:13px">// somewhere else</=
div>
<div style=3D"font-family:arial,sans-serif;font-size:13px">class Seq friend=
</div><div style=3D"font-family:arial,sans-serif;font-size:13px">{</div><di=
v style=3D"font-family:arial,sans-serif;font-size:13px">//...</div><div sty=
le=3D"font-family:arial,sans-serif;font-size:13px">
}; // I would leave this semicolon here</div><div style=3D"font-family:aria=
l,sans-serif;font-size:13px"><br></div><div class=3D"" style=3D"font-family=
:arial,sans-serif;font-size:13px"></div><div class=3D"gmail_extra">(At leas=
t for me) this looks less surprising (it's not declaration of friend me=
mber class, but "friends" (=3D "non-member interface functio=
ns") of the class), is consistent with itself and allows a bit shorter=
syntax when declaring non-member interface "in place".</div>
<div class=3D"gmail_extra"><br></div><div class=3D"gmail_extra">Also, I agr=
ee with Ville on the fact that "friend" is a little awkward here.=
<br><br><div class=3D"gmail_quote">On 2 February 2013 17:03, Arthur Tchaiko=
vsky <span dir=3D"ltr"><<a href=3D"mailto:atch.cpp@gmail.com" target=3D"=
_blank">atch.cpp@gmail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div>Cze=C5=9B=C4=87 Andrzej,<br></div><div>=
Wydaje mi si=C4=99... oops sorry, go back to EN mode,</div><div>OK, that=
9;s better,</div>
<div>Andrew I think that the idea is certainly worth considering but I for =
once don't like the constraint that it has to be exactly next to class =
def/decl. It is not in the C++ spirit to tell people that something has to =
be right next to such declaration and nowhere else.</div>
<div>What I would see:</div><div><br></div><div>class Seq<br>{<br> // ...<=
br>};//Business/SEMICOLON AS USUAL</div><div><br></div><div>//possibly in d=
ifferent file:<br>friend class Seq<div class=3D"im"><br>{<br> Seq operator=
+(Seq, Seq);<br>
void swap(Seq&, Seq&); <br> ostream& operator<<(ostrea=
m&, Seq); <br> Iter begin(Seq &); <br> Iter end(Seq &); <br>}=
<br></div>; // the semicolon that ends class definition ISN'T NECESSARY=
HERE</div>
<div class=3D"HOEnZb"><div class=3D"h5"><br>On Saturday, 2 February 2013 13=
:59:28 UTC, Andrzej Krzemie=C5=84ski wrote:<blockquote class=3D"gmail_quot=
e" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-l=
eft:1ex">
I would like to throw an idea at people in this forum, and check if you=20
consider it a useful addition to C++ language. It is an elaboration on=20
the idea suggested by Vicente J. Botet Escriba: <a href=3D"https://groups.g=
oogle.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/FJeR8QL3pBcJ" target=
=3D"_blank">https://groups.google.com/a/isocpp.org/d/msg/std-proposals/-u6e=
-rohWXM/FJeR8QL3pBcJ</a>.<br>
<br>It
is based on observation that the interface of a class type consists not
only of its member functions, but also of some non-member functions:<br><b=
r><div 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><div>
<span style=3D"color:#008">class</span><span style> </span><span style=3D"c=
olor:#606">Seq</span><span style><br></span><span style=3D"color:#660">{</s=
pan><span style><br>=C2=A0 </span><span style=3D"color:#800">// ...</span><=
span style><br>
</span><span style=3D"color:#660">};</span><span style><br><br></span><span=
style=3D"color:#606">Seq</span><span style> </span><span style=3D"color:#0=
08">operator</span><span style=3D"color:#660">+(</span><span style=3D"color=
:#606">Seq</span><span style=3D"color:#660">,</span><span style> </span><sp=
an style=3D"color:#606">Seq</span><span style=3D"color:#660">);</span><span=
style> </span><span style=3D"color:#800">// also class interface</span><sp=
an style><br>
</span><span style=3D"color:#008">void</span><span style> swap</span><span =
style=3D"color:#660">(</span><span style=3D"color:#606">Seq</span><span sty=
le=3D"color:#660">&,</span><span style> </span><span style=3D"color:#60=
6">Seq</span><span style=3D"color:#660">&);</span><span style> </span><=
span style=3D"color:#800">// also class interface</span><span style><br>
ostream</span><span style=3D"color:#660">&</span><span style> </span><s=
pan style=3D"color:#008">operator</span><span style=3D"color:#660"><<=
(</span><span style>ostream</span><span style=3D"color:#660">&,</span><=
span style> </span><span style=3D"color:#606">Seq</span><span style=3D"colo=
r:#660">);</span><span style> </span><span style=3D"color:#800">// also cla=
ss interface</span><span style><br>
</span><span style=3D"color:#606">Iter</span><span style> </span><span styl=
e=3D"color:#008">begin</span><span style=3D"color:#660">(</span><span style=
=3D"color:#606">Seq</span><span style> </span><span style=3D"color:#660">&a=
mp;);</span><span style> </span><span style=3D"color:#800">// also class in=
terface</span><span style><br>
</span><span style=3D"color:#606">Iter</span><span style> </span><span styl=
e=3D"color:#008">end</span><span style=3D"color:#660">(</span><span style=
=3D"color:#606">Seq</span><span style> </span><span style=3D"color:#660">&a=
mp;);</span><span style> </span><span style=3D"color:#800">// also class in=
terface</span><span style><br>
<br></span><span style=3D"color:#800">// ...</span><span style><br></span><=
span style=3D"color:#008">bool</span><span style> has_duplicates</span><spa=
n style=3D"color:#660">(</span><span style=3D"color:#606">Seq</span><span s=
tyle> </span><span style=3D"color:#008">const</span><span style=3D"color:#6=
60">&)</span><span style> </span><span style=3D"color:#800">// not an i=
nterface</span><span style><br>
</span></div></code></div><br>"Being
a class interface" means when I use my class, I also want these=20
functions to be considered in overload resolution. ADL does enable this,
however it also imports anything from our namespace, which is often far
too much.<br><br>N3490 proposes to disable ADL in a controlled way. But
for functions that we consider an "extended class interface", we=
still=20
would like the ADL to work. <br><br>The idea here is to give a tool for=20
programmers to indicate that some functions are part of class's=20
interface, even though they are member functions. One possible syntax=20
for it is the following.<br><br><div 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><div><span style=3D"color:#008">class</span><span s=
tyle> </span><span style=3D"color:#606">Seq</span><span style><br>
</span><span style=3D"color:#660">{</span><span style><br>=C2=A0 </span><sp=
an style=3D"color:#800">// ...</span><span style><br></span><span style=3D"=
color:#660">}</span><span style><br></span><span style=3D"color:#008">frien=
d</span><span style><br>
</span><span style=3D"color:#660">{</span><span style><br>=C2=A0 </span><sp=
an style=3D"color:#606">Seq</span><span style> </span><span style=3D"color:=
#008">operator</span><span style=3D"color:#660">+(</span><span style=3D"col=
or:#606">Seq</span><span style=3D"color:#660">,</span><span style> </span><=
span style=3D"color:#606">Seq</span><span style=3D"color:#660">);</span><sp=
an style><br>
=C2=A0 </span><span style=3D"color:#008">void</span><span style> swap</span=
><span style=3D"color:#660">(</span><span style=3D"color:#606">Seq</span><s=
pan style=3D"color:#660">&,</span><span style> </span><span style=3D"co=
lor:#606">Seq</span><span style=3D"color:#660">&);</span><span style> <=
br>
=C2=A0 ostream</span><span style=3D"color:#660">&</span><span style> </=
span><span style=3D"color:#008">operator</span><span style=3D"color:#660">&=
lt;<(</span><span style>ostream</span><span style=3D"color:#660">&,<=
/span><span style> </span><span style=3D"color:#606">Seq</span><span style=
=3D"color:#660">);</span><span style> <br>
=C2=A0 </span><span style=3D"color:#606">Iter</span><span style> </span><sp=
an style=3D"color:#008">begin</span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#606">Seq</span><span style> </span><span style=3D"color:#=
660">&);</span><span style> <br>
=C2=A0 </span><span style=3D"color:#606">Iter</span><span style> </span><sp=
an style=3D"color:#008">end</span><span style=3D"color:#660">(</span><span =
style=3D"color:#606">Seq</span><span style> </span><span style=3D"color:#66=
0">&);</span><span style> <br>
</span><span style=3D"color:#660">}</span><span style><br></span><span styl=
e=3D"color:#660">;</span><span style> </span><span style=3D"color:#800">// =
the semicolon that ends class definition</span><span style><br><br></span><=
span style=3D"color:#800">// ...</span><span style><br>
</span><span style=3D"color:#008">bool</span><span style> has_duplicates</s=
pan><span style=3D"color:#660">(</span><span style=3D"color:#606">Seq</span=
><span style> </span><span style=3D"color:#008">const</span><span style=3D"=
color:#660">&)</span><span style> </span><span style=3D"color:#800">// =
not an interface</span><span style><br>
</span></div></code></div><br>The
"friend namespace" needs to be declared just after the closing b=
race of
the class scope, but before the semicolon. This way we guarantee that=20
only the class author decides which functions constitute the extended=20
interface.<br>It does not introduce any new scope. It only groups=20
functions. These functions are different from other functions in the=20
namespace in the following way:<br><br><ol><li>They are picked by the overl=
oad resolution even if ADL is disabled, as per N3490 ("Controlling Arg=
ument-Dependent Lookup")</li><li>They are automatically inherited by o=
paque aliases, as proposed in N3515("Toward Opaque Typedefs for C++1Y&=
quot;)</li>
</ol>The same logic for being promoted to extended class interface could be=
enabled for friend functions declared without scope qualification:<br><br>=
<div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,18=
7);border-style:solid;border-width:1px;word-wrap:break-word">
<code><div><span style=3D"color:#008">class</span><span style> </span><span=
style=3D"color:#606">Seq</span><span style><br></span><span style=3D"color=
:#660">{</span><span style><br>=C2=A0 </span><span style=3D"color:#008">fri=
end</span><span style> ostream</span><span style=3D"color:#660">&</span=
><span style> </span><span style=3D"color:#008">operator</span><span style=
=3D"color:#660"><<(</span><span style>ostream</span><span style=3D"co=
lor:#660">&,</span><span style> </span><span style=3D"color:#606">Seq</=
span><span style=3D"color:#660">);</span><span style> </span><span style=3D=
"color:#800">// also class interface</span><span style><br>
<br>=C2=A0 </span><span style=3D"color:#008">friend</span><span style> </sp=
an><span style=3D"color:#606">Iter</span><span style> </span><span style=3D=
"color:#008">begin</span><span style=3D"color:#660">(</span><span style=3D"=
color:#606">Seq</span><span style> </span><span style=3D"color:#660">&)=
;</span><span style> </span><span style=3D"color:#800">// also class interf=
ace</span><span style><br>
=C2=A0 </span><span style=3D"color:#008">friend</span><span style> </span><=
span style=3D"color:#606">Iter</span><span style> </span><span style=3D"col=
or:#008">end</span><span style=3D"color:#660">(</span><span style=3D"color:=
#606">Seq</span><span style> </span><span style=3D"color:#660">&);</spa=
n><span style> </span><span style=3D"color:#800">// also class interface</s=
pan><span style><br>
</span><span style=3D"color:#660">};</span><span style><br></span></div></c=
ode></div><br><br>At first glance, it looks as a useful compliment to N3490=
and N3515. I wonder what you think?<br><br>Regards,<br>&rzej<br></bloc=
kquote>
<p></p>
-- <br>
=C2=A0<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den" target=3D"_blank">http://groups.google.com/a/isocpp=
..org/group/std-proposals/?hl=3Den</a>.<br>
=C2=A0<br>
=C2=A0<br>
</div></div></blockquote></div><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--f46d0401f93797c0f404d4c1a570--
.
Author: =?UTF-8?Q?Andrzej_Krzemie=C5=84ski?= <akrzemi1@gmail.com>
Date: Sat, 2 Feb 2013 11:51:19 -0800 (PST)
Raw View
------=_Part_1209_4608965.1359834679327
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
W dniu sobota, 2 lutego 2013 19:01:18 UTC+1 u=BFytkownik Micha=B3 Dominiak=
=20
napisa=B3:
>
> Hi,
>
> > //possibly in different file:
> > friend class Seq
> > {
> > Seq operator+(Seq, Seq);
> > void swap(Seq&, Seq&);=20
> > ostream& operator<<(ostream&, Seq);=20
> > Iter begin(Seq &);=20
> > Iter end(Seq &);=20
> > }
> > ; // the semicolon that ends class definition ISN'T NECESSARY HERE
>
> That definitely makes sense, although "friend class Seq" looks a bit=20
> surprising. I would consider leaving the syntax from OP, but also=20
> introducing the possibility to extend the interface in this way:
>
> class Seq
> {
> //...
> }
> friend
> {
> //...
> };
>
> // somewhere else
> class Seq friend
> {
> //...
> }; // I would leave this semicolon here
>
> (At least for me) this looks less surprising (it's not declaration of=20
> friend member class, but "friends" (=3D "non-member interface functions")=
of=20
> the class), is consistent with itself and allows a bit shorter syntax whe=
n=20
> declaring non-member interface "in place".
>
> Also, I agree with Ville on the fact that "friend" is a little awkward=20
> here.
>
>
Let's not get hung up on syntax too much. This can be changed to whatever.=
=20
The main points of this feature are:
1. The author of the class can specify functions that are not members,=
=20
but are part of class's interface.=20
2. No-one else can inject the additional non-member interface to your=20
class.
Regards,
&rzej
--=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/?hl=3Den.
------=_Part_1209_4608965.1359834679327
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
<br><br>W dniu sobota, 2 lutego 2013 19:01:18 UTC+1 u=BFytkownik Micha=B3 D=
ominiak napisa=B3:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"=
ltr">Hi,<div><br></div><div>> <span style=3D"font-family:arial,sans=
-serif;font-size:13px">//possibly in different file:</span></div><div style=
=3D"font-family:arial,sans-serif;font-size:13px">> friend class Seq<div>
> {<br>> Seq operator+(Seq, Seq);<br>> void swap(Seq&, Seq&=
;); <br>> ostream& operator<<(ostream&, Seq); <b=
r>> Iter begin(Seq &); <br>> Iter end(Seq &); <br>&=
gt; }<br></div>> ; // the semicolon that ends class definition ISN'T NEC=
ESSARY HERE</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><div s=
tyle=3D"font-family:arial,sans-serif;font-size:13px">That definitely makes =
sense, although "friend class Seq" looks a bit surprising. I would consider=
leaving the syntax from OP, but also introducing the possibility to extend=
the interface in this way:</div>
<div style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><div s=
tyle=3D"font-family:arial,sans-serif;font-size:13px">class Seq</div><div st=
yle=3D"font-family:arial,sans-serif;font-size:13px">{</div><div style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">
//...</div><div style=3D"font-family:arial,sans-serif;font-size:13px">}</di=
v><div style=3D"font-family:arial,sans-serif;font-size:13px">friend</div><d=
iv style=3D"font-family:arial,sans-serif;font-size:13px">{</div><div style=
=3D"font-family:arial,sans-serif;font-size:13px">
//...</div><div style=3D"font-family:arial,sans-serif;font-size:13px">};</d=
iv><div style=3D"font-family:arial,sans-serif;font-size:13px"><br></div><di=
v style=3D"font-family:arial,sans-serif;font-size:13px">// somewhere else</=
div>
<div style=3D"font-family:arial,sans-serif;font-size:13px">class Seq friend=
</div><div style=3D"font-family:arial,sans-serif;font-size:13px">{</div><di=
v style=3D"font-family:arial,sans-serif;font-size:13px">//...</div><div sty=
le=3D"font-family:arial,sans-serif;font-size:13px">
}; // I would leave this semicolon here</div><div style=3D"font-family:aria=
l,sans-serif;font-size:13px"><br></div><div style=3D"font-family:arial,sans=
-serif;font-size:13px"></div><div>(At least for me) this looks less surpris=
ing (it's not declaration of friend member class, but "friends" (=3D "non-m=
ember interface functions") of the class), is consistent with itself and al=
lows a bit shorter syntax when declaring non-member interface "in place".</=
div>
<div><br></div><div>Also, I agree with Ville on the fact that "friend" is a=
little awkward here.<br><br></div></div></blockquote><div><br>Let's not ge=
t hung up on syntax too much. This can be changed to whatever. The main poi=
nts of this feature are:<br><ol><li>The author of the class can specify fun=
ctions that are not members, but are part of class's interface. <br></li><l=
i>No-one else can inject the additional non-member interface to your class.=
</li></ol><p>Regards,<br>&rzej<br></p></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_1209_4608965.1359834679327--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Sat, 2 Feb 2013 21:57:05 +0200
Raw View
On 2 February 2013 21:51, Andrzej Krzemie=C5=84ski <akrzemi1@gmail.com> wro=
te:
>> Also, I agree with Ville on the fact that "friend" is a little awkward
>> here.
> Let's not get hung up on syntax too much. This can be changed to whatever=
..
> The main points of this feature are:
> The author of the class can specify functions that are not members, but a=
re
> part of class's interface.
> No-one else can inject the additional non-member interface to your class.
I agree with the soundness of the idea. My point about friendship
isn't syntactic, but semantic.
--=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/?hl=3Den.
.
Author: =?UTF-8?Q?Andrzej_Krzemie=C5=84ski?= <akrzemi1@gmail.com>
Date: Sat, 2 Feb 2013 12:38:18 -0800 (PST)
Raw View
------=_Part_542_20266445.1359837498749
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
W dniu sobota, 2 lutego 2013 20:57:05 UTC+1 u=BFytkownik Ville Voutilainen=
=20
napisa=B3:
>
> On 2 February 2013 21:51, Andrzej Krzemie=F1ski <akrz...@gmail.com<javasc=
ript:>>=20
> wrote:=20
> >> Also, I agree with Ville on the fact that "friend" is a little awkward=
=20
> >> here.=20
> > Let's not get hung up on syntax too much. This can be changed to=20
> whatever.=20
> > The main points of this feature are:=20
> > The author of the class can specify functions that are not members, but=
=20
> are=20
> > part of class's interface.=20
> > No-one else can inject the additional non-member interface to your=20
> class.=20
>
> I agree with the soundness of the idea. My point about friendship=20
> isn't syntactic, but semantic.=20
>
Choosing a different syntax, we express the same idea as:
class Seq
{
// normal members=20
=20
nonmember Seq operator+(Seq, Seq);
nonmember void swap(Seq&, Seq&);=20
nonmember ostream& operator<<(ostream&, Seq);=20
nonmember Iter begin(Seq &);=20
nonmember Iter end(Seq &);=20
};
"nonmember" being a hypothetical keyword indicating that it should be=20
treated as a free-standing function. In that case, the fact that the=20
function can access the guts of the class is natural; and sometimes useful.
Regards,
&rzej
--=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/?hl=3Den.
------=_Part_542_20266445.1359837498749
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<br><br>W dniu sobota, 2 lutego 2013 20:57:05 UTC+1 u=C5=BCytkownik Ville V=
outilainen napisa=C5=82:<blockquote class=3D"gmail_quote" style=3D"margin: =
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 2 F=
ebruary 2013 21:51, Andrzej Krzemie=C5=84ski <<a href=3D"javascript:" ta=
rget=3D"_blank" gdf-obfuscated-mailto=3D"luTcFgqsdpIJ">akrz...@gmail.com</a=
>> wrote:
<br>>> Also, I agree with Ville on the fact that "friend" is a little=
awkward
<br>>> here.
<br>> Let's not get hung up on syntax too much. This can be changed to w=
hatever.
<br>> The main points of this feature are:
<br>> The author of the class can specify functions that are not members=
, but are
<br>> part of class's interface.
<br>> No-one else can inject the additional non-member interface to your=
class.
<br>
<br>I agree with the soundness of the idea. My point about friendship
<br>isn't syntactic, but semantic.
<br></blockquote><div><br>Choosing a different syntax, we express the same =
idea as:<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(2=
50, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; borde=
r-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div clas=
s=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">class</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Seq</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> </span><span style=3D=
"color: #800;" class=3D"styled-by-prettify">// normal members </span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br> <br> n=
onmember </span><span style=3D"color: #606;" class=3D"styled-by-prettify">S=
eq</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">operator</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">+(</span><span styl=
e=3D"color: #606;" class=3D"styled-by-prettify">Seq</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: #606;" class=
=3D"styled-by-prettify">Seq</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br> nonmember </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> swap</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
Seq</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: #606;" class=3D"styled-by-prettify">Seq</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&);</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> <br> nonmember ostrea=
m</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify"><<(</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">ostream</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: #6=
06;" class=3D"styled-by-prettify">Seq</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> <br> nonmember </span><span style=3D"color: #606;=
" class=3D"styled-by-prettify">Iter</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">begin</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify=
">Seq</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&);</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> <br> nonme=
mber </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Iter<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">end</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #606;" class=3D"styled-by-prettify">Seq</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></span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br></span></div></code></div><br>"nonmember" being a hypothetical =
keyword indicating that it should be treated as a free-standing function. I=
n that case, the fact that the function can access the guts of the class is=
natural; and sometimes useful.<br><br>Regards,<br>&rzej<br><br><br></d=
iv>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_542_20266445.1359837498749--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Sat, 2 Feb 2013 22:49:03 +0200
Raw View
On 2 February 2013 22:38, Andrzej Krzemie=F1ski <akrzemi1@gmail.com> wrote:
> "nonmember" being a hypothetical keyword indicating that it should be
> treated as a free-standing function. In that case, the fact that the
> function can access the guts of the class is natural; and sometimes usefu=
l.
I think this is a valid proposal to consider. But again, access to the guts=
is
orthogonal. I don't claim it's not useful, but it's certainly something tha=
t
needs to be carefully considered as to whether it's the default or not.
To me it's not natural at all.
To take a step back to a bit more abstract plane, what about the "partial
class" idea that some languages (I think C#, for example) support?
That allows adding class members after the class has been defined.
I don't mean that we should do only that instead, I'm just curious
about the relation of this proposal and such after-the-fact members.
I would like to see a comparative analysis of those in a proposal.
--=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/?hl=3Den.
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sat, 2 Feb 2013 13:36:22 -0800 (PST)
Raw View
------=_Part_1437_14565639.1359840982773
Content-Type: text/plain; charset=ISO-8859-1
On Saturday, February 2, 2013 9:56:42 AM UTC-8, Ville Voutilainen wrote:
>
>
> ----- Original message -----
> > functions. One possible syntax for it is the following.
> > class Seq
> > {
> > // ...
> > }
> > friend
> > {
>
> The idea in general is interesting, but
> using friend to denote it is illogical.
> Remember that "Part of the interface" and
> "has access to the guts" are orthogonal.
>
One thing that I find confusing about this discussion is this: what *exactly
* does it mean to be "part of the interface" for a class? Is this only
about ADL, or is it about something else? Can a free function be part of
multiple class interfaces?
And if they are orthogonal, when would you want a free function to be part
of the interface and not a friend?
--
---
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/?hl=en.
------=_Part_1437_14565639.1359840982773
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
On Saturday, February 2, 2013 9:56:42 AM UTC-8, Ville Voutilainen wrote:<bl=
ockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border=
-left: 1px #ccc solid;padding-left: 1ex;">
<br>----- Original message -----
<br>> functions. One possible syntax for it is the following.
<br>> class Seq
<br>> {
<br>> // ...
<br>> }
<br>> friend
<br>> {
<br>
<br>The idea in general is interesting, but
<br>using friend to denote it is illogical.
<br>Remember that "Part of the interface" and=20
<br>"has access to the guts" are orthogonal.
<br></blockquote><div><br>One thing that I find confusing about this discus=
sion is this: what <i>exactly</i> does it mean to be "part of the interface=
" for a class? Is this only about ADL, or is it about something else? Can a=
free function be part of multiple class interfaces?<br><br>And if they are=
orthogonal, when would you want a free function to be part of the interfac=
e and not a friend?<br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_1437_14565639.1359840982773--
.
Author: =?UTF-8?Q?Andrzej_Krzemie=C5=84ski?= <akrzemi1@gmail.com>
Date: Sat, 2 Feb 2013 16:11:54 -0800 (PST)
Raw View
------=_Part_2062_17768448.1359850314033
Content-Type: text/plain; charset=ISO-8859-1
> To take a step back to a bit more abstract plane, what about the "partial
> class" idea that some languages (I think C#, for example) support?
> That allows adding class members after the class has been defined.
> I don't mean that we should do only that instead, I'm just curious
> about the relation of this proposal and such after-the-fact members.
> I would like to see a comparative analysis of those in a proposal.
>
I guess the example that fixed on a particular syntax unnecessarily caused
a connotation with partial classes. The proposal here is something
absolutely unrelated to partial classes and even comparing them would cause
an unnecessary confusion. Nonetheless, this is what I am about to do below
:(
"After-the-fact members" is something that partial class offers. Vicente's
proposal (I hope Vicente doesn't mind calling it this way. I just do not
want to take credit for something I didn't come up with.) doesn't allow
that. The "special members" are defined inside the class, before the author
finishes the class definition. Once he finishes, no-one can add a new
function to the interface. The only benefit from this proposal is that some
functions obtain a certain syntactic property, you do not have to use the
"dot" syntax when calling them, and they are included in the overload
resolution even if ADL is disabled.
class Seq
{
// normal members
nonmember Iter begin(Seq &);
};
void test(Seq & s)
{
auto i = bein(s);
}
--
---
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/?hl=en.
------=_Part_2062_17768448.1359850314033
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex=
;border-left: 1px #ccc solid;padding-left: 1ex;">To take a step back to a b=
it more abstract plane, what about the "partial
<br>class" idea that some languages (I think C#, for example) support?
<br>That allows adding class members after the class has been defined.
<br>I don't mean that we should do only that instead, I'm just curious
<br>about the relation of this proposal and such after-the-fact members.
<br>I would like to see a comparative analysis of those in a proposal.
<br></blockquote><div><br>I guess the example that fixed on a particular sy=
ntax unnecessarily caused a connotation with partial classes. The proposal =
here is something absolutely unrelated to partial classes and even comparin=
g them would cause an unnecessary confusion. Nonetheless, this is what I am=
about to do below :(<br><br>"After-the-fact members" is something that par=
tial class offers. Vicente's proposal (I hope Vicente doesn't mind calling =
it this way. I just do not want to take credit for something I didn't come =
up with.) doesn't allow that. The "special members" are defined inside the =
class, before the author finishes the class definition. Once he finishes, n=
o-one can add a new function to the interface. The only benefit from this p=
roposal is that some functions obtain a certain syntactic property, you do =
not have to use the "dot" syntax when calling them, and they are included i=
n the overload resolution even if ADL is disabled.<br><br><div style=3D"bac=
kground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:s=
olid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color=
:#008">class</span><span style=3D"color:#000"> </span><span style=3D"color:=
#606">Seq</span><span style=3D"color:#000"><br></span><span style=3D"color:=
#660">{</span><span style=3D"color:#000"><br> </span><span style=3D"c=
olor:#800">// normal members </span><span style=3D"color:#000"><br></span><=
span style=3D"color:#000"><br> nonmember </span><span style=3D"color:=
#606">Iter</span><span style=3D"color:#000"> </span><span style=3D"color:#0=
08">begin</span><span style=3D"color:#660">(</span><span style=3D"color:#60=
6">Seq</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
&);</span><span style=3D"color:#000"> </span><span style=3D"color:#000"=
><br></span><span style=3D"color:#660">};</span><span style=3D"color:#000">=
<br><br>void test(Seq & s)<br>{<br> auto i =3D bein(s);<br>}<br><=
/span></div></code></div><br><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_2062_17768448.1359850314033--
.
Author: =?UTF-8?Q?Andrzej_Krzemie=C5=84ski?= <akrzemi1@gmail.com>
Date: Sat, 2 Feb 2013 16:27:03 -0800 (PST)
Raw View
------=_Part_11_4265616.1359851223460
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
W dniu sobota, 2 lutego 2013 22:36:22 UTC+1 u=BFytkownik Nicol Bolas napisa=
=B3:
>
> On Saturday, February 2, 2013 9:56:42 AM UTC-8, Ville Voutilainen wrote:
>>
>>
>> ----- Original message -----=20
>> > functions. One possible syntax for it is the following.=20
>> > class Seq=20
>> > {=20
>> > // ...=20
>> > }=20
>> > friend=20
>> > {=20
>>
>> The idea in general is interesting, but=20
>> using friend to denote it is illogical.=20
>> Remember that "Part of the interface" and=20
>> "has access to the guts" are orthogonal.=20
>>
>
> One thing that I find confusing about this discussion is this: what *
> exactly* does it mean to be "part of the interface" for a class? Is this=
=20
> only about ADL, or is it about something else?=20
>
Note that if this proposal adds nothing useful to C++11. It will only prove=
=20
useful if N3490 ("Controlling Argument-Dependent Lookup") and/or N3515=20
("Toward Opaque Typedefs for C++1Y") are added to C++.
N3490 allows you to disable the ADL locally. "part of the interface" means=
=20
that if ADL is disabled, our function is still looked up: ADL is not=20
disabled for it.
N3515 proposes opaque typedefs. If OT is an opaque typedef for T, it=20
provides the same interface as T. There is this question what is T's=20
interface. In this context, "part of the interface" means that OT will also=
=20
provide this function (if T provides it).
=20
> Can a free function be part of multiple class interfaces?
>
No. At least at this point. All the practical use cases I was able to find=
=20
did not need it: arithmetic operators, ostream operators, swap, begin/end.
=20
>
> And if they are orthogonal, when would you want a free function to be par=
t=20
> of the interface and not a friend?
>
I personally do not see any security issue in granting any function that is=
=20
part of class's interface access to its guts. Especially, considering the=
=20
practical use cases that I was able to identify: arithmetic operators,=20
ostream operators, swap, begin/end. But strictly speaking, they are=20
orthogonal.
--=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/?hl=3Den.
------=_Part_11_4265616.1359851223460
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
<br><br>W dniu sobota, 2 lutego 2013 22:36:22 UTC+1 u=BFytkownik Nicol Bola=
s napisa=B3:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On Saturday, Febru=
ary 2, 2013 9:56:42 AM UTC-8, Ville Voutilainen wrote:<blockquote class=3D"=
gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid=
;padding-left:1ex">
<br>----- Original message -----
<br>> functions. One possible syntax for it is the following.
<br>> class Seq
<br>> {
<br>> // ...
<br>> }
<br>> friend
<br>> {
<br>
<br>The idea in general is interesting, but
<br>using friend to denote it is illogical.
<br>Remember that "Part of the interface" and=20
<br>"has access to the guts" are orthogonal.
<br></blockquote><div><br>One thing that I find confusing about this discus=
sion is this: what <i>exactly</i> does it mean to be "part of the interface=
" for a class? Is this only about ADL, or is it about something else? </div=
></blockquote><div><br>Note that if this proposal adds nothing useful to C+=
+11. It will only prove useful if N3490 ("Controlling Argument-Dependent Lo=
okup") and/or N3515 ("Toward Opaque Typedefs for C++1Y") are added to C++.<=
br><br>N3490 allows you to disable the ADL locally. "part of the interface"=
means that if ADL is disabled, our function is still looked up: ADL is not=
disabled for it.<br><br>N3515 proposes opaque typedefs. If OT is an opaque=
typedef for T, it provides the same interface as T. There is this question=
what is T's interface. In this context, "part of the interface" means that=
OT will also provide this function (if T provides it).<br> <br></div>=
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><div>Can a free function be pa=
rt of multiple class interfaces?<br></div></blockquote><div><br>No. At leas=
t at this point. All the practical use cases I was able to find did not nee=
d it: arithmetic operators, ostream operators, swap, begin/end.<br><br>&nbs=
p;<br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div><br>And if th=
ey are orthogonal, when would you want a free function to be part of the in=
terface and not a friend?<br></div></blockquote><div><br>I personally do no=
t see any security issue in granting any function that is part of class's i=
nterface access to its guts. Especially, considering the practical use case=
s that I was able to identify: arithmetic operators, ostream operators, swa=
p, begin/end. But strictly speaking, they are orthogonal.<br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_11_4265616.1359851223460--
.
Author: Tony <tvaneerd@gmail.com>
Date: Sun, 03 Feb 2013 05:40:20 -0000
Raw View
<html><head></head><body><br><hr><div><strong>From:</strong> "Andrzej Krzem=
ie=F1ski" <akrzemi1@gmail.com><br><strong>To:</strong> "std-proposals=
@isocpp.org" <std-proposals@isocpp.org><br><strong>CC:</strong> "Vill=
e Voutilainen" <ville.voutilainen@gmail.com><br><strong>Sent:</strong=
> February 3, 2013 12:27 AM<br><strong>Subject:</strong> Re: [std-proposals=
] probing interest: extended class interface<br></div><br><br><br>W dniu so=
bota, 2 lutego 2013 22:36:22 UTC+1 u=BFytkownik Nicol Bolas napisa=B3:<bloc=
kquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-l=
eft: 1px #ccc solid;padding-left: 1ex;">On Saturday, February 2, 2013 9:56:=
42 AM UTC-8, Ville Voutilainen wrote:<blockquote class=3D"gmail_quote" styl=
e=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex=
">
<br>----- Original message -----
<br>> functions. One possible syntax for it is the following.
<br>> class Seq
<br>> {
<br>> // ...
<br>> }
<br>> friend
<br>> {
<br>
<br>The idea in general is interesting, but
<br>using friend to denote it is illogical.
<br>Remember that "Part of the interface" and=20
<br>"has access to the guts" are orthogonal.
<br></blockquote><div><br>One thing that I find confusing about this discus=
sion is this: what <i>exactly</i> does it mean to be "part of the interface=
" for a class? Is this only about ADL, or is it about something else? </div=
></blockquote><div><br> <br></div><blockquote class=3D"gmail_quote" st=
yle=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-lef=
t: 1ex;"><div>Can a free function be part of multiple class interfaces?<br>=
</div></blockquote><div><br>> No. At least at this point. All the practi=
cal use cases I was able to find did not need it: arithmetic operators, ost=
ream operators, swap, begin/end.<br><br>Mixed relops?</div><div>bool operat=
or<(T, U) might be an interface of either or both T and U?<br></div><div=
><br></div><div>And if it is about ADL, maybe we should use 'using'?</div><=
div><br></div><div>class Seq using</div><div>{</div><div>...</div><div>};</=
div><div><br></div><div>Tony</div><div><br></div><div><br></div><blockquote=
class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1=
px #ccc solid;padding-left: 1ex;"><div><br></div><div><br></div></blockquot=
e>
<br>
</body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sun, 03 Feb 2013 11:03:16 +0100
Raw View
This is a multi-part message in MIME format.
--------------000702000209060506000606
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
Le 02/02/13 18:56, Ville Voutilainen a =E9crit :
> ----- Original message -----
>> functions. One possible syntax for it is the following.
>> class Seq
>> {
>> // ...
>> }
>> friend
>> {
> The idea in general is interesting, but
> using friend to denote it is illogical.
> Remember that "Part of the interface" and
> "has access to the guts" are orthogonal.
>
I agree, reusing friend here is not correct as it is orthogonal. My=20
initial proposal didn't included any keyword
class Seq
{
// ...
}
{
// ADL preserved non-member functions
};
I'm not against the introduction of a new keyword *nonmember* and moving=20
the non-member functions inside the class scope.
|classSeq
{
// ...
||*nonmember* Seqoperator+(Seq,Seq);
||||*nonmember*||||voidswap(Seq&,Seq&);
||||*nonmember*||||ostream&operator<<(ostream&,Seq);
||||*nonmember*||||Iterbegin(Seq&);
||||*nonmember*||||Iterend(Seq&);
};
|Best,
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/?hl=3Den.
--------------000702000209060506000606
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3DISO-8859-2"
http-equiv=3D"Content-Type">
</head>
<body bgcolor=3D"#FFFFFF" text=3D"#000000">
<div class=3D"moz-cite-prefix">Le 02/02/13 18:56, Ville Voutilainen a
=E9crit=A0:<br>
</div>
<blockquote cite=3D"mid:1359827802.1381.5.camel@Nokia-N900"
type=3D"cite">
<pre wrap=3D"">
----- Original message -----
</pre>
<blockquote type=3D"cite">
<pre wrap=3D"">functions. One possible syntax for it is the followi=
ng.
class Seq
{
=A0 =A0 // ...
}
friend
{
</pre>
</blockquote>
<pre wrap=3D"">
The idea in general is interesting, but
using friend to denote it is illogical.
Remember that "Part of the interface" and=20
"has access to the guts" are orthogonal.
</pre>
</blockquote>
I agree, reusing friend here is not correct as it is orthogonal. My
initial proposal didn't included any keyword<br>
<br>
<pre wrap=3D"">class Seq
{
=A0 =A0 // ...
}
{
// ADL preserved non-member functions=20
</pre>
};<br>
<br>
I'm not against the introduction of a new keyword <b>nonmember</b>
and moving the non-member functions inside the class scope. <br>
<br>
<code class=3D"prettyprint"><span style=3D"color: #008;"
class=3D"styled-by-prettify">class</span><span style=3D"color:
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color:
#606;" class=3D"styled-by-prettify">Seq</span><span style=3D"color:
#000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify=
">//
...</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=A0 =
</span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"><b>nonmember</b> </span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #008;" class=3D"styled-by-prettify">operator</span>=
<span
style=3D"color: #660;" class=3D"styled-by-prettify">+(</span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</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: #606;" class=3D"styled-by-prettify">Seq</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
=A0 </span></code><code class=3D"prettyprint"><span style=3D"color:
#000;" class=3D"styled-by-prettify"></span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"><b>nonmember</b></span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"><code class=3D"prettyprint"><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span></c=
ode></span><span
style=3D"color: #008;" class=3D"styled-by-prettify">void</span><spa=
n
style=3D"color: #000;" class=3D"styled-by-prettify"> swap</span><sp=
an
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">&,</span><s=
pan
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">&);</span><=
span
style=3D"color: #000;" class=3D"styled-by-prettify"> <br>
=A0 </span></code><code class=3D"prettyprint"><span style=3D"color:
#000;" class=3D"styled-by-prettify"></span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"><b>nonmember</b></span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"><code class=3D"prettyprint"><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span></c=
ode>ostream</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: #008;" class=3D"styled-by-prettify">operator</span>=
<span
style=3D"color: #660;" class=3D"styled-by-prettify"><<(</span=
><span
style=3D"color: #000;" class=3D"styled-by-prettify">ostream</span><=
span
style=3D"color: #660;" class=3D"styled-by-prettify">&,</span><s=
pan
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> <br>
=A0 </span></code><code class=3D"prettyprint"><span style=3D"color:
#000;" class=3D"styled-by-prettify"></span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"><b>nonmember</b></span></code><code
class=3D"prettyprint"><span style=3D"color: #606;"
class=3D"styled-by-prettify"><code class=3D"prettyprint"><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span></c=
ode>Iter</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #008;" class=3D"styled-by-prettify">begin</span><sp=
an
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</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>
=A0 </span></code><code class=3D"prettyprint"><span style=3D"color:
#000;" class=3D"styled-by-prettify"></span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"><b>nonmember</b></span></code><code
class=3D"prettyprint"><span style=3D"color: #606;"
class=3D"styled-by-prettify"><code class=3D"prettyprint"><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span></c=
ode>Iter</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #008;" class=3D"styled-by-prettify">end</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</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>
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</s=
pan><span
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> <br>
<br>
<br>
<br>
</span></code>Best,<br>
Vicente<br>
</body>
</html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--------------000702000209060506000606--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sun, 03 Feb 2013 11:07:31 +0100
Raw View
This is a multi-part message in MIME format.
--------------020001010901020000040802
Content-Type: text/plain; charset=ISO-8859-2; format=flowed
Content-Transfer-Encoding: quoted-printable
Le 03/02/13 06:40, Tony a =E9crit :
>
> ------------------------------------------------------------------------
> *From:* "Andrzej Krzemie=F1ski" <akrzemi1@gmail.com>
> *To:* "std-proposals@isocpp.org" <std-proposals@isocpp.org>
> *CC:* "Ville Voutilainen" <ville.voutilainen@gmail.com>
> *Sent:* February 3, 2013 12:27 AM
> *Subject:* Re: [std-proposals] probing interest: extended class interface
>
>
>
> W dniu sobota, 2 lutego 2013 22:36:22 UTC+1 u=BFytkownik Nicol Bolas=20
> napisa=B3:
>
> On Saturday, February 2, 2013 9:56:42 AM UTC-8, Ville Voutilainen
> wrote:
>
>
> ----- Original message -----
> > functions. One possible syntax for it is the following.
> > class Seq
> > {
> > // ...
> > }
> > friend
> > {
>
> The idea in general is interesting, but
> using friend to denote it is illogical.
> Remember that "Part of the interface" and
> "has access to the guts" are orthogonal.
>
>
> One thing that I find confusing about this discussion is this:
> what /exactly/ does it mean to be "part of the interface" for a
> class? Is this only about ADL, or is it about something else?
>
>
>
> Can a free function be part of multiple class interfaces?
>
>
> > No. At least at this point. All the practical use cases I was able=20
> to find did not need it: arithmetic operators, ostream operators,=20
> swap, begin/end.
>
> Mixed relops?
> bool operator<(T, U) might be an interface of either or both T and U?
I agree here. Non-member functions can be part of the interface of=20
multiple classes. I don't see where the problem could come from?
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/?hl=3Den.
--------------020001010901020000040802
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3DISO-8859-2"
http-equiv=3D"Content-Type">
</head>
<body bgcolor=3D"#FFFFFF" text=3D"#000000">
<div class=3D"moz-cite-prefix">Le 03/02/13 06:40, Tony a =E9crit=A0:<br=
>
</div>
<blockquote cite=3D"mid:510df846.e759320a.513b.4424@mx.google.com"
type=3D"cite"><br>
<hr>
<div><strong>From:</strong> "Andrzej Krzemie=F1ski"
<a class=3D"moz-txt-link-rfc2396E" href=3D"mailto:akrzemi1@gmail.co=
m"><akrzemi1@gmail.com></a><br>
<strong>To:</strong> <a class=3D"moz-txt-link-rfc2396E" href=3D"mai=
lto:std-proposals@isocpp.org">"std-proposals@isocpp.org"</a>
<a class=3D"moz-txt-link-rfc2396E" href=3D"mailto:std-proposals@iso=
cpp.org"><std-proposals@isocpp.org></a><br>
<strong>CC:</strong> "Ville Voutilainen"
<a class=3D"moz-txt-link-rfc2396E" href=3D"mailto:ville.voutilainen=
@gmail.com"><ville.voutilainen@gmail.com></a><br>
<strong>Sent:</strong> February 3, 2013 12:27 AM<br>
<strong>Subject:</strong> Re: [std-proposals] probing interest:
extended class interface<br>
</div>
<br>
<br>
<br>
W dniu sobota, 2 lutego 2013 22:36:22 UTC+1 u=BFytkownik Nicol Bolas
napisa=B3:
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On
Saturday, February 2, 2013 9:56:42 AM UTC-8, Ville Voutilainen
wrote:
<blockquote class=3D"gmail_quote"
style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc
solid;padding-left:1ex">
<br>
----- Original message -----
<br>
> functions. One possible syntax for it is the following.
<br>
> class Seq
<br>
> {
<br>
>=A0 =A0 =A0// ...
<br>
> }
<br>
> friend
<br>
> {
<br>
<br>
The idea in general is interesting, but
<br>
using friend to denote it is illogical.
<br>
Remember that "Part of the interface" and <br>
"has access to the guts" are orthogonal.
<br>
</blockquote>
<div><br>
One thing that I find confusing about this discussion is this:
what <i>exactly</i> does it mean to be "part of the
interface" for a class? Is this only about ADL, or is it about
something else? </div>
</blockquote>
<div><br>
=A0<br>
</div>
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<div>Can a free function be part of multiple class interfaces?<br>
</div>
</blockquote>
<div><br>
> No. At least at this point. All the practical use cases I
was able to find did not need it: arithmetic operators, ostream
operators, swap, begin/end.<br>
<br>
Mixed relops?</div>
<div>bool operator<(T, U) might be an interface of either or
both T and U?<br>
</div>
</blockquote>
<br>
I agree here. Non-member functions can be part of the interface of
multiple classes. I don't see where the problem could come from?<br>
<br>
Vicente<br>
<br>
<br>
</body>
</html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--------------020001010901020000040802--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sun, 03 Feb 2013 12:12:46 +0100
Raw View
This is a multi-part message in MIME format.
--------------040806090606020603060208
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
Le 03/02/13 01:11, Andrzej Krzemien'ski a =E9crit :
>
> To take a step back to a bit more abstract plane, what about the
> "partial
> class" idea that some languages (I think C#, for example) support?
> That allows adding class members after the class has been defined.
> I don't mean that we should do only that instead, I'm just curious
> about the relation of this proposal and such after-the-fact members.
> I would like to see a comparative analysis of those in a proposal.
>
>
> I guess the example that fixed on a particular syntax unnecessarily=20
> caused a connotation with partial classes. The proposal here is=20
> something absolutely unrelated to partial classes and even comparing=20
> them would cause an unnecessary confusion. Nonetheless, this is what I=20
> am about to do below :(
>
> "After-the-fact members" is something that partial class offers.=20
> Vicente's proposal (I hope Vicente doesn't mind calling it this way. I=20
> just do not want to take credit for something I didn't come up with.)=20
> doesn't allow that. The "special members" are defined inside the=20
> class, before the author finishes the class definition. Once he=20
> finishes, no-one can add a new function to the interface. The only=20
> benefit from this proposal is that some functions obtain a certain=20
> syntactic property, you do not have to use the "dot" syntax when=20
> calling them, and they are included in the overload resolution even if=20
> ADL is disabled.
Andrzej you can take the credit as the problem I was trying to solve was=20
not related to ADL ;-)
>
> |
> classSeq
> {
> // normal members
>
> nonmember Iterbegin(Seq&);
> };
>
> void test(Seq & s)
> {
> auto i =3D begin(s);
> }
> |
>
>
Partial class definition solves partially the ADL issue Andrzej is=20
trying to solve as the intent of partial classes is to extend the class=20
interface but using member function call notation.
Thus, if we use partial classes we add a new member function but we=20
don't associate an existing non-member function to the interface.
|
classSeq
{
// normal members
};
namespace class Seq
{
// added *member*
|Iterbegin();
|};
void test(Seq & s)
{
auto i =3D s.begin();
}
|
I said partially, because even if the call systax s.begin() doesn't need=20
ADL it doesn't allows to manage with non-member function (in particular=20
operators overloading);
The specificity of this proposal is that it adds a non-member existing=20
function to the 'ADL set' of a class. I don't know how the partial class=20
proposal N1420 could do that as IIUC it can be used only to add new=20
functions.
|
namespace class Seq
{
// added *static* *member*
|static Iterbegin(Seq &);
|};
void test(Seq & s)
{
auto i =3D S::begin(s);
}
|
If partial classes was adopted, the question of whether these functions=20
are part of the class interface and whether we let use nonmember=20
functions is open.
|
namespace class Seq
{
// added *non-member*
|*nonmember* Iterbegin(Seq &);
|};
void test(Seq & s)
{
auto i =3D begin(s);
}
|
Best,
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/?hl=3Den.
--------------040806090606020603060208
Content-Type: text/html; charset=ISO-8859-1
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Le 03/02/13 01:11, Andrzej Krzemieński
a écrit :<br>
</div>
<blockquote
cite="mid:72b03764-99f4-47a6-b440-a4828b91ebcb@isocpp.org"
type="cite"><br>
<blockquote class="gmail_quote" style="margin: 0;margin-left:
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">To take a
step back to a bit more abstract plane, what about the "partial
<br>
class" idea that some languages (I think C#, for example)
support?
<br>
That allows adding class members after the class has been
defined.
<br>
I don't mean that we should do only that instead, I'm just
curious
<br>
about the relation of this proposal and such after-the-fact
members.
<br>
I would like to see a comparative analysis of those in a
proposal.
<br>
</blockquote>
<div><br>
I guess the example that fixed on a particular syntax
unnecessarily caused a connotation with partial classes. The
proposal here is something absolutely unrelated to partial
classes and even comparing them would cause an unnecessary
confusion. Nonetheless, this is what I am about to do below :(<br>
<br>
"After-the-fact members" is something that partial class offers.
Vicente's proposal (I hope Vicente doesn't mind calling it this
way. I just do not want to take credit for something I didn't
come up with.) doesn't allow that. The "special members" are
defined inside the class, before the author finishes the class
definition. Once he finishes, no-one can add a new function to
the interface. The only benefit from this proposal is that some
functions obtain a certain syntactic property, you do not have
to use the "dot" syntax when calling them, and they are included
in the overload resolution even if ADL is disabled.<br>
</div>
</blockquote>
Andrzej you can take the credit as the problem I was trying to solve
was not related to ADL ;-)<br>
<blockquote
cite="mid:72b03764-99f4-47a6-b440-a4828b91ebcb@isocpp.org"
type="cite">
<div><br>
<div
style="background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><code>
<div><span style="color:#008">class</span><span
style="color:#000"> </span><span style="color:#606">Seq</span><span
style="color:#000"><br>
</span><span style="color:#660">{</span><span
style="color:#000"><br>
</span><span style="color:#800">// normal members </span><span
style="color:#000"><br>
</span><span style="color:#000"><br>
nonmember </span><span style="color:#606">Iter</span><span
style="color:#000"> </span><span style="color:#008">begin</span><span
style="color:#660">(</span><span style="color:#606">Seq</span><span
style="color:#000"> </span><span style="color:#660">&);</span><span
style="color:#000"> </span><span style="color:#000"><br>
</span><span style="color:#660">};</span><span
style="color:#000"><br>
<br>
void test(Seq & s)<br>
{<br>
auto i = begin(s);<br>
}<br>
</span></div>
</code></div>
<br>
<br>
</div>
</blockquote>
Partial class definition solves partially the ADL issue Andrzej is
trying to solve as the intent of partial classes is to extend the
class interface but using member function call notation.<br>
Thus, if we use partial classes we add a new member function but we
don't associate an existing non-member function to the interface.<br>
<br>
<div
style="background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><code>
<div><span style="color:#008">class</span><span
style="color:#000"> </span><span style="color:#606">Seq</span><span
style="color:#000"><br>
</span><span style="color:#660">{</span><span
style="color:#000"><br>
</span><span style="color:#800">// normal members </span><span
style="color:#000"><br>
</span><span style="color:#000"><br>
</span><span style="color:#660">};</span><span
style="color:#000"><br>
<br>
namespace class Seq <br>
{<br>
// added <b>member</b><br>
</span><span style="color:#000"><code><span style="color:#000">
</span><span style="color:#606">Iter</span><span
style="color:#000"> </span><span style="color:#008">begin</span><span
style="color:#660">(</span><span style="color:#660">);</span><span
style="color:#000"> </span><span style="color:#000"><br>
</span><span style="color:#660"></span></code>};<br>
<br>
void test(Seq & s)<br>
{<br>
auto i = s.begin();<br>
}<br>
</span></div>
</code></div>
<br>
I said partially, because even if the call systax s.begin() doesn't
need ADL it doesn't allows to manage with non-member function (in
particular operators overloading);<br>
<br>
The specificity of this proposal is that it adds a non-member
existing function to the 'ADL set' of a class. I don't know how the
partial class proposal N1420 could do that as IIUC it can be used
only to add new functions.<br>
<br>
<div
style="background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><code>
<div><span style="color:#000"><br>
namespace class Seq <br>
{<br>
// added <b>static</b> <b>member</b><br>
</span><span style="color:#000"><code><span style="color:#000">
static </span><span style="color:#606">Iter</span><span
style="color:#000"> </span><span style="color:#008">begin</span><span
style="color:#660">(</span><span style="color:#660">Seq
&);</span><span style="color:#000"> </span><span
style="color:#000"><br>
</span><span style="color:#660"></span></code>};<br>
<br>
void test(Seq & s)<br>
{<br>
auto i = S::begin(s);<br>
}<br>
</span></div>
</code></div>
<br>
If partial classes was adopted, the question of whether these
functions are part of the class interface and whether we let use
nonmember functions is open. <br>
<br>
<div
style="background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><code>
<div><span style="color:#000"><br>
namespace class Seq <br>
{<br>
// added <b>non-member</b><br>
</span><span style="color:#000"><code><span style="color:#000">
<b>nonmember</b> </span><span style="color:#606">Iter</span><span
style="color:#000"> </span><span style="color:#008">begin</span><span
style="color:#660">(</span><span style="color:#660">Seq
&);</span><span style="color:#000"> </span><span
style="color:#000"><br>
</span><span style="color:#660"></span></code>};<br>
<br>
void test(Seq & s)<br>
{<br>
auto i = begin(s);<br>
}<br>
</span></div>
</code></div>
<br>
<br>
Best,<br>
Vicente<br>
</body>
</html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" 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/?hl=en">http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en</a>.<br />
<br />
<br />
--------------040806090606020603060208--
.
Author: =?UTF-8?Q?Andrzej_Krzemie=C5=84ski?= <akrzemi1@gmail.com>
Date: Mon, 4 Feb 2013 03:03:04 -0800 (PST)
Raw View
------=_Part_321_32721513.1359975784802
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
W dniu sobota, 2 lutego 2013 22:36:22 UTC+1 u=BFytkownik Nicol Bolas napisa=
=B3:
>
> On Saturday, February 2, 2013 9:56:42 AM UTC-8, Ville Voutilainen wrote:
>>
>>
>> ----- Original message -----=20
>> > functions. One possible syntax for it is the following.=20
>> > class Seq=20
>> > {=20
>> > // ...=20
>> > }=20
>> > friend=20
>> > {=20
>>
>> The idea in general is interesting, but=20
>> using friend to denote it is illogical.=20
>> Remember that "Part of the interface" and=20
>> "has access to the guts" are orthogonal.=20
>>
>
> One thing that I find confusing about this discussion is this: what *
> exactly* does it mean to be "part of the interface" for a class? Is this=
=20
> only about ADL, or is it about something else? Can a free function be par=
t=20
> of multiple class interfaces?
>
> And if they are orthogonal, when would you want a free function to be par=
t=20
> of the interface and not a friend?
>
This idea can definitely be extended/improved to cover the cases of=20
functions belonging to two classes and address the separation of=20
befriending with being the part of the interface.=20
At this point I was trying to get feedback, especially from the Committee=
=20
members, if this is worth investing time in such proposal. If the potential=
=20
benefits compensate the time spent on analyzing the proposal details in the=
=20
Committee.
Regards,
&rzej
--=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/?hl=3Den.
------=_Part_321_32721513.1359975784802
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
<br><br>W dniu sobota, 2 lutego 2013 22:36:22 UTC+1 u=BFytkownik Nicol Bola=
s napisa=B3:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On Saturday, Febru=
ary 2, 2013 9:56:42 AM UTC-8, Ville Voutilainen wrote:<blockquote class=3D"=
gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid=
;padding-left:1ex">
<br>----- Original message -----
<br>> functions. One possible syntax for it is the following.
<br>> class Seq
<br>> {
<br>> // ...
<br>> }
<br>> friend
<br>> {
<br>
<br>The idea in general is interesting, but
<br>using friend to denote it is illogical.
<br>Remember that "Part of the interface" and=20
<br>"has access to the guts" are orthogonal.
<br></blockquote><div><br>One thing that I find confusing about this discus=
sion is this: what <i>exactly</i> does it mean to be "part of the interface=
" for a class? Is this only about ADL, or is it about something else? Can a=
free function be part of multiple class interfaces?<br><br>And if they are=
orthogonal, when would you want a free function to be part of the interfac=
e and not a friend?<br></div></blockquote><div><br>This idea can definitely=
be extended/improved to cover the cases of functions belonging to two clas=
ses and address the separation of befriending with being the part of the in=
terface. <br><br>At this point I was trying to get feedback, especially fro=
m the Committee members, if this is worth investing time in such proposal. =
If the potential benefits compensate the time spent on analyzing the propos=
al details in the Committee.<br><br>Regards,<br>&rzej<br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_321_32721513.1359975784802--
.
Author: Dave Abrahams <dave@boostpro.com>
Date: Mon, 4 Feb 2013 05:50:26 -0800 (PST)
Raw View
------=_Part_545_4719341.1359985826845
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Saturday, February 2, 2013 8:59:28 AM UTC-5, Andrzej Krzemie=C5=84ski wr=
ote:
>
> I would like to throw an idea at people in this forum, and check if you=
=20
> consider it a useful addition to C++ language. It is an elaboration on th=
e=20
> idea suggested by Vicente J. Botet Escriba:=20
> https://groups.google.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/FJ=
eR8QL3pBcJ
> .
>
> It is based on observation that the interface of a class type consists no=
t=20
> only of its member functions, but also of some non-member functions:
>
> class Seq
> {
> // ...
> };
>
> Seq operator+(Seq, Seq); // also class interface
> void swap(Seq&, Seq&); // also class interface
> ostream& operator<<(ostream&, Seq); // also class interface
> Iter begin(Seq &); // also class interface
> Iter end(Seq &); // also class interface
>
> // ...
> bool has_duplicates(Seq const&) // not an interface
>
> "Being a class interface" means when I use my class, I also want these=20
> functions to be considered in overload resolution. ADL does enable this,=
=20
> however it also imports anything from our namespace, which is often far t=
oo=20
> much.
>
> N3490 proposes to disable ADL in a controlled way. But for functions that=
=20
> we consider an "extended class interface", we still would like the ADL to=
=20
> work.=20
>
>
I disagree with the premise here. If I write a function f() that calls a=
=20
helper function has_duplicates in the same namespace, the semantics of my=
=20
has_duplicates and those of the has_duplicates in Seq's namespace, even=20
with such a very specific name, are quite likely to be different (either=20
slightly or dramatically). The problem is that it's easy and natural to=20
write an unqualified call under the assumption that "that function right=20
over there, in the same namespace" will be called. This is the trap that=
=20
causes problems with ADL, and if you leave it in place, you haven't solved=
=20
any problems.
--=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/?hl=3Den.
------=_Part_545_4719341.1359985826845
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<br><br>On Saturday, February 2, 2013 8:59:28 AM UTC-5, Andrzej Krzemie=C5=
=84ski wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">I would like to t=
hrow an idea at people in this forum, and check if you=20
consider it a useful addition to C++ language. It is an elaboration on=20
the idea suggested by Vicente J. Botet Escriba: <a href=3D"https://groups.g=
oogle.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/FJeR8QL3pBcJ" target=
=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msg/std-<wbr>prop=
osals/-u6e-rohWXM/<wbr>FJeR8QL3pBcJ</a>.<br><br>It
is based on observation that the interface of a class type consists not
only of its member functions, but also of some non-member functions:<br><b=
r><div 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><div><=
span style=3D"color:#008">class</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#606">Seq</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#660">{</span><span style=3D"color:#000"><br> </sp=
an><span style=3D"color:#800">// ...</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br><b=
r></span><span style=3D"color:#606">Seq</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">operator</span><span style=3D"color:#660">=
+(</span><span style=3D"color:#606">Seq</span><span style=3D"color:#660">,<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#606">Seq</sp=
an><span style=3D"color:#660">);</span><span style=3D"color:#000"> </span><=
span style=3D"color:#800">// also class interface</span><span style=3D"colo=
r:#000"><br></span><span style=3D"color:#008">void</span><span style=3D"col=
or:#000"> swap</span><span style=3D"color:#660">(</span><span style=3D"colo=
r:#606">Seq</span><span style=3D"color:#660">&,</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#606">Seq</span><span style=3D"color=
:#660">&);</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#800">// also class interface</span><span style=3D"color:#000"><br>ostrea=
m</span><span style=3D"color:#660">&</span><span style=3D"color:#000"> =
</span><span style=3D"color:#008">operator</span><span style=3D"color:#660"=
><<(</span><span style=3D"color:#000">ostream</span><span style=3D"co=
lor:#660">&,</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#606">Seq</span><span style=3D"color:#660">);</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#800">// also class interface</span><s=
pan style=3D"color:#000"><br></span><span style=3D"color:#606">Iter</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">begin</span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#606">Seq</span><span=
style=3D"color:#000"> </span><span style=3D"color:#660">&);</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#800">// also class int=
erface</span><span style=3D"color:#000"><br></span><span style=3D"color:#60=
6">Iter</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>end</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Se=
q</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&=
);</span><span style=3D"color:#000"> </span><span style=3D"color:#800">// a=
lso class interface</span><span style=3D"color:#000"><br><br></span><span s=
tyle=3D"color:#800">// ...</span><span style=3D"color:#000"><br></span><spa=
n style=3D"color:#008">bool</span><span style=3D"color:#000"> has_duplicate=
s</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Seq</=
span><span style=3D"color:#000"> </span><span style=3D"color:#008">const</s=
pan><span style=3D"color:#660">&)</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#800">// not an interface</span><span style=3D"col=
or:#000"><br></span></div></code></div><br>"Being
a class interface" means when I use my class, I also want these=20
functions to be considered in overload resolution. ADL does enable this,
however it also imports anything from our namespace, which is often far
too much.<br><br>N3490 proposes to disable ADL in a controlled way. But
for functions that we consider an "extended class interface", we still=20
would like the ADL to work. <br><br></blockquote><div><br></div><div>I disa=
gree with the premise here. If I write a function f() that calls a he=
lper function has_duplicates in the same namespace, the semantics of my has=
_duplicates and those of the has_duplicates in Seq's namespace, even with s=
uch a very specific name, are quite likely to be different (either slightly=
or dramatically). The problem is that it's easy and natural to write=
an unqualified call under the assumption that "that function right over th=
ere, in the same namespace" will be called. This is the trap that cau=
ses problems with ADL, and if you leave it in place, you haven't solved any=
problems.</div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_545_4719341.1359985826845--
.
Author: =?UTF-8?Q?Andrzej_Krzemie=C5=84ski?= <akrzemi1@gmail.com>
Date: Mon, 4 Feb 2013 06:21:20 -0800 (PST)
Raw View
------=_Part_436_6304886.1359987680606
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
W dniu poniedzia=B3ek, 4 lutego 2013 14:50:26 UTC+1 u=BFytkownik Dave Abrah=
ams=20
napisa=B3:
>
>
>
> On Saturday, February 2, 2013 8:59:28 AM UTC-5, Andrzej Krzemie=F1ski wro=
te:
>>
>> I would like to throw an idea at people in this forum, and check if you=
=20
>> consider it a useful addition to C++ language. It is an elaboration on t=
he=20
>> idea suggested by Vicente J. Botet Escriba:=20
>> https://groups.google.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/F=
JeR8QL3pBcJ
>> .
>>
>> It is based on observation that the interface of a class type consists=
=20
>> not only of its member functions, but also of some non-member functions:
>>
>> class Seq
>> {
>> // ...
>> };
>>
>> Seq operator+(Seq, Seq); // also class interface
>> void swap(Seq&, Seq&); // also class interface
>> ostream& operator<<(ostream&, Seq); // also class interface
>> Iter begin(Seq &); // also class interface
>> Iter end(Seq &); // also class interface
>>
>> // ...
>> bool has_duplicates(Seq const&) // not an interface
>>
>> "Being a class interface" means when I use my class, I also want these=
=20
>> functions to be considered in overload resolution. ADL does enable this,=
=20
>> however it also imports anything from our namespace, which is often far =
too=20
>> much.
>>
>> N3490 proposes to disable ADL in a controlled way. But for functions tha=
t=20
>> we consider an "extended class interface", we still would like the ADL t=
o=20
>> work.=20
>>
>>
> I disagree with the premise here. If I write a function f() that calls a=
=20
> helper function has_duplicates in the same namespace, the semantics of my=
=20
> has_duplicates and those of the has_duplicates in Seq's namespace, even=
=20
> with such a very specific name, are quite likely to be different (either=
=20
> slightly or dramatically). The problem is that it's easy and natural to=
=20
> write an unqualified call under the assumption that "that function right=
=20
> over there, in the same namespace" will be called. This is the trap that=
=20
> causes problems with ADL, and if you leave it in place, you haven't solve=
d=20
> any problems.
>
This is true in general. The motivation for this proposal was that some=20
functions are special, and for these you would not like to define overloads=
=20
in your own namespace. These special functions include ostream operators <<=
=20
and >> and functions begin(), end() and swap() which have so special=20
semantics already that they can be considered operators. But you are right=
=20
that once such feature is in place, everyone could abuse it for any purpose=
=20
and the ADL problem would be back.
Thanks,
&rzej
--=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/?hl=3Den.
------=_Part_436_6304886.1359987680606
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
<br><br>W dniu poniedzia=B3ek, 4 lutego 2013 14:50:26 UTC+1 u=BFytkownik Da=
ve Abrahams napisa=B3:<blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><br><br>=
On Saturday, February 2, 2013 8:59:28 AM UTC-5, Andrzej Krzemie=F1ski wrote=
:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bord=
er-left:1px #ccc solid;padding-left:1ex">I would like to throw an idea at p=
eople in this forum, and check if you=20
consider it a useful addition to C++ language. It is an elaboration on=20
the idea suggested by Vicente J. Botet Escriba: <a href=3D"https://groups.g=
oogle.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/FJeR8QL3pBcJ" target=
=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msg/std-<wbr>prop=
osals/-u6e-rohWXM/<wbr>FJeR8QL3pBcJ</a>.<br><br>It
is based on observation that the interface of a class type consists not
only of its member functions, but also of some non-member functions:<br><b=
r><div 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><div><=
span style=3D"color:#008">class</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#606">Seq</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#660">{</span><span style=3D"color:#000"><br> </sp=
an><span style=3D"color:#800">// ...</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br><b=
r></span><span style=3D"color:#606">Seq</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">operator</span><span style=3D"color:#660">=
+(</span><span style=3D"color:#606">Seq</span><span style=3D"color:#660">,<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#606">Seq</sp=
an><span style=3D"color:#660">);</span><span style=3D"color:#000"> </span><=
span style=3D"color:#800">// also class interface</span><span style=3D"colo=
r:#000"><br></span><span style=3D"color:#008">void</span><span style=3D"col=
or:#000"> swap</span><span style=3D"color:#660">(</span><span style=3D"colo=
r:#606">Seq</span><span style=3D"color:#660">&,</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#606">Seq</span><span style=3D"color=
:#660">&);</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#800">// also class interface</span><span style=3D"color:#000"><br>ostrea=
m</span><span style=3D"color:#660">&</span><span style=3D"color:#000"> =
</span><span style=3D"color:#008">operator</span><span style=3D"color:#660"=
><<(</span><span style=3D"color:#000">ostream</span><span style=3D"co=
lor:#660">&,</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#606">Seq</span><span style=3D"color:#660">);</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#800">// also class interface</span><s=
pan style=3D"color:#000"><br></span><span style=3D"color:#606">Iter</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">begin</span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#606">Seq</span><span=
style=3D"color:#000"> </span><span style=3D"color:#660">&);</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#800">// also class int=
erface</span><span style=3D"color:#000"><br></span><span style=3D"color:#60=
6">Iter</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>end</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Se=
q</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&=
);</span><span style=3D"color:#000"> </span><span style=3D"color:#800">// a=
lso class interface</span><span style=3D"color:#000"><br><br></span><span s=
tyle=3D"color:#800">// ...</span><span style=3D"color:#000"><br></span><spa=
n style=3D"color:#008">bool</span><span style=3D"color:#000"> has_duplicate=
s</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Seq</=
span><span style=3D"color:#000"> </span><span style=3D"color:#008">const</s=
pan><span style=3D"color:#660">&)</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#800">// not an interface</span><span style=3D"col=
or:#000"><br></span></div></code></div><br>"Being
a class interface" means when I use my class, I also want these=20
functions to be considered in overload resolution. ADL does enable this,
however it also imports anything from our namespace, which is often far
too much.<br><br>N3490 proposes to disable ADL in a controlled way. But
for functions that we consider an "extended class interface", we still=20
would like the ADL to work. <br><br></blockquote><div><br></div><div>I disa=
gree with the premise here. If I write a function f() that calls a he=
lper function has_duplicates in the same namespace, the semantics of my has=
_duplicates and those of the has_duplicates in Seq's namespace, even with s=
uch a very specific name, are quite likely to be different (either slightly=
or dramatically). The problem is that it's easy and natural to write=
an unqualified call under the assumption that "that function right over th=
ere, in the same namespace" will be called. This is the trap that cau=
ses problems with ADL, and if you leave it in place, you haven't solved any=
problems.</div></blockquote><div><br>This is true in general. The motivati=
on for this proposal was that some functions are special, and for these you=
would not like to define overloads in your own namespace. These special fu=
nctions include ostream operators << and >> and functions begin=
(), end() and swap() which have so special semantics already that they can =
be considered operators. But you are right that once such feature is in pla=
ce, everyone could abuse it for any purpose and the ADL problem would be ba=
ck.<br><br>Thanks,<br>&rzej<br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_436_6304886.1359987680606--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Mon, 04 Feb 2013 18:12:23 +0100
Raw View
This is a multi-part message in MIME format.
--------------060105020207000708060705
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
Le 03/02/13 11:03, Vicente J. Botet Escriba a =E9crit :
> Le 02/02/13 18:56, Ville Voutilainen a =E9crit :
>> ----- Original message -----
>>
>
> I'm not against the introduction of a new keyword *nonmember* and=20
> moving the non-member functions inside the class scope.
>
> |classSeq
> {
> // ...
> ||*nonmember* Seqoperator+(Seq,Seq);
> ||||*nonmember*||||voidswap(Seq&,Seq&);
> ||||*nonmember*||||ostream&operator<<(ostream&,Seq);
> ||||*nonmember*||||Iterbegin(Seq&);
> ||||*nonmember*||||Iterend(Seq&);
> };
>
> |
An alternative could also be to use nonmember: as=20
public/protected/private are used
|classSeq
{
// ...
||*nonmember*:
Seqoperator+(Seq,Seq);
||||||voidswap(Seq&,Seq&);
||||||ostream&operator<<(ostream&,Seq);
||||||Iterbegin(Seq&);
||||||Iterend(Seq&);
};
|
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/?hl=3Den.
--------------060105020207000708060705
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3DISO-8859-2"
http-equiv=3D"Content-Type">
</head>
<body bgcolor=3D"#FFFFFF" text=3D"#000000">
<div class=3D"moz-cite-prefix">Le 03/02/13 11:03, Vicente J. Botet
Escriba a =E9crit=A0:<br>
</div>
<blockquote cite=3D"mid:510E35E4.1080802@wanadoo.fr" type=3D"cite">
<meta content=3D"text/html; charset=3DISO-8859-2"
http-equiv=3D"Content-Type">
<div class=3D"moz-cite-prefix">Le 02/02/13 18:56, Ville Voutilainen
a =E9crit=A0:<br>
</div>
<blockquote cite=3D"mid:1359827802.1381.5.camel@Nokia-N900"
type=3D"cite">
<pre wrap=3D"">----- Original message -----
</pre>
<br>
</blockquote>
<br>
I'm not against the introduction of a new keyword <b>nonmember</b>
and moving the non-member functions inside the class scope. <br>
<br>
<code class=3D"prettyprint"><span style=3D"color: #008;"
class=3D"styled-by-prettify">class</span><span style=3D"color:
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color:
#606;" class=3D"styled-by-prettify">Seq</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>
=A0 </span><span style=3D"color: #800;"
class=3D"styled-by-prettify">// ...</span><span style=3D"color:
#000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
=A0 </span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"><b>nonmember</b> </span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><sp=
an
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #008;" class=3D"styled-by-prettify">operator</spa=
n><span
style=3D"color: #660;" class=3D"styled-by-prettify">+(</span><spa=
n
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><sp=
an
style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><sp=
an
style=3D"color: #660;" class=3D"styled-by-prettify">);</span><spa=
n
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
=A0 </span></code><code class=3D"prettyprint"><span style=3D"colo=
r:
#000;" class=3D"styled-by-prettify"></span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"><b>nonmember</b></span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"><code class=3D"prettyprint"><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
/code></span><span
style=3D"color: #008;" class=3D"styled-by-prettify">void</span><s=
pan
style=3D"color: #000;" class=3D"styled-by-prettify"> swap</span><=
span
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><sp=
an
style=3D"color: #660;" class=3D"styled-by-prettify">&,</span>=
<span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><sp=
an
style=3D"color: #660;" class=3D"styled-by-prettify">&);</span=
><span
style=3D"color: #000;" class=3D"styled-by-prettify"> <br>
=A0 </span></code><code class=3D"prettyprint"><span style=3D"colo=
r:
#000;" class=3D"styled-by-prettify"></span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"><b>nonmember</b></span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"><code class=3D"prettyprint"><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
/code>ostream</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">&</span><=
span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #008;" class=3D"styled-by-prettify">operator</spa=
n><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<(</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify">ostream</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: #606;" class=3D"styled-by-prettify">Seq</span><sp=
an
style=3D"color: #660;" class=3D"styled-by-prettify">);</span><spa=
n
style=3D"color: #000;" class=3D"styled-by-prettify"> <br>
=A0 </span></code><code class=3D"prettyprint"><span style=3D"colo=
r:
#000;" class=3D"styled-by-prettify"></span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"><b>nonmember</b></span></code><code
class=3D"prettyprint"><span style=3D"color: #606;"
class=3D"styled-by-prettify"><code class=3D"prettyprint"><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
/code>Iter</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #008;" class=3D"styled-by-prettify">begin</span><=
span
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</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"> <br>
=A0 </span></code><code class=3D"prettyprint"><span style=3D"colo=
r:
#000;" class=3D"styled-by-prettify"></span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"><b>nonmember</b></span></code><code
class=3D"prettyprint"><span style=3D"color: #606;"
class=3D"styled-by-prettify"><code class=3D"prettyprint"><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
/code>Iter</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #008;" class=3D"styled-by-prettify">end</span><sp=
an
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</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"> <br>
</span><span style=3D"color: #660;" 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></code><br>
</blockquote>
An alternative could also be to use nonmember: as
public/protected/private are used<br>
<br>
<code class=3D"prettyprint"><span style=3D"color: #008;"
class=3D"styled-by-prettify">class</span><span style=3D"color:
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color:
#606;" class=3D"styled-by-prettify">Seq</span><span style=3D"color:
#000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify=
">//
...</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>
</span></code><code class=3D"prettyprint"><span style=3D"color: #000;=
"
class=3D"styled-by-prettify"><b>nonmember</b>:<br>
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">=A0 =
Seq</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #008;" class=3D"styled-by-prettify">operator</span>=
<span
style=3D"color: #660;" class=3D"styled-by-prettify">+(</span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</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: #606;" class=3D"styled-by-prettify">Seq</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
=A0 </span></code><code class=3D"prettyprint"><span style=3D"color:
#000;" class=3D"styled-by-prettify"></span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"><code class=3D"prettyprint"><span
style=3D"color: #000;" class=3D"styled-by-prettify"></span></co=
de></span><span
style=3D"color: #008;" class=3D"styled-by-prettify">void</span><spa=
n
style=3D"color: #000;" class=3D"styled-by-prettify"> swap</span><sp=
an
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">&,</span><s=
pan
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">&);</span><=
span
style=3D"color: #000;" class=3D"styled-by-prettify"> <br>
=A0 </span></code><code class=3D"prettyprint"><span style=3D"color:
#000;" class=3D"styled-by-prettify"></span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"><code class=3D"prettyprint"><span
style=3D"color: #000;" class=3D"styled-by-prettify"></span></co=
de>ostream</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: #008;" class=3D"styled-by-prettify">operator</span>=
<span
style=3D"color: #660;" class=3D"styled-by-prettify"><<(</span=
><span
style=3D"color: #000;" class=3D"styled-by-prettify">ostream</span><=
span
style=3D"color: #660;" class=3D"styled-by-prettify">&,</span><s=
pan
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> <br>
=A0 </span></code><code class=3D"prettyprint"><span style=3D"color:
#000;" class=3D"styled-by-prettify"></span></code><code
class=3D"prettyprint"><span style=3D"color: #606;"
class=3D"styled-by-prettify"><code class=3D"prettyprint"><span
style=3D"color: #000;" class=3D"styled-by-prettify"></span></co=
de>Iter</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #008;" class=3D"styled-by-prettify">begin</span><sp=
an
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</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>
=A0 </span></code><code class=3D"prettyprint"><span style=3D"color:
#000;" class=3D"styled-by-prettify"></span></code><code
class=3D"prettyprint"><span style=3D"color: #606;"
class=3D"styled-by-prettify"><code class=3D"prettyprint"><span
style=3D"color: #000;" class=3D"styled-by-prettify"></span></co=
de>Iter</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #008;" class=3D"styled-by-prettify">end</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Seq</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>
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</s=
pan><span
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> <br>
</span></code><br>
Vicente<br>
</body>
</html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--------------060105020207000708060705--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Mon, 4 Feb 2013 13:15:47 -0800 (PST)
Raw View
------=_Part_456_31327113.1360012547973
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
On Monday, February 4, 2013 6:21:20 AM UTC-8, Andrzej Krzemie=F1ski wrote:
> W dniu poniedzia=B3ek, 4 lutego 2013 14:50:26 UTC+1 u=BFytkownik Dave Abr=
ahams=20
> napisa=B3:
>>
>>
>>
>> On Saturday, February 2, 2013 8:59:28 AM UTC-5, Andrzej Krzemie=F1ski wr=
ote:
>>>
>>> I would like to throw an idea at people in this forum, and check if you=
=20
>>> consider it a useful addition to C++ language. It is an elaboration on =
the=20
>>> idea suggested by Vicente J. Botet Escriba:=20
>>> https://groups.google.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/=
FJeR8QL3pBcJ
>>> .
>>>
>>> It is based on observation that the interface of a class type consists=
=20
>>> not only of its member functions, but also of some non-member functions=
:
>>>
>>> class Seq
>>> {
>>> // ...
>>> };
>>>
>>> Seq operator+(Seq, Seq); // also class interface
>>> void swap(Seq&, Seq&); // also class interface
>>> ostream& operator<<(ostream&, Seq); // also class interface
>>> Iter begin(Seq &); // also class interface
>>> Iter end(Seq &); // also class interface
>>>
>>> // ...
>>> bool has_duplicates(Seq const&) // not an interface
>>>
>>> "Being a class interface" means when I use my class, I also want these=
=20
>>> functions to be considered in overload resolution. ADL does enable this=
,=20
>>> however it also imports anything from our namespace, which is often far=
too=20
>>> much.
>>>
>>> N3490 proposes to disable ADL in a controlled way. But for functions=20
>>> that we consider an "extended class interface", we still would like the=
ADL=20
>>> to work.=20
>>>
>>>
>> I disagree with the premise here. If I write a function f() that calls =
a=20
>> helper function has_duplicates in the same namespace, the semantics of m=
y=20
>> has_duplicates and those of the has_duplicates in Seq's namespace, even=
=20
>> with such a very specific name, are quite likely to be different (either=
=20
>> slightly or dramatically). The problem is that it's easy and natural to=
=20
>> write an unqualified call under the assumption that "that function right=
=20
>> over there, in the same namespace" will be called. This is the trap tha=
t=20
>> causes problems with ADL, and if you leave it in place, you haven't solv=
ed=20
>> any problems.
>>
>
> This is true in general. The motivation for this proposal was that some=
=20
> functions are special, and for these you would not like to define overloa=
ds=20
> in your own namespace. These special functions include ostream operators =
<<=20
> and >> and functions begin(), end() and swap() which have so special=20
> semantics already that they can be considered operators. But you are righ=
t=20
> that once such feature is in place, everyone could abuse it for any purpo=
se=20
> and the ADL problem would be back.
>
> Thanks,
> &rzej
>
I would say that the big difference is that you have to *want* to abuse it=
=20
for it to be back. Before, the ADL problem required no effort from the=20
library writer; it was always a danger. With this and the ADL minimization=
=20
efforts, it becomes something the library writer has control over. Thus, if=
=20
the library author wants to define a series of special functions that use=
=20
ADL, they can. But they have to want to do so; it won't happen by itself.
--=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/?hl=3Den.
------=_Part_456_31327113.1360012547973
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
<br><br>On Monday, February 4, 2013 6:21:20 AM UTC-8, Andrzej Krzemie=F1ski=
wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left=
: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">W dniu poniedzia=B3=
ek, 4 lutego 2013 14:50:26 UTC+1 u=BFytkownik Dave Abrahams napisa=B3:<bloc=
kquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"><br><br>On Saturday, February 2, 2013 8:=
59:28 AM UTC-5, Andrzej Krzemie=F1ski wrote:<blockquote class=3D"gmail_quot=
e" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-l=
eft:1ex">I would like to throw an idea at people in this forum, and check i=
f you=20
consider it a useful addition to C++ language. It is an elaboration on=20
the idea suggested by Vicente J. Botet Escriba: <a href=3D"https://groups.g=
oogle.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/FJeR8QL3pBcJ" target=
=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msg/std-<wbr>prop=
osals/-u6e-rohWXM/<wbr>FJeR8QL3pBcJ</a>.<br><br>It
is based on observation that the interface of a class type consists not
only of its member functions, but also of some non-member functions:<br><b=
r><div 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><div><=
span style=3D"color:#008">class</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#606">Seq</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#660">{</span><span style=3D"color:#000"><br> </sp=
an><span style=3D"color:#800">// ...</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br><b=
r></span><span style=3D"color:#606">Seq</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">operator</span><span style=3D"color:#660">=
+(</span><span style=3D"color:#606">Seq</span><span style=3D"color:#660">,<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#606">Seq</sp=
an><span style=3D"color:#660">);</span><span style=3D"color:#000"> </span><=
span style=3D"color:#800">// also class interface</span><span style=3D"colo=
r:#000"><br></span><span style=3D"color:#008">void</span><span style=3D"col=
or:#000"> swap</span><span style=3D"color:#660">(</span><span style=3D"colo=
r:#606">Seq</span><span style=3D"color:#660">&,</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#606">Seq</span><span style=3D"color=
:#660">&);</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#800">// also class interface</span><span style=3D"color:#000"><br>ostrea=
m</span><span style=3D"color:#660">&</span><span style=3D"color:#000"> =
</span><span style=3D"color:#008">operator</span><span style=3D"color:#660"=
><<(</span><span style=3D"color:#000">ostream</span><span style=3D"co=
lor:#660">&,</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#606">Seq</span><span style=3D"color:#660">);</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#800">// also class interface</span><s=
pan style=3D"color:#000"><br></span><span style=3D"color:#606">Iter</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">begin</span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#606">Seq</span><span=
style=3D"color:#000"> </span><span style=3D"color:#660">&);</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#800">// also class int=
erface</span><span style=3D"color:#000"><br></span><span style=3D"color:#60=
6">Iter</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>end</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Se=
q</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&=
);</span><span style=3D"color:#000"> </span><span style=3D"color:#800">// a=
lso class interface</span><span style=3D"color:#000"><br><br></span><span s=
tyle=3D"color:#800">// ...</span><span style=3D"color:#000"><br></span><spa=
n style=3D"color:#008">bool</span><span style=3D"color:#000"> has_duplicate=
s</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Seq</=
span><span style=3D"color:#000"> </span><span style=3D"color:#008">const</s=
pan><span style=3D"color:#660">&)</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#800">// not an interface</span><span style=3D"col=
or:#000"><br></span></div></code></div><br>"Being
a class interface" means when I use my class, I also want these=20
functions to be considered in overload resolution. ADL does enable this,
however it also imports anything from our namespace, which is often far
too much.<br><br>N3490 proposes to disable ADL in a controlled way. But
for functions that we consider an "extended class interface", we still=20
would like the ADL to work. <br><br></blockquote><div><br></div><div>I disa=
gree with the premise here. If I write a function f() that calls a he=
lper function has_duplicates in the same namespace, the semantics of my has=
_duplicates and those of the has_duplicates in Seq's namespace, even with s=
uch a very specific name, are quite likely to be different (either slightly=
or dramatically). The problem is that it's easy and natural to write=
an unqualified call under the assumption that "that function right over th=
ere, in the same namespace" will be called. This is the trap that cau=
ses problems with ADL, and if you leave it in place, you haven't solved any=
problems.</div></blockquote><div><br>This is true in general. The motivati=
on for this proposal was that some functions are special, and for these you=
would not like to define overloads in your own namespace. These special fu=
nctions include ostream operators << and >> and functions begin=
(), end() and swap() which have so special semantics already that they can =
be considered operators. But you are right that once such feature is in pla=
ce, everyone could abuse it for any purpose and the ADL problem would be ba=
ck.<br><br>Thanks,<br>&rzej<br></div></blockquote><div><br>I would say =
that the big difference is that you have to <i>want</i> to abuse it for it =
to be back. Before, the ADL problem required no effort from the library wri=
ter; it was always a danger. With this and the ADL minimization efforts, it=
becomes something the library writer has control over. Thus, if the librar=
y author wants to define a series of special functions that use ADL, they c=
an. But they have to want to do so; it won't happen by itself.<br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_456_31327113.1360012547973--
.
Author: Dave Abrahams <dave@boostpro.com>
Date: Mon, 4 Feb 2013 14:46:12 -0800 (PST)
Raw View
------=_Part_1358_16576411.1360017972465
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
On Monday, February 4, 2013 9:21:20 AM UTC-5, Andrzej Krzemie=F1ski wrote:
>
>
>
> W dniu poniedzia=B3ek, 4 lutego 2013 14:50:26 UTC+1 u=BFytkownik Dave Abr=
ahams=20
> napisa=B3:
>>
>>
>>
>> On Saturday, February 2, 2013 8:59:28 AM UTC-5, Andrzej Krzemie=F1ski wr=
ote:
>>>
>>> I would like to throw an idea at people in this forum, and check if you=
=20
>>> consider it a useful addition to C++ language. It is an elaboration on =
the=20
>>> idea suggested by Vicente J. Botet Escriba:=20
>>> https://groups.google.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/=
FJeR8QL3pBcJ
>>> .
>>>
>>> It is based on observation that the interface of a class type consists=
=20
>>> not only of its member functions, but also of some non-member functions=
:
>>>
>>> class Seq
>>> {
>>> // ...
>>> };
>>>
>>> Seq operator+(Seq, Seq); // also class interface
>>> void swap(Seq&, Seq&); // also class interface
>>> ostream& operator<<(ostream&, Seq); // also class interface
>>> Iter begin(Seq &); // also class interface
>>> Iter end(Seq &); // also class interface
>>>
>>> // ...
>>> bool has_duplicates(Seq const&) // not an interface
>>>
>>> "Being a class interface" means when I use my class, I also want these=
=20
>>> functions to be considered in overload resolution. ADL does enable this=
,=20
>>> however it also imports anything from our namespace, which is often far=
too=20
>>> much.
>>>
>>> N3490 proposes to disable ADL in a controlled way. But for functions=20
>>> that we consider an "extended class interface", we still would like the=
ADL=20
>>> to work.=20
>>>
>>>
>> I disagree with the premise here. If I write a function f() that calls =
a=20
>> helper function has_duplicates in the same namespace, the semantics of m=
y=20
>> has_duplicates and those of the has_duplicates in Seq's namespace, even=
=20
>> with such a very specific name, are quite likely to be different (either=
=20
>> slightly or dramatically). The problem is that it's easy and natural to=
=20
>> write an unqualified call under the assumption that "that function right=
=20
>> over there, in the same namespace" will be called. This is the trap tha=
t=20
>> causes problems with ADL, and if you leave it in place, you haven't solv=
ed=20
>> any problems.
>>
>
> This is true in general. The motivation for this proposal was that some=
=20
> functions are special, and for these you would not like to define overloa=
ds=20
> in your own namespace. These special functions include ostream operators =
<<=20
> and >> and functions begin(), end() and swap() which have so special=20
> semantics already that they can be considered operators. But you are righ=
t=20
> that once such feature is in place, everyone could abuse it for any purpo=
se=20
> and the ADL problem would be back.
>
I also must ask how your proposal is any different from the status quo.=20
--=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/?hl=3Den.
------=_Part_1358_16576411.1360017972465
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
<br><br>On Monday, February 4, 2013 9:21:20 AM UTC-5, Andrzej Krzemie=F1ski=
wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.=
8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><br><br>W dniu poniedzi=
a=B3ek, 4 lutego 2013 14:50:26 UTC+1 u=BFytkownik Dave Abrahams napisa=B3:<=
blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border=
-left:1px #ccc solid;padding-left:1ex"><br><br>On Saturday, February 2, 201=
3 8:59:28 AM UTC-5, Andrzej Krzemie=F1ski wrote:<blockquote class=3D"gmail_=
quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;paddi=
ng-left:1ex">I would like to throw an idea at people in this forum, and che=
ck if you=20
consider it a useful addition to C++ language. It is an elaboration on=20
the idea suggested by Vicente J. Botet Escriba: <a href=3D"https://groups.g=
oogle.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/FJeR8QL3pBcJ" target=
=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msg/std-<wbr>prop=
osals/-u6e-rohWXM/<wbr>FJeR8QL3pBcJ</a>.<br><br>It
is based on observation that the interface of a class type consists not
only of its member functions, but also of some non-member functions:<br><b=
r><div 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><div><=
span style=3D"color:#008">class</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#606">Seq</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#660">{</span><span style=3D"color:#000"><br> </sp=
an><span style=3D"color:#800">// ...</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br><b=
r></span><span style=3D"color:#606">Seq</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">operator</span><span style=3D"color:#660">=
+(</span><span style=3D"color:#606">Seq</span><span style=3D"color:#660">,<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#606">Seq</sp=
an><span style=3D"color:#660">);</span><span style=3D"color:#000"> </span><=
span style=3D"color:#800">// also class interface</span><span style=3D"colo=
r:#000"><br></span><span style=3D"color:#008">void</span><span style=3D"col=
or:#000"> swap</span><span style=3D"color:#660">(</span><span style=3D"colo=
r:#606">Seq</span><span style=3D"color:#660">&,</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#606">Seq</span><span style=3D"color=
:#660">&);</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#800">// also class interface</span><span style=3D"color:#000"><br>ostrea=
m</span><span style=3D"color:#660">&</span><span style=3D"color:#000"> =
</span><span style=3D"color:#008">operator</span><span style=3D"color:#660"=
><<(</span><span style=3D"color:#000">ostream</span><span style=3D"co=
lor:#660">&,</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#606">Seq</span><span style=3D"color:#660">);</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#800">// also class interface</span><s=
pan style=3D"color:#000"><br></span><span style=3D"color:#606">Iter</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">begin</span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#606">Seq</span><span=
style=3D"color:#000"> </span><span style=3D"color:#660">&);</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#800">// also class int=
erface</span><span style=3D"color:#000"><br></span><span style=3D"color:#60=
6">Iter</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>end</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Se=
q</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&=
);</span><span style=3D"color:#000"> </span><span style=3D"color:#800">// a=
lso class interface</span><span style=3D"color:#000"><br><br></span><span s=
tyle=3D"color:#800">// ...</span><span style=3D"color:#000"><br></span><spa=
n style=3D"color:#008">bool</span><span style=3D"color:#000"> has_duplicate=
s</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Seq</=
span><span style=3D"color:#000"> </span><span style=3D"color:#008">const</s=
pan><span style=3D"color:#660">&)</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#800">// not an interface</span><span style=3D"col=
or:#000"><br></span></div></code></div><br>"Being
a class interface" means when I use my class, I also want these=20
functions to be considered in overload resolution. ADL does enable this,
however it also imports anything from our namespace, which is often far
too much.<br><br>N3490 proposes to disable ADL in a controlled way. But
for functions that we consider an "extended class interface", we still=20
would like the ADL to work. <br><br></blockquote><div><br></div><div>I disa=
gree with the premise here. If I write a function f() that calls a he=
lper function has_duplicates in the same namespace, the semantics of my has=
_duplicates and those of the has_duplicates in Seq's namespace, even with s=
uch a very specific name, are quite likely to be different (either slightly=
or dramatically). The problem is that it's easy and natural to write=
an unqualified call under the assumption that "that function right over th=
ere, in the same namespace" will be called. This is the trap that cau=
ses problems with ADL, and if you leave it in place, you haven't solved any=
problems.</div></blockquote><div><br>This is true in general. The motivati=
on for this proposal was that some functions are special, and for these you=
would not like to define overloads in your own namespace. These special fu=
nctions include ostream operators << and >> and functions begin=
(), end() and swap() which have so special semantics already that they can =
be considered operators. But you are right that once such feature is in pla=
ce, everyone could abuse it for any purpose and the ADL problem would be ba=
ck.<br></div></blockquote><div><br></div><div>I also must ask how your prop=
osal is any different from the status quo. </div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_1358_16576411.1360017972465--
.
Author: Dave Abrahams <dave@boostpro.com>
Date: Mon, 4 Feb 2013 14:48:03 -0800 (PST)
Raw View
------=_Part_794_32955190.1360018083788
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
On Monday, February 4, 2013 4:15:47 PM UTC-5, Nicol Bolas wrote:
>
>
>
> On Monday, February 4, 2013 6:21:20 AM UTC-8, Andrzej Krzemie=F1ski wrote=
:
>
>> W dniu poniedzia=B3ek, 4 lutego 2013 14:50:26 UTC+1 u=BFytkownik Dave=20
>> Abrahams napisa=B3:
>>>
>>>
>>>
>>> On Saturday, February 2, 2013 8:59:28 AM UTC-5, Andrzej Krzemie=F1ski=
=20
>>> wrote:
>>>>
>>>> I would like to throw an idea at people in this forum, and check if yo=
u=20
>>>> consider it a useful addition to C++ language. It is an elaboration on=
the=20
>>>> idea suggested by Vicente J. Botet Escriba:=20
>>>> https://groups.google.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM=
/FJeR8QL3pBcJ
>>>> .
>>>>
>>>> It is based on observation that the interface of a class type consists=
=20
>>>> not only of its member functions, but also of some non-member function=
s:
>>>>
>>>> class Seq
>>>> {
>>>> // ...
>>>> };
>>>>
>>>> Seq operator+(Seq, Seq); // also class interface
>>>> void swap(Seq&, Seq&); // also class interface
>>>> ostream& operator<<(ostream&, Seq); // also class interface
>>>> Iter begin(Seq &); // also class interface
>>>> Iter end(Seq &); // also class interface
>>>>
>>>> // ...
>>>> bool has_duplicates(Seq const&) // not an interface
>>>>
>>>> "Being a class interface" means when I use my class, I also want these=
=20
>>>> functions to be considered in overload resolution. ADL does enable thi=
s,=20
>>>> however it also imports anything from our namespace, which is often fa=
r too=20
>>>> much.
>>>>
>>>> N3490 proposes to disable ADL in a controlled way. But for functions=
=20
>>>> that we consider an "extended class interface", we still would like th=
e ADL=20
>>>> to work.=20
>>>>
>>>>
>>> I disagree with the premise here. If I write a function f() that calls=
=20
>>> a helper function has_duplicates in the same namespace, the semantics o=
f my=20
>>> has_duplicates and those of the has_duplicates in Seq's namespace, even=
=20
>>> with such a very specific name, are quite likely to be different (eithe=
r=20
>>> slightly or dramatically). The problem is that it's easy and natural t=
o=20
>>> write an unqualified call under the assumption that "that function righ=
t=20
>>> over there, in the same namespace" will be called. This is the trap th=
at=20
>>> causes problems with ADL, and if you leave it in place, you haven't sol=
ved=20
>>> any problems.
>>>
>>
>> This is true in general. The motivation for this proposal was that some=
=20
>> functions are special, and for these you would not like to define overlo=
ads=20
>> in your own namespace. These special functions include ostream operators=
<<=20
>> and >> and functions begin(), end() and swap() which have so special=20
>> semantics already that they can be considered operators. But you are rig=
ht=20
>> that once such feature is in place, everyone could abuse it for any purp=
ose=20
>> and the ADL problem would be back.
>>
>> Thanks,
>> &rzej
>>
>
> I would say that the big difference is that you have to *want* to abuse=
=20
> it for it to be back. Before, the ADL problem required no effort from the=
=20
> library writer; it was always a danger. With this and the ADL minimizatio=
n=20
> efforts, it becomes something the library writer has control over. Thus, =
if=20
> the library author wants to define a series of special functions that use=
=20
> ADL, they can. But they have to want to do so; it won't happen by itself.
>
I'd like to see some justification and/or explanation of your claims here.=
=20
Seems to me all you have to do is forget to look carefully at every=20
unqualified call and remember it is subject to ADL.
--=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/?hl=3Den.
------=_Part_794_32955190.1360018083788
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
<br><br>On Monday, February 4, 2013 4:15:47 PM UTC-5, Nicol Bolas wrote:<bl=
ockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border=
-left: 1px #ccc solid;padding-left: 1ex;"><br><br>On Monday, February 4, 20=
13 6:21:20 AM UTC-8, Andrzej Krzemie=F1ski wrote:<br><blockquote class=3D"g=
mail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;=
padding-left:1ex">W dniu poniedzia=B3ek, 4 lutego 2013 14:50:26 UTC+1 u=BFy=
tkownik Dave Abrahams napisa=B3:<blockquote class=3D"gmail_quote" style=3D"=
margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><br=
><br>On Saturday, February 2, 2013 8:59:28 AM UTC-5, Andrzej Krzemie=F1ski =
wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex=
;border-left:1px #ccc solid;padding-left:1ex">I would like to throw an idea=
at people in this forum, and check if you=20
consider it a useful addition to C++ language. It is an elaboration on=20
the idea suggested by Vicente J. Botet Escriba: <a href=3D"https://groups.g=
oogle.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/FJeR8QL3pBcJ" target=
=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msg/std-<wbr>prop=
osals/-u6e-rohWXM/<wbr>FJeR8QL3pBcJ</a>.<br><br>It
is based on observation that the interface of a class type consists not
only of its member functions, but also of some non-member functions:<br><b=
r><div 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><div><=
span style=3D"color:#008">class</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#606">Seq</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#660">{</span><span style=3D"color:#000"><br> </sp=
an><span style=3D"color:#800">// ...</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br><b=
r></span><span style=3D"color:#606">Seq</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">operator</span><span style=3D"color:#660">=
+(</span><span style=3D"color:#606">Seq</span><span style=3D"color:#660">,<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#606">Seq</sp=
an><span style=3D"color:#660">);</span><span style=3D"color:#000"> </span><=
span style=3D"color:#800">// also class interface</span><span style=3D"colo=
r:#000"><br></span><span style=3D"color:#008">void</span><span style=3D"col=
or:#000"> swap</span><span style=3D"color:#660">(</span><span style=3D"colo=
r:#606">Seq</span><span style=3D"color:#660">&,</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#606">Seq</span><span style=3D"color=
:#660">&);</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#800">// also class interface</span><span style=3D"color:#000"><br>ostrea=
m</span><span style=3D"color:#660">&</span><span style=3D"color:#000"> =
</span><span style=3D"color:#008">operator</span><span style=3D"color:#660"=
><<(</span><span style=3D"color:#000">ostream</span><span style=3D"co=
lor:#660">&,</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#606">Seq</span><span style=3D"color:#660">);</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#800">// also class interface</span><s=
pan style=3D"color:#000"><br></span><span style=3D"color:#606">Iter</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">begin</span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#606">Seq</span><span=
style=3D"color:#000"> </span><span style=3D"color:#660">&);</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#800">// also class int=
erface</span><span style=3D"color:#000"><br></span><span style=3D"color:#60=
6">Iter</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>end</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Se=
q</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&=
);</span><span style=3D"color:#000"> </span><span style=3D"color:#800">// a=
lso class interface</span><span style=3D"color:#000"><br><br></span><span s=
tyle=3D"color:#800">// ...</span><span style=3D"color:#000"><br></span><spa=
n style=3D"color:#008">bool</span><span style=3D"color:#000"> has_duplicate=
s</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Seq</=
span><span style=3D"color:#000"> </span><span style=3D"color:#008">const</s=
pan><span style=3D"color:#660">&)</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#800">// not an interface</span><span style=3D"col=
or:#000"><br></span></div></code></div><br>"Being
a class interface" means when I use my class, I also want these=20
functions to be considered in overload resolution. ADL does enable this,
however it also imports anything from our namespace, which is often far
too much.<br><br>N3490 proposes to disable ADL in a controlled way. But
for functions that we consider an "extended class interface", we still=20
would like the ADL to work. <br><br></blockquote><div><br></div><div>I disa=
gree with the premise here. If I write a function f() that calls a he=
lper function has_duplicates in the same namespace, the semantics of my has=
_duplicates and those of the has_duplicates in Seq's namespace, even with s=
uch a very specific name, are quite likely to be different (either slightly=
or dramatically). The problem is that it's easy and natural to write=
an unqualified call under the assumption that "that function right over th=
ere, in the same namespace" will be called. This is the trap that cau=
ses problems with ADL, and if you leave it in place, you haven't solved any=
problems.</div></blockquote><div><br>This is true in general. The motivati=
on for this proposal was that some functions are special, and for these you=
would not like to define overloads in your own namespace. These special fu=
nctions include ostream operators << and >> and functions begin=
(), end() and swap() which have so special semantics already that they can =
be considered operators. But you are right that once such feature is in pla=
ce, everyone could abuse it for any purpose and the ADL problem would be ba=
ck.<br><br>Thanks,<br>&rzej<br></div></blockquote><div><br>I would say =
that the big difference is that you have to <i>want</i> to abuse it for it =
to be back. Before, the ADL problem required no effort from the library wri=
ter; it was always a danger. With this and the ADL minimization efforts, it=
becomes something the library writer has control over. Thus, if the librar=
y author wants to define a series of special functions that use ADL, they c=
an. But they have to want to do so; it won't happen by itself.<br></div></b=
lockquote><div><br></div><div>I'd like to see some justification and/or exp=
lanation of your claims here. Seems to me all you have to do is forge=
t to look carefully at every unqualified call and remember it is subject to=
ADL.</div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_794_32955190.1360018083788--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Mon, 4 Feb 2013 16:14:48 -0800 (PST)
Raw View
------=_Part_710_31468508.1360023288596
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
On Monday, February 4, 2013 2:48:03 PM UTC-8, Dave Abrahams wrote:
>
>
>
> On Monday, February 4, 2013 4:15:47 PM UTC-5, Nicol Bolas wrote:
>>
>>
>>
>> On Monday, February 4, 2013 6:21:20 AM UTC-8, Andrzej Krzemie=F1ski wrot=
e:
>>
>>> W dniu poniedzia=B3ek, 4 lutego 2013 14:50:26 UTC+1 u=BFytkownik Dave=
=20
>>> Abrahams napisa=B3:
>>>>
>>>>
>>>>
>>>> On Saturday, February 2, 2013 8:59:28 AM UTC-5, Andrzej Krzemie=F1ski=
=20
>>>> wrote:
>>>>>
>>>>> I would like to throw an idea at people in this forum, and check if=
=20
>>>>> you consider it a useful addition to C++ language. It is an elaborati=
on on=20
>>>>> the idea suggested by Vicente J. Botet Escriba:=20
>>>>> https://groups.google.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWX=
M/FJeR8QL3pBcJ
>>>>> .
>>>>>
>>>>> It is based on observation that the interface of a class type consist=
s=20
>>>>> not only of its member functions, but also of some non-member functio=
ns:
>>>>>
>>>>> class Seq
>>>>> {
>>>>> // ...
>>>>> };
>>>>>
>>>>> Seq operator+(Seq, Seq); // also class interface
>>>>> void swap(Seq&, Seq&); // also class interface
>>>>> ostream& operator<<(ostream&, Seq); // also class interface
>>>>> Iter begin(Seq &); // also class interface
>>>>> Iter end(Seq &); // also class interface
>>>>>
>>>>> // ...
>>>>> bool has_duplicates(Seq const&) // not an interface
>>>>>
>>>>> "Being a class interface" means when I use my class, I also want thes=
e=20
>>>>> functions to be considered in overload resolution. ADL does enable th=
is,=20
>>>>> however it also imports anything from our namespace, which is often f=
ar too=20
>>>>> much.
>>>>>
>>>>> N3490 proposes to disable ADL in a controlled way. But for functions=
=20
>>>>> that we consider an "extended class interface", we still would like t=
he ADL=20
>>>>> to work.=20
>>>>>
>>>>>
>>>> I disagree with the premise here. If I write a function f() that call=
s=20
>>>> a helper function has_duplicates in the same namespace, the semantics =
of my=20
>>>> has_duplicates and those of the has_duplicates in Seq's namespace, eve=
n=20
>>>> with such a very specific name, are quite likely to be different (eith=
er=20
>>>> slightly or dramatically). The problem is that it's easy and natural =
to=20
>>>> write an unqualified call under the assumption that "that function rig=
ht=20
>>>> over there, in the same namespace" will be called. This is the trap t=
hat=20
>>>> causes problems with ADL, and if you leave it in place, you haven't so=
lved=20
>>>> any problems.
>>>>
>>>
>>> This is true in general. The motivation for this proposal was that some=
=20
>>> functions are special, and for these you would not like to define overl=
oads=20
>>> in your own namespace. These special functions include ostream operator=
s <<=20
>>> and >> and functions begin(), end() and swap() which have so special=20
>>> semantics already that they can be considered operators. But you are ri=
ght=20
>>> that once such feature is in place, everyone could abuse it for any pur=
pose=20
>>> and the ADL problem would be back.
>>>
>>> Thanks,
>>> &rzej
>>>
>>
>> I would say that the big difference is that you have to *want* to abuse=
=20
>> it for it to be back. Before, the ADL problem required no effort from th=
e=20
>> library writer; it was always a danger. With this and the ADL minimizati=
on=20
>> efforts, it becomes something the library writer has control over. Thus,=
if=20
>> the library author wants to define a series of special functions that us=
e=20
>> ADL, they can. But they have to want to do so; it won't happen by itself=
..
>>
>
> I'd like to see some justification and/or explanation of your claims here=
..=20
> Seems to me all you have to do is forget to look carefully at every=20
> unqualified call and remember it is subject to ADL.
>
I'm not sure how you get that. I said "and the ADL minimization efforts",=
=20
which I assumed to mean something not entirely unlike this proposal<http://=
www.open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3490.html>.=20
With that, you have the ability to shut off ADL within a namespace. And=20
with the proposal under discussion here, we get to turn it back on *for=20
specific functions*. And unlike the ADL proposal, it only turns it back on=
=20
for specific combinations of function and type.
In short, there's specific syntax that says, "function X can do ADL with=20
argument type Y." The library writer has a way to say that they *want* ADL=
=20
in specific cases. Unless you're saying that ADL is always bad.
--=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/?hl=3Den.
------=_Part_710_31468508.1360023288596
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
<br><br>On Monday, February 4, 2013 2:48:03 PM UTC-8, Dave Abrahams wrote:<=
blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bord=
er-left: 1px #ccc solid;padding-left: 1ex;"><br><br>On Monday, February 4, =
2013 4:15:47 PM UTC-5, Nicol Bolas wrote:<blockquote class=3D"gmail_quote" =
style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left=
:1ex"><br><br>On Monday, February 4, 2013 6:21:20 AM UTC-8, Andrzej Krzemie=
=F1ski wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0;margin=
-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">W dniu poniedzia=
=B3ek, 4 lutego 2013 14:50:26 UTC+1 u=BFytkownik Dave Abrahams napisa=B3:<b=
lockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-=
left:1px #ccc solid;padding-left:1ex"><br><br>On Saturday, February 2, 2013=
8:59:28 AM UTC-5, Andrzej Krzemie=F1ski wrote:<blockquote class=3D"gmail_q=
uote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;paddin=
g-left:1ex">I would like to throw an idea at people in this forum, and chec=
k if you=20
consider it a useful addition to C++ language. It is an elaboration on=20
the idea suggested by Vicente J. Botet Escriba: <a href=3D"https://groups.g=
oogle.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/FJeR8QL3pBcJ" target=
=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msg/std-<wbr>prop=
osals/-u6e-rohWXM/<wbr>FJeR8QL3pBcJ</a>.<br><br>It
is based on observation that the interface of a class type consists not
only of its member functions, but also of some non-member functions:<br><b=
r><div 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><div><=
span style=3D"color:#008">class</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#606">Seq</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#660">{</span><span style=3D"color:#000"><br> </sp=
an><span style=3D"color:#800">// ...</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br><b=
r></span><span style=3D"color:#606">Seq</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">operator</span><span style=3D"color:#660">=
+(</span><span style=3D"color:#606">Seq</span><span style=3D"color:#660">,<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#606">Seq</sp=
an><span style=3D"color:#660">);</span><span style=3D"color:#000"> </span><=
span style=3D"color:#800">// also class interface</span><span style=3D"colo=
r:#000"><br></span><span style=3D"color:#008">void</span><span style=3D"col=
or:#000"> swap</span><span style=3D"color:#660">(</span><span style=3D"colo=
r:#606">Seq</span><span style=3D"color:#660">&,</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#606">Seq</span><span style=3D"color=
:#660">&);</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#800">// also class interface</span><span style=3D"color:#000"><br>ostrea=
m</span><span style=3D"color:#660">&</span><span style=3D"color:#000"> =
</span><span style=3D"color:#008">operator</span><span style=3D"color:#660"=
><<(</span><span style=3D"color:#000">ostream</span><span style=3D"co=
lor:#660">&,</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#606">Seq</span><span style=3D"color:#660">);</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#800">// also class interface</span><s=
pan style=3D"color:#000"><br></span><span style=3D"color:#606">Iter</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">begin</span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#606">Seq</span><span=
style=3D"color:#000"> </span><span style=3D"color:#660">&);</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#800">// also class int=
erface</span><span style=3D"color:#000"><br></span><span style=3D"color:#60=
6">Iter</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>end</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Se=
q</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&=
);</span><span style=3D"color:#000"> </span><span style=3D"color:#800">// a=
lso class interface</span><span style=3D"color:#000"><br><br></span><span s=
tyle=3D"color:#800">// ...</span><span style=3D"color:#000"><br></span><spa=
n style=3D"color:#008">bool</span><span style=3D"color:#000"> has_duplicate=
s</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Seq</=
span><span style=3D"color:#000"> </span><span style=3D"color:#008">const</s=
pan><span style=3D"color:#660">&)</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#800">// not an interface</span><span style=3D"col=
or:#000"><br></span></div></code></div><br>"Being
a class interface" means when I use my class, I also want these=20
functions to be considered in overload resolution. ADL does enable this,
however it also imports anything from our namespace, which is often far
too much.<br><br>N3490 proposes to disable ADL in a controlled way. But
for functions that we consider an "extended class interface", we still=20
would like the ADL to work. <br><br></blockquote><div><br></div><div>I disa=
gree with the premise here. If I write a function f() that calls a he=
lper function has_duplicates in the same namespace, the semantics of my has=
_duplicates and those of the has_duplicates in Seq's namespace, even with s=
uch a very specific name, are quite likely to be different (either slightly=
or dramatically). The problem is that it's easy and natural to write=
an unqualified call under the assumption that "that function right over th=
ere, in the same namespace" will be called. This is the trap that cau=
ses problems with ADL, and if you leave it in place, you haven't solved any=
problems.</div></blockquote><div><br>This is true in general. The motivati=
on for this proposal was that some functions are special, and for these you=
would not like to define overloads in your own namespace. These special fu=
nctions include ostream operators << and >> and functions begin=
(), end() and swap() which have so special semantics already that they can =
be considered operators. But you are right that once such feature is in pla=
ce, everyone could abuse it for any purpose and the ADL problem would be ba=
ck.<br><br>Thanks,<br>&rzej<br></div></blockquote><div><br>I would say =
that the big difference is that you have to <i>want</i> to abuse it for it =
to be back. Before, the ADL problem required no effort from the library wri=
ter; it was always a danger. With this and the ADL minimization efforts, it=
becomes something the library writer has control over. Thus, if the librar=
y author wants to define a series of special functions that use ADL, they c=
an. But they have to want to do so; it won't happen by itself.<br></div></b=
lockquote><div><br></div><div>I'd like to see some justification and/or exp=
lanation of your claims here. Seems to me all you have to do is forge=
t to look carefully at every unqualified call and remember it is subject to=
ADL.</div></blockquote><div><br>I'm not sure how you get that. I said "and=
the ADL minimization efforts", which I assumed to mean something not entir=
ely unlike <a href=3D"http://www.open-std.org/JTC1/SC22/WG21/docs/papers/20=
12/n3490.html">this proposal</a>. With that, you have the ability to shut o=
ff ADL within a namespace. And with the proposal under discussion here, we =
get to turn it back on <i>for specific functions</i>. And unlike the ADL pr=
oposal, it only turns it back on for specific combinations of function and =
type.<br><br>In short, there's specific syntax that says, "function X can d=
o ADL with argument type Y." The library writer has a way to say that they =
<i>want</i> ADL in specific cases. Unless you're saying that ADL is always =
bad.<br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_710_31468508.1360023288596--
.
Author: =?UTF-8?Q?Andrzej_Krzemie=C5=84ski?= <akrzemi1@gmail.com>
Date: Tue, 5 Feb 2013 01:03:10 -0800 (PST)
Raw View
------=_Part_705_28001431.1360054990767
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
W dniu poniedzia=B3ek, 4 lutego 2013 23:46:12 UTC+1 u=BFytkownik Dave Abrah=
ams=20
napisa=B3:
>
>
>
> On Monday, February 4, 2013 9:21:20 AM UTC-5, Andrzej Krzemie=F1ski wrote=
:
>>
>>
>>
>> W dniu poniedzia=B3ek, 4 lutego 2013 14:50:26 UTC+1 u=BFytkownik Dave=20
>> Abrahams napisa=B3:
>>>
>>>
>>>
>>> On Saturday, February 2, 2013 8:59:28 AM UTC-5, Andrzej Krzemie=F1ski=
=20
>>> wrote:
>>>>
>>>> I would like to throw an idea at people in this forum, and check if yo=
u=20
>>>> consider it a useful addition to C++ language. It is an elaboration on=
the=20
>>>> idea suggested by Vicente J. Botet Escriba:=20
>>>> https://groups.google.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM=
/FJeR8QL3pBcJ
>>>> .
>>>>
>>>> It is based on observation that the interface of a class type consists=
=20
>>>> not only of its member functions, but also of some non-member function=
s:
>>>>
>>>> class Seq
>>>> {
>>>> // ...
>>>> };
>>>>
>>>> Seq operator+(Seq, Seq); // also class interface
>>>> void swap(Seq&, Seq&); // also class interface
>>>> ostream& operator<<(ostream&, Seq); // also class interface
>>>> Iter begin(Seq &); // also class interface
>>>> Iter end(Seq &); // also class interface
>>>>
>>>> // ...
>>>> bool has_duplicates(Seq const&) // not an interface
>>>>
>>>> "Being a class interface" means when I use my class, I also want these=
=20
>>>> functions to be considered in overload resolution. ADL does enable thi=
s,=20
>>>> however it also imports anything from our namespace, which is often fa=
r too=20
>>>> much.
>>>>
>>>> N3490 proposes to disable ADL in a controlled way. But for functions=
=20
>>>> that we consider an "extended class interface", we still would like th=
e ADL=20
>>>> to work.=20
>>>>
>>>>
>>> I disagree with the premise here. If I write a function f() that calls=
=20
>>> a helper function has_duplicates in the same namespace, the semantics o=
f my=20
>>> has_duplicates and those of the has_duplicates in Seq's namespace, even=
=20
>>> with such a very specific name, are quite likely to be different (eithe=
r=20
>>> slightly or dramatically). The problem is that it's easy and natural t=
o=20
>>> write an unqualified call under the assumption that "that function righ=
t=20
>>> over there, in the same namespace" will be called. This is the trap th=
at=20
>>> causes problems with ADL, and if you leave it in place, you haven't sol=
ved=20
>>> any problems.
>>>
>>
>> This is true in general. The motivation for this proposal was that some=
=20
>> functions are special, and for these you would not like to define overlo=
ads=20
>> in your own namespace. These special functions include ostream operators=
<<=20
>> and >> and functions begin(), end() and swap() which have so special=20
>> semantics already that they can be considered operators. But you are rig=
ht=20
>> that once such feature is in place, everyone could abuse it for any purp=
ose=20
>> and the ADL problem would be back.
>>
>
> I also must ask how your proposal is any different from the status quo.=
=20
>
=20
The current status quo in C++11 is that anything in the namespace of class=
=20
Seq is looked up when picking the overload. Therefore "my" proposal changes=
=20
absolutely nothing. However, it does change (I claim that in a useful way)=
=20
your proposal: N3490. In N3490 you have a way to say "disable any ADL in my=
=20
namespace". With the addition proposed here, you cannot say that anymore;=
=20
you can say instead "disable ADL in my namespace, except for the cases=20
where class author explicitly requested that a function should always=20
participate in overload resolution". The proposal here could be a=20
"supplement" for N3490 (and also for N3515<http://www.open-std.org/jtc1/sc2=
2/wg21/docs/papers/2013/n3515.pdf>(opaque typedefs)).
I was already pointed out that what I propose is too briefly described for=
=20
others to be able to see what it is and assess whether it is useful. Let me=
=20
try to explain the motivation for it. I believe there are some functions=20
for which you always want the ADL to be there and disabling ADL could cause=
=20
unnecessary harm/confusion. These functions include most of the operators,=
=20
special functions begin(), end(), swap(), and there may be some portions=20
that you consider the type's interface that the class author does not want=
=20
to make a member, because the function is supposed to be "generic" and also=
=20
needs to work for built-in types:
class SmartPtr
{
// ... other declarations
nonmember bool is_null(SmartPtr p);
};
"nonmember" is like "static" but you do not need to qualify it with=20
SmartPtr::
Function is_null ideally should be a member function, but we want to be=20
able to uniformly use it for SmartPtr and raw pointers, and we would not be=
=20
able to define a member function for a raw pointer.
With this proposal atop of N3490 the following would be the case:
namespace Lib{
class Seq
{
// normal functions
nonmember Iter begin(Seq & s);
nonmember Iter end(Seq & s);
};
bool is_empty(Seq const& s); // normal function
}
namespace User {
using =3D delete;
void test(Seq s)
{
is_empty(s); // error: no is_seq found
begin(s); // ok: begin() is part of Seq interface
}
bool begin(Seq s); // ??? not sure about this one
// prerhaps an error:
// begin() is already part of Seq interface
}
--=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/?hl=3Den.
------=_Part_705_28001431.1360054990767
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
<br><br>W dniu poniedzia=B3ek, 4 lutego 2013 23:46:12 UTC+1 u=BFytkownik Da=
ve Abrahams napisa=B3:<blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><br><br>=
On Monday, February 4, 2013 9:21:20 AM UTC-5, Andrzej Krzemie=F1ski wrote:<=
blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border=
-left:1px #ccc solid;padding-left:1ex"><br><br>W dniu poniedzia=B3ek, 4 lut=
ego 2013 14:50:26 UTC+1 u=BFytkownik Dave Abrahams napisa=B3:<blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #cc=
c solid;padding-left:1ex"><br><br>On Saturday, February 2, 2013 8:59:28 AM =
UTC-5, Andrzej Krzemie=F1ski wrote:<blockquote class=3D"gmail_quote" style=
=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"=
>I would like to throw an idea at people in this forum, and check if you=20
consider it a useful addition to C++ language. It is an elaboration on=20
the idea suggested by Vicente J. Botet Escriba: <a href=3D"https://groups.g=
oogle.com/a/isocpp.org/d/msg/std-proposals/-u6e-rohWXM/FJeR8QL3pBcJ" target=
=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msg/std-<wbr>prop=
osals/-u6e-rohWXM/<wbr>FJeR8QL3pBcJ</a>.<br><br>It
is based on observation that the interface of a class type consists not
only of its member functions, but also of some non-member functions:<br><b=
r><div 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><div><=
span style=3D"color:#008">class</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#606">Seq</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#660">{</span><span style=3D"color:#000"><br> </sp=
an><span style=3D"color:#800">// ...</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br><b=
r></span><span style=3D"color:#606">Seq</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">operator</span><span style=3D"color:#660">=
+(</span><span style=3D"color:#606">Seq</span><span style=3D"color:#660">,<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#606">Seq</sp=
an><span style=3D"color:#660">);</span><span style=3D"color:#000"> </span><=
span style=3D"color:#800">// also class interface</span><span style=3D"colo=
r:#000"><br></span><span style=3D"color:#008">void</span><span style=3D"col=
or:#000"> swap</span><span style=3D"color:#660">(</span><span style=3D"colo=
r:#606">Seq</span><span style=3D"color:#660">&,</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#606">Seq</span><span style=3D"color=
:#660">&);</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#800">// also class interface</span><span style=3D"color:#000"><br>ostrea=
m</span><span style=3D"color:#660">&</span><span style=3D"color:#000"> =
</span><span style=3D"color:#008">operator</span><span style=3D"color:#660"=
><<(</span><span style=3D"color:#000">ostream</span><span style=3D"co=
lor:#660">&,</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#606">Seq</span><span style=3D"color:#660">);</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#800">// also class interface</span><s=
pan style=3D"color:#000"><br></span><span style=3D"color:#606">Iter</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">begin</span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#606">Seq</span><span=
style=3D"color:#000"> </span><span style=3D"color:#660">&);</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#800">// also class int=
erface</span><span style=3D"color:#000"><br></span><span style=3D"color:#60=
6">Iter</span><span style=3D"color:#000"> </span><span style=3D"color:#008"=
>end</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Se=
q</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&=
);</span><span style=3D"color:#000"> </span><span style=3D"color:#800">// a=
lso class interface</span><span style=3D"color:#000"><br><br></span><span s=
tyle=3D"color:#800">// ...</span><span style=3D"color:#000"><br></span><spa=
n style=3D"color:#008">bool</span><span style=3D"color:#000"> has_duplicate=
s</span><span style=3D"color:#660">(</span><span style=3D"color:#606">Seq</=
span><span style=3D"color:#000"> </span><span style=3D"color:#008">const</s=
pan><span style=3D"color:#660">&)</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#800">// not an interface</span><span style=3D"col=
or:#000"><br></span></div></code></div><br>"Being
a class interface" means when I use my class, I also want these=20
functions to be considered in overload resolution. ADL does enable this,
however it also imports anything from our namespace, which is often far
too much.<br><br>N3490 proposes to disable ADL in a controlled way. But
for functions that we consider an "extended class interface", we still=20
would like the ADL to work. <br><br></blockquote><div><br></div><div>I disa=
gree with the premise here. If I write a function f() that calls a he=
lper function has_duplicates in the same namespace, the semantics of my has=
_duplicates and those of the has_duplicates in Seq's namespace, even with s=
uch a very specific name, are quite likely to be different (either slightly=
or dramatically). The problem is that it's easy and natural to write=
an unqualified call under the assumption that "that function right over th=
ere, in the same namespace" will be called. This is the trap that cau=
ses problems with ADL, and if you leave it in place, you haven't solved any=
problems.</div></blockquote><div><br>This is true in general. The motivati=
on for this proposal was that some functions are special, and for these you=
would not like to define overloads in your own namespace. These special fu=
nctions include ostream operators << and >> and functions begin=
(), end() and swap() which have so special semantics already that they can =
be considered operators. But you are right that once such feature is in pla=
ce, everyone could abuse it for any purpose and the ADL problem would be ba=
ck.<br></div></blockquote><div><br></div><div>I also must ask how your prop=
osal is any different from the status quo. </div></blockquote><div>&nb=
sp;</div><div>The current status quo in C++11 is that anything in the names=
pace of class <span style=3D"font-family: courier new,monospace;">Seq</span=
> is looked up when picking the overload. Therefore "my" proposal changes a=
bsolutely nothing. However, it does change (I claim that in a useful way) y=
our proposal: N3490. In N3490 you have a way to say "disable any ADL in my =
namespace". With the addition proposed here, you cannot say that anymore; y=
ou can say instead "disable ADL in my namespace, except for the cases where=
class author explicitly requested that a function should always participat=
e in overload resolution". The proposal here could be a "supplement" for N3=
490 (and also for <a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/pa=
pers/2013/n3515.pdf">N3515</a> (opaque typedefs)).<br><br>I was already poi=
nted out that what I propose is too briefly described for others to be able=
to see what it is and assess whether it is useful. Let me try to explain t=
he motivation for it. I believe there are some functions for which you alwa=
ys want the ADL to be there and disabling ADL could cause unnecessary harm/=
confusion. These functions include most of the operators, special functions=
begin(), end(), swap(), and there may be some portions that you consider t=
he type's interface that the class author does not want to make a member, b=
ecause the function is supposed to be "generic" and also needs to work for =
built-in types:<br><br><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"><d=
iv class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by=
-prettify">class</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Sma=
rtPtr</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><s=
pan style=3D"color: #800;" class=3D"styled-by-prettify">// ... other declar=
ations</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
nonmember </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">bool</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> is_null</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">SmartPtr</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> p</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span></div></code></div><br>"nonmemb=
er" is like "static" but you do not need to qualify it with <span style=3D"=
font-family: courier new,monospace;">SmartPtr::</span><br>Function <span st=
yle=3D"font-family: courier new,monospace;">is_null</span> ideally should b=
e a member function, but we want to be able to uniformly use it for <span s=
tyle=3D"font-family: courier new,monospace;">SmartPtr </span>and raw pointe=
rs, and we would not be able to define a member function for a raw pointer.=
<br><br>With this proposal atop of N3490 the following would be the case:<b=
r><br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 2=
50); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1=
px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpr=
ettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">namesp=
ace</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #606;" class=3D"styled-by-prettify">Lib</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br> </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">class</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;"=
class=3D"styled-by-prettify">Seq</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br> </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">// normal functions</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br> nonmember </span><span s=
tyle=3D"color: #606;" class=3D"styled-by-prettify">Iter</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">begin</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">Seq</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-prettif=
y"> s</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &n=
bsp; nonmember </span><span style=3D"color: #606;" class=3D"styled-by-prett=
ify">Iter</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">end</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #606;" class=3D"styled-by-prettify">Seq</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">&</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> s</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br> </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br><br> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">bool</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> is_empty</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Seq</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> s</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: #800;" class=3D"st=
yled-by-prettify">// normal function</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><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">namespace</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">U=
ser</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"><br> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">using</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">delete</span><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"styl=
ed-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> test</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Seq<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> s</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br> is_empty</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">s</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: no is_seq found</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br> </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">begin</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify">s</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"sty=
led-by-prettify">// ok: begin() is part of Seq interface</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br><br> </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 style=3D"color: #008;" =
class=3D"styled-by-prettify">begin</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">Seq</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> s</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">// ??? not sure a=
bout this one</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br>  =
; </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//=
prerhaps an error:</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br> =
</span><span style=3D"color: #800;" class=3D"styled-by-pretti=
fy">//</span><span style=3D"color: #800;" class=3D"styled-by-prettify"> beg=
in() is already part of Seq interface</span><span style=3D"color: #000;" cl=
ass=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-b=
y-prettify"><br></span></div></code></div><br><br><br><br><br><br><br></div=
>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_705_28001431.1360054990767--
.