Topic: not-using" declarations


Author: David Krauss <potswa@gmail.com>
Date: Thu, 8 Aug 2013 01:13:55 -0700 (PDT)
Raw View
------=_Part_253_340652.1375949635525
Content-Type: text/plain; charset=ISO-8859-1

Base class private members pollute the namespaces of derived classes, and
moreover of unrelated bases, because they are still found by name lookup
even if restricted by access qualification.

class a {
private:
    int foo; // Just hoping foo is a unique name here.
};

class b {
public:
    int foo; // This is a completely unrelated, public interface.
};

class c : private class a {};

class d : public b, public c {
    int bar() { return foo; } // I only know about b::foo. What's the
problem here??
};

The problem is more pronounced with commonly overloaded names. (The
function call operator is currently giving me trouble.) The way around this
is "using b::foo;", but

   1. It shouldn't be necessary; even an obvious yet necessary fix
   represents brittleness foisted by the language.
   2. In a template context the using declaration imposes an extraneous
   constraint. Maybe foo does or doesn't exist.

Idiomatically extrapolating from existing syntax, I propose this solution:

class c : private class a {
    using a::foo = delete; // foo is not found by name lookup, whatever it
is.
};

Names of private members that need not be accessed through a derived class
may thus be explicitly freed by the component that reserved them, rather
than bypassed by everyone else.

I propose that the syntax look just like that in all cases, since it
doesn't matter whether the name being freed is a template, typename,
object, or injected-class-name.

--

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

------=_Part_253_340652.1375949635525
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Base class private members pollute the namespaces of derived classes, and m=
oreover of unrelated bases, because they are still found by name lookup eve=
n if restricted by access qualification.<br><br>class a {<br>private:<br>&n=
bsp;&nbsp;&nbsp; int foo; // Just hoping foo is a unique name here.<br>};<b=
r><br>class b {<br>public:<br>&nbsp;&nbsp;&nbsp; int foo; // This is a comp=
letely unrelated, public interface.<br>};<br><br>class c : private class a =
{};<br><br>class d : public b, public c {<br>&nbsp;&nbsp;&nbsp; int bar() {=
 return foo; } // I only know about b::foo. What's the problem here??<br>};=
<br><br>The problem is more pronounced with commonly overloaded names. (The=
 function call operator is currently giving me trouble.) The way around thi=
s is "using b::foo;", but<br><ol><li>It shouldn't be necessary; even an obv=
ious yet necessary fix represents brittleness foisted by the language.</li>=
<li>In a template context the using declaration imposes an extraneous const=
raint. Maybe foo does or doesn't exist.<br></li></ol>Idiomatically extrapol=
ating from existing syntax, I propose this solution:<br><br>class c : priva=
te class a {<br>&nbsp;&nbsp;&nbsp; using a::foo =3D delete; // foo is not f=
ound by name lookup, whatever it is.<br>};<br><br>Names of private members =
that need not be accessed through a derived class may thus be explicitly fr=
eed by the component that reserved them, rather than bypassed by everyone e=
lse.<br><br>I propose that the syntax look just like that in all cases, sin=
ce it doesn't matter whether the name being freed is a template, typename, =
object, or injected-class-name.<br>

<p></p>

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

------=_Part_253_340652.1375949635525--

.


Author: David Krauss <potswa@gmail.com>
Date: Thu, 8 Aug 2013 01:51:20 -0700 (PDT)
Raw View
------=_Part_4501_21489713.1375951880902
Content-Type: text/plain; charset=ISO-8859-1


>
> Base class private members pollute the namespaces of derived classes
>

Note that I mean "namespace" in the informal, C-language sense, not the
namespace construct. And apologies for not clicking the monospace button
for the source code.

--

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



------=_Part_4501_21489713.1375951880902
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(=
204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote">Base class privat=
e members pollute the namespaces of derived classes<br></blockquote><br>Not=
e that I mean "namespace" in the informal, C-language sense, not the <code>=
namespace</code> construct. And apologies for not clicking the monospace bu=
tton for the source code.<br>

<p></p>

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

------=_Part_4501_21489713.1375951880902--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Thu, 8 Aug 2013 12:13:18 +0300
Raw View
--001a1132eb24a2c2cf04e36c11c8
Content-Type: text/plain; charset=ISO-8859-1

On 8 August 2013 11:13, David Krauss <potswa@gmail.com> wrote:

> Idiomatically extrapolating from existing syntax, I propose this solution:
>
> class c : private class a {
>     using a::foo = delete; // foo is not found by name lookup, whatever it
> is.
> };
>

Looks pretty similar to
http://open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3490.html

--

---
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/.



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

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On 8 August 2013 11:13, David Krauss <span dir=3D"ltr">&lt;<a href=
=3D"mailto:potswa@gmail.com" target=3D"_blank">potswa@gmail.com</a>&gt;</sp=
an> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">Idiomatically extrapolati=
ng from existing syntax, I propose this solution:<br><br>class c : private =
class a {<br>
=A0=A0=A0 using a::foo =3D delete; // foo is not found by name lookup, what=
ever it is.<br>};<br></blockquote><div><br></div><div>Looks pretty similar =
to<br><a href=3D"http://open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3490.=
html">http://open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3490.html</a><br=
>
<br></div></div><br></div></div>

<p></p>

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

--001a1132eb24a2c2cf04e36c11c8--

.


Author: David Krauss <potswa@gmail.com>
Date: Thu, 8 Aug 2013 02:37:54 -0700 (PDT)
Raw View
------=_Part_2804_8185361.1375954674338
Content-Type: text/plain; charset=ISO-8859-1

On Thursday, August 8, 2013 5:13:18 PM UTC+8, Ville Voutilainen wrote:
>
>
> Looks pretty similar to
> http://open-std.org/JTC1/SC22/WG21/docs/papers/2012/n3490.html
>

Similar syntax, similar problem, but different context. That paper is
concerned only with ADL but I am only concerned with member name lookup.
The two proposals could be complementary.

Thanks for the reference!

--

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



------=_Part_2804_8185361.1375954674338
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Thursday, August 8, 2013 5:13:18 PM UTC+8, Ville Voutilainen wrote:<bloc=
kquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-l=
eft: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><br><div><div clas=
s=3D"gmail_quote"><div>Looks pretty similar to<br><a href=3D"http://open-st=
d.org/JTC1/SC22/WG21/docs/papers/2012/n3490.html" target=3D"_blank">http://=
open-std.org/JTC1/SC22/<wbr>WG21/docs/papers/2012/n3490.<wbr>html</a><br></=
div></div></div></div></blockquote><div>&nbsp;<br>Similar syntax, similar p=
roblem, but different context. That paper is concerned only with ADL but I =
am only concerned with member name lookup. The two proposals could be compl=
ementary.<br><br>Thanks for the reference!<br></div>

<p></p>

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

------=_Part_2804_8185361.1375954674338--

.