Topic: Resovling ambiguity override in multiple inheritance


Author: lanxingcan@gmail.com
Date: Mon, 26 Oct 2015 04:25:53 -0700 (PDT)
Raw View
------=_Part_5756_1042460092.1445858753628
Content-Type: multipart/alternative;
 boundary="----=_Part_5757_1593331851.1445858753629"

------=_Part_5757_1593331851.1445858753629
Content-Type: text/plain; charset=UTF-8



Currently virtual function override is ambiguity when a class inheriates from
multiple class and those class have member function with same name and singature.
see http://stackoverflow.com/questions/3150310/c-virtual-override-functions-with-same-name
I want to propose a new syntax to resolve this.

class A
{
public:
  virtual void f(int);
};

class B
{
public:
  virtual void f(int);
};

class C : public A, public B
{
public:
  virtual void f(int) override; // Both A::f(int) and B::f(int) are overridden
};

class D : public A, public B
{
public:
  virtual void f(int) override(A); // Proposed syntax, ovrride A::f(int)
  virtual void f(int) override(B); // Override B::f(int)
};

Any comment?

--

---
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_5757_1593331851.1445858753629
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><pre style=3D"font-size: 9pt;"><span style=3D"font-family:=
 courier new,monospace;"><span style=3D"color: rgb(0, 0, 0);"><span style=
=3D"background-color: rgb(255, 255, 255);"><span style=3D"font-family: verd=
ana,sans-serif;">Currently </span></span></span></span><span style=3D"font-=
family: courier new,monospace;"><span style=3D"color: rgb(0, 0, 0);"><span =
style=3D"background-color: rgb(255, 255, 255);"><span style=3D"font-family:=
 verdana,sans-serif;"><span style=3D"font-family: courier new,monospace;"><=
span style=3D"color: rgb(0, 0, 0);"><span style=3D"background-color: rgb(25=
5, 255, 255);"><span style=3D"font-family: verdana,sans-serif;"></span></sp=
an></span></span>virtual function override is ambiguity when a class inheri=
ates from <br>multiple class and those class have member function with same=
 name and singature.<br>see http://stackoverflow.com/questions/3150310/c-vi=
rtual-override-functions-with-same-name<br>I want to propose a new syntax t=
o resolve this.<br></span><span style=3D"font-weight: bold;">=C2=A0<br>clas=
s </span>A<br>{<br><span style=3D"font-weight: bold;">public</span>:<br>  <=
span style=3D"font-weight: bold;">virtual void </span>f(<span style=3D"font=
-weight: bold;">int</span>);<br>};<br><br><span style=3D"font-weight: bold;=
">class </span>B<br>{<br><span style=3D"font-weight: bold;">public</span>:<=
br>  <span style=3D"font-weight: bold;">virtual void </span>f(<span style=
=3D"font-weight: bold;">int</span>);<br>};<br><br><span style=3D"font-weigh=
t: bold;">class </span>C : <span style=3D"font-weight: bold;">public </span=
>A, <span style=3D"font-weight: bold;">public </span>B<br>{<br><span style=
=3D"font-weight: bold;">public</span>:<br>  <span style=3D"font-weight: bol=
d;">virtual void </span>f(<span style=3D"font-weight: bold;">int</span>) <s=
pan style=3D"font-weight: bold;">override</span>; // Both A::f(int) and B::=
f(int) are overridden<br>};<br><br><span style=3D"font-weight: bold;">class=
 </span>D : <span style=3D"font-weight: bold;">public </span>A, <span style=
=3D"font-weight: bold;">public </span>B<br>{<br><span style=3D"font-weight:=
 bold;">public</span>:<br>  <span style=3D"font-weight: bold;">virtual void=
 </span>f(<span style=3D"font-weight: bold;">int</span>) <span style=3D"fon=
t-weight: bold;">override</span>(A); // </span></span></span><span style=3D=
"font-family: courier new,monospace;"><span style=3D"color: rgb(0, 0, 0);">=
<span style=3D"background-color: rgb(255, 255, 255);"><span class=3D"word-t=
ext">Proposed</span> syntax, ovrride A::f(int) <br><span style=3D"font-weig=
ht: bold;">  virtual void </span>f(<span style=3D"font-weight: bold;">int</=
span>) <span style=3D"font-weight: bold;">override</span>(B); // Override B=
::f(int) <br>};<br></span></span></span><span style=3D"font-family: courier=
 new,monospace;"><span style=3D"color: rgb(0, 0, 0);"><span style=3D"backgr=
ound-color: rgb(255, 255, 255);"><span style=3D"font-family: verdana,sans-s=
erif;"> <br>Any comment?</span></span></span></span><br></pre></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
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_5757_1593331851.1445858753629--
------=_Part_5756_1042460092.1445858753628--

.


Author: Alisdair Meredith <alisdairm@me.com>
Date: Mon, 26 Oct 2015 09:11:31 -0400
Raw View
--Apple-Mail=_EB6E7E76-23AB-4C7B-947B-AD3E9E485A38
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8

This design was considered and rejected during the initial
development of the current syntax.  There were a couple
of variations, and we had some useful experience with the
Microsoft C++/CLI model to draw upon too.

The form you are proposing would require overloading on
the =E2=80=98override=E2=80=99 keyword.  That would be very subtle, allow
functions to potentially not override a method from one of
their base classes (controversial new semantic) and require
an ABI change to name mangling if we allowed it (ABI
breakage is very controversial) so that two otherwise identical
function signatures can overload on the override.  At the
time of the proposal, even supporting =E2=80=98override=E2=80=99 was a hard
sell as it did not have the same perceived values as =E2=80=98const=E2=80=
=99,
we had been writing correct programs without it for a decade
or longer, so it was being proposed as an attribute.  Overloading
on attributes would have been even more controversial and was
definitely out of scope for this feature.

The alternative we considered was to allow the =E2=80=98override=E2=80=99 k=
eyword
to go on functions with a different name, and then say which function
they override.  This solves the overloading problem, and potentially
the ABI problem, but is very confusing when looking into deeper
class hierarchies as it is no longer obvious which function will be
invoked when a virtual function in a base is called.  This is closer
to the MS C++/CLI model.

The third model was the path of least resistance that we adopted:
preserve the existing (familiar) semantics and ABI of C++, but
add an extra check to validate assumptions, when requested.
This as least likely to break anyone (and I have not even got
started on the template cases yet ;))

AlisdairM

> On Oct 26, 2015, at 7:25 AM, lanxingcan@gmail.com wrote:
>=20
> Currently virtual function override is ambiguity when a class inheriates =
from=20
> multiple class and those class have member function with same name and si=
ngature.
> see http://stackoverflow.com/questions/3150310/c-virtual-override-functio=
ns-with-same-name
> I want to propose a new syntax to resolve this.
> =20
> class A
> {
> public:
>   virtual void f(int);
> };
>=20
> class B
> {
> public:
>   virtual void f(int);
> };
>=20
> class C : public A, public B
> {
> public:
>   virtual void f(int) override; // Both A::f(int) and B::f(int) are overr=
idden
> };
>=20
> class D : public A, public B
> {
> public:
>   virtual void f(int) override(A); // Proposed syntax, ovrride A::f(int)=
=20
>   virtual void f(int) override(B); // Override B::f(int)=20
> };
> =20
> Any comment?
>=20
> --=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=
 email to std-proposals+unsubscribe@isocpp.org <mailto:std-proposals+unsubs=
cribe@isocpp.org>.
> To post to this group, send email to std-proposals@isocpp.org <mailto:std=
-proposals@isocpp.org>.
> Visit this group at http://groups.google.com/a/isocpp.org/group/std-propo=
sals/ <http://groups.google.com/a/isocpp.org/group/std-proposals/>.

--=20

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

--Apple-Mail=_EB6E7E76-23AB-4C7B-947B-AD3E9E485A38
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D"">This design was co=
nsidered and rejected during the initial<div class=3D"">development of the =
current syntax. &nbsp;There were a couple</div><div class=3D"">of variation=
s, and we had some useful experience with the</div><div class=3D"">Microsof=
t C++/CLI model to draw upon too.</div><div class=3D""><br class=3D""></div=
><div class=3D"">The form you are proposing would require overloading on</d=
iv><div class=3D"">the =E2=80=98override=E2=80=99 keyword. &nbsp;That would=
 be very subtle, allow</div><div class=3D"">functions to potentially not ov=
erride a method from one of</div><div class=3D"">their base classes (contro=
versial new semantic) and require</div><div class=3D"">an ABI change to nam=
e mangling if we allowed it (ABI</div><div class=3D"">breakage is very cont=
roversial) so that two otherwise identical</div><div class=3D"">function si=
gnatures can overload on the override. &nbsp;At the</div><div class=3D"">ti=
me of the proposal, even supporting =E2=80=98override=E2=80=99 was a hard</=
div><div class=3D"">sell as it did not have the same perceived values as =
=E2=80=98const=E2=80=99,</div><div class=3D"">we had been writing correct p=
rograms without it for a decade</div><div class=3D"">or longer, so it was b=
eing proposed as an attribute. &nbsp;Overloading</div><div class=3D"">on at=
tributes would have been even more controversial and was</div><div class=3D=
"">definitely out of scope for this feature.</div><div class=3D""><br class=
=3D""></div><div class=3D"">The alternative we considered was to allow the =
=E2=80=98override=E2=80=99 keyword</div><div class=3D"">to go on functions =
with a different name, and then say which function</div><div class=3D"">the=
y override. &nbsp;This solves the overloading problem, and potentially</div=
><div class=3D"">the ABI problem, but is very confusing when looking into d=
eeper</div><div class=3D"">class hierarchies as it is no longer obvious whi=
ch function will be</div><div class=3D"">invoked when a virtual function in=
 a base is called. &nbsp;This is closer</div><div class=3D"">to the MS C++/=
CLI model.</div><div class=3D""><br class=3D""></div><div class=3D"">The th=
ird model was the path of least resistance that we adopted:</div><div class=
=3D"">preserve the existing (familiar) semantics and ABI of C++, but</div><=
div class=3D"">add an extra check to validate assumptions, when requested.<=
/div><div class=3D"">This as least likely to break anyone (and I have not e=
ven got</div><div class=3D"">started on the template cases yet ;))</div><di=
v class=3D""><br class=3D""></div><div class=3D"">AlisdairM</div><div class=
=3D""><br class=3D""><div><blockquote type=3D"cite" class=3D""><div class=
=3D"">On Oct 26, 2015, at 7:25 AM, <a href=3D"mailto:lanxingcan@gmail.com" =
class=3D"">lanxingcan@gmail.com</a> wrote:</div><br class=3D"Apple-intercha=
nge-newline"><div class=3D""><div dir=3D"ltr" class=3D""><pre style=3D"font=
-size: 9pt;" class=3D""><span style=3D"font-family: courier new,monospace;"=
 class=3D""><span style=3D"" class=3D""><span style=3D"background-color: rg=
b(255, 255, 255);" class=3D""><span style=3D"font-family: verdana,sans-seri=
f;" class=3D"">Currently </span></span></span></span><span style=3D"font-fa=
mily: courier new,monospace;" class=3D""><span style=3D"" class=3D""><span =
style=3D"background-color: rgb(255, 255, 255);" class=3D""><span style=3D"f=
ont-family: verdana,sans-serif;" class=3D""><span style=3D"font-family: cou=
rier new,monospace;" class=3D""><span style=3D"" class=3D""><span style=3D"=
background-color: rgb(255, 255, 255);" class=3D""><span style=3D"font-famil=
y: verdana,sans-serif;" class=3D""></span></span></span></span>virtual func=
tion override is ambiguity when a class inheriates from <br class=3D"">mult=
iple class and those class have member function with same name and singatur=
e.<br class=3D"">see <a href=3D"http://stackoverflow.com/questions/3150310/=
c-virtual-override-functions-with-same-name" class=3D"">http://stackoverflo=
w.com/questions/3150310/c-virtual-override-functions-with-same-name</a><br =
class=3D"">I want to propose a new syntax to resolve this.<br class=3D""></=
span><span style=3D"font-weight: bold;" class=3D"">&nbsp;<br class=3D"">cla=
ss </span>A<br class=3D"">{<br class=3D""><span style=3D"font-weight: bold;=
" class=3D"">public</span>:<br class=3D"">  <span style=3D"font-weight: bol=
d;" class=3D"">virtual void </span>f(<span style=3D"font-weight: bold;" cla=
ss=3D"">int</span>);<br class=3D"">};<br class=3D""><br class=3D""><span st=
yle=3D"font-weight: bold;" class=3D"">class </span>B<br class=3D"">{<br cla=
ss=3D""><span style=3D"font-weight: bold;" class=3D"">public</span>:<br cla=
ss=3D"">  <span style=3D"font-weight: bold;" class=3D"">virtual void </span=
>f(<span style=3D"font-weight: bold;" class=3D"">int</span>);<br class=3D""=
>};<br class=3D""><br class=3D""><span style=3D"font-weight: bold;" class=
=3D"">class </span>C : <span style=3D"font-weight: bold;" class=3D"">public=
 </span>A, <span style=3D"font-weight: bold;" class=3D"">public </span>B<br=
 class=3D"">{<br class=3D""><span style=3D"font-weight: bold;" class=3D"">p=
ublic</span>:<br class=3D"">  <span style=3D"font-weight: bold;" class=3D""=
>virtual void </span>f(<span style=3D"font-weight: bold;" class=3D"">int</s=
pan>) <span style=3D"font-weight: bold;" class=3D"">override</span>; // Bot=
h A::f(int) and B::f(int) are overridden<br class=3D"">};<br class=3D""><br=
 class=3D""><span style=3D"font-weight: bold;" class=3D"">class </span>D : =
<span style=3D"font-weight: bold;" class=3D"">public </span>A, <span style=
=3D"font-weight: bold;" class=3D"">public </span>B<br class=3D"">{<br class=
=3D""><span style=3D"font-weight: bold;" class=3D"">public</span>:<br class=
=3D"">  <span style=3D"font-weight: bold;" class=3D"">virtual void </span>f=
(<span style=3D"font-weight: bold;" class=3D"">int</span>) <span style=3D"f=
ont-weight: bold;" class=3D"">override</span>(A); // </span></span></span><=
span style=3D"font-family: courier new,monospace;" class=3D"">Proposed synt=
ax, ovrride A::f(int) <br class=3D""><span style=3D"font-weight: bold;" cla=
ss=3D"">  virtual void </span>f(<span style=3D"font-weight: bold;" class=3D=
"">int</span>) <span style=3D"font-weight: bold;" class=3D"">override</span=
>(B); // Override B::f(int) <br class=3D"">};<br class=3D""></span><span st=
yle=3D"font-family: courier new,monospace;" class=3D""><span style=3D"" cla=
ss=3D""><span style=3D"background-color: rgb(255, 255, 255);" class=3D""><s=
pan style=3D"font-family: verdana,sans-serif;" class=3D""> <br class=3D"">A=
ny comment?</span></span></span></span><br class=3D""></pre></div><div clas=
s=3D""><br class=3D"webkit-block-placeholder"></div>

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

--Apple-Mail=_EB6E7E76-23AB-4C7B-947B-AD3E9E485A38--

.


Author: Alisdair Meredith <alisdairm@me.com>
Date: Mon, 26 Oct 2015 09:11:52 -0400
Raw View
--Apple-Mail=_C6B7BF20-197E-4100-97F8-8D230EB60F09
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8

This design was considered and rejected during the initial
development of the current syntax.  There were a couple
of variations, and we had some useful experience with the
Microsoft C++/CLI model to draw upon too.

The form you are proposing would require overloading on
the =E2=80=98override=E2=80=99 keyword.  That would be very subtle, allow
functions to potentially not override a method from one of
their base classes (controversial new semantic) and require
an ABI change to name mangling if we allowed it (ABI
breakage is very controversial) so that two otherwise identical
function signatures can overload on the override.  At the
time of the proposal, even supporting =E2=80=98override=E2=80=99 was a hard
sell as it did not have the same perceived values as =E2=80=98const=E2=80=
=99,
we had been writing correct programs without it for a decade
or longer, so it was being proposed as an attribute.  Overloading
on attributes would have been even more controversial and was
definitely out of scope for this feature.

The alternative we considered was to allow the =E2=80=98override=E2=80=99 k=
eyword
to go on functions with a different name, and then say which function
they override.  This solves the overloading problem, and potentially
the ABI problem, but is very confusing when looking into deeper
class hierarchies as it is no longer obvious which function will be
invoked when a virtual function in a base is called.  This is closer
to the MS C++/CLI model.

The third model was the path of least resistance that we adopted:
preserve the existing (familiar) semantics and ABI of C++, but
add an extra check to validate assumptions, when requested.
This as least likely to break anyone (and I have not even got
started on the template cases yet ;))

AlisdairM

> On Oct 26, 2015, at 7:25 AM, lanxingcan@gmail.com <mailto:lanxingcan@gmai=
l.com> wrote:
>=20
> Currently virtual function override is ambiguity when a class inheriates =
from=20
> multiple class and those class have member function with same name and si=
ngature.
> see http://stackoverflow.com/questions/3150310/c-virtual-override-functio=
ns-with-same-name <http://stackoverflow.com/questions/3150310/c-virtual-ove=
rride-functions-with-same-name>
> I want to propose a new syntax to resolve this.
> =20
> class A
> {
> public:
>   virtual void f(int);
> };
>=20
> class B
> {
> public:
>   virtual void f(int);
> };
>=20
> class C : public A, public B
> {
> public:
>   virtual void f(int) override; // Both A::f(int) and B::f(int) are overr=
idden
> };
>=20
> class D : public A, public B
> {
> public:
>   virtual void f(int) override(A); // Proposed syntax, ovrride A::f(int)=
=20
>   virtual void f(int) override(B); // Override B::f(int)=20
> };
> =20
> Any comment?
>=20
> --=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=
 email to std-proposals+unsubscribe@isocpp.org <mailto:std-proposals+unsubs=
cribe@isocpp.org>.
> To post to this group, send email to std-proposals@isocpp.org <mailto:std=
-proposals@isocpp.org>.
> Visit this group at http://groups.google.com/a/isocpp.org/group/std-propo=
sals/ <http://groups.google.com/a/isocpp.org/group/std-proposals/>.

--=20

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

--Apple-Mail=_C6B7BF20-197E-4100-97F8-8D230EB60F09
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"><meta http-equiv=3D"Content-Type" content=3D"text/html charset=3D=
utf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: spac=
e; -webkit-line-break: after-white-space;" class=3D"">This design was consi=
dered and rejected during the initial<div class=3D"">development of the cur=
rent syntax. &nbsp;There were a couple</div><div class=3D"">of variations, =
and we had some useful experience with the</div><div class=3D"">Microsoft C=
++/CLI model to draw upon too.</div><div class=3D""><br class=3D""></div><d=
iv class=3D"">The form you are proposing would require overloading on</div>=
<div class=3D"">the =E2=80=98override=E2=80=99 keyword. &nbsp;That would be=
 very subtle, allow</div><div class=3D"">functions to potentially not overr=
ide a method from one of</div><div class=3D"">their base classes (controver=
sial new semantic) and require</div><div class=3D"">an ABI change to name m=
angling if we allowed it (ABI</div><div class=3D"">breakage is very controv=
ersial) so that two otherwise identical</div><div class=3D"">function signa=
tures can overload on the override. &nbsp;At the</div><div class=3D"">time =
of the proposal, even supporting =E2=80=98override=E2=80=99 was a hard</div=
><div class=3D"">sell as it did not have the same perceived values as =E2=
=80=98const=E2=80=99,</div><div class=3D"">we had been writing correct prog=
rams without it for a decade</div><div class=3D"">or longer, so it was bein=
g proposed as an attribute. &nbsp;Overloading</div><div class=3D"">on attri=
butes would have been even more controversial and was</div><div class=3D"">=
definitely out of scope for this feature.</div><div class=3D""><br class=3D=
""></div><div class=3D"">The alternative we considered was to allow the =E2=
=80=98override=E2=80=99 keyword</div><div class=3D"">to go on functions wit=
h a different name, and then say which function</div><div class=3D"">they o=
verride. &nbsp;This solves the overloading problem, and potentially</div><d=
iv class=3D"">the ABI problem, but is very confusing when looking into deep=
er</div><div class=3D"">class hierarchies as it is no longer obvious which =
function will be</div><div class=3D"">invoked when a virtual function in a =
base is called. &nbsp;This is closer</div><div class=3D"">to the MS C++/CLI=
 model.</div><div class=3D""><br class=3D""></div><div class=3D"">The third=
 model was the path of least resistance that we adopted:</div><div class=3D=
"">preserve the existing (familiar) semantics and ABI of C++, but</div><div=
 class=3D"">add an extra check to validate assumptions, when requested.</di=
v><div class=3D"">This as least likely to break anyone (and I have not even=
 got</div><div class=3D"">started on the template cases yet ;))</div><div c=
lass=3D""><br class=3D""></div><div class=3D"">AlisdairM</div><div class=3D=
""><br class=3D""><div class=3D""><blockquote type=3D"cite" class=3D""><div=
 class=3D"">On Oct 26, 2015, at 7:25 AM, <a href=3D"mailto:lanxingcan@gmail=
..com" class=3D"">lanxingcan@gmail.com</a> wrote:</div><br class=3D"Apple-in=
terchange-newline"><div class=3D""><div dir=3D"ltr" class=3D""><pre style=
=3D"font-size: 9pt;" class=3D""><span style=3D"font-family: courier new,mon=
ospace;" class=3D""><span style=3D"" class=3D""><span style=3D"background-c=
olor: rgb(255, 255, 255);" class=3D""><span style=3D"font-family: verdana,s=
ans-serif;" class=3D"">Currently </span></span></span></span><span style=3D=
"font-family: courier new,monospace;" class=3D""><span style=3D"" class=3D"=
"><span style=3D"background-color: rgb(255, 255, 255);" class=3D""><span st=
yle=3D"font-family: verdana,sans-serif;" class=3D""><span style=3D"font-fam=
ily: courier new,monospace;" class=3D""><span style=3D"" class=3D""><span s=
tyle=3D"background-color: rgb(255, 255, 255);" class=3D""><span style=3D"fo=
nt-family: verdana,sans-serif;" class=3D""></span></span></span></span>virt=
ual function override is ambiguity when a class inheriates from <br class=
=3D"">multiple class and those class have member function with same name an=
d singature.<br class=3D"">see <a href=3D"http://stackoverflow.com/question=
s/3150310/c-virtual-override-functions-with-same-name" class=3D"">http://st=
ackoverflow.com/questions/3150310/c-virtual-override-functions-with-same-na=
me</a><br class=3D"">I want to propose a new syntax to resolve this.<br cla=
ss=3D""></span><span style=3D"font-weight: bold;" class=3D"">&nbsp;<br clas=
s=3D"">class </span>A<br class=3D"">{<br class=3D""><span style=3D"font-wei=
ght: bold;" class=3D"">public</span>:<br class=3D"">  <span style=3D"font-w=
eight: bold;" class=3D"">virtual void </span>f(<span style=3D"font-weight: =
bold;" class=3D"">int</span>);<br class=3D"">};<br class=3D""><br class=3D"=
"><span style=3D"font-weight: bold;" class=3D"">class </span>B<br class=3D"=
">{<br class=3D""><span style=3D"font-weight: bold;" class=3D"">public</spa=
n>:<br class=3D"">  <span style=3D"font-weight: bold;" class=3D"">virtual v=
oid </span>f(<span style=3D"font-weight: bold;" class=3D"">int</span>);<br =
class=3D"">};<br class=3D""><br class=3D""><span style=3D"font-weight: bold=
;" class=3D"">class </span>C : <span style=3D"font-weight: bold;" class=3D"=
">public </span>A, <span style=3D"font-weight: bold;" class=3D"">public </s=
pan>B<br class=3D"">{<br class=3D""><span style=3D"font-weight: bold;" clas=
s=3D"">public</span>:<br class=3D"">  <span style=3D"font-weight: bold;" cl=
ass=3D"">virtual void </span>f(<span style=3D"font-weight: bold;" class=3D"=
">int</span>) <span style=3D"font-weight: bold;" class=3D"">override</span>=
; // Both A::f(int) and B::f(int) are overridden<br class=3D"">};<br class=
=3D""><br class=3D""><span style=3D"font-weight: bold;" class=3D"">class </=
span>D : <span style=3D"font-weight: bold;" class=3D"">public </span>A, <sp=
an style=3D"font-weight: bold;" class=3D"">public </span>B<br class=3D"">{<=
br class=3D""><span style=3D"font-weight: bold;" class=3D"">public</span>:<=
br class=3D"">  <span style=3D"font-weight: bold;" class=3D"">virtual void =
</span>f(<span style=3D"font-weight: bold;" class=3D"">int</span>) <span st=
yle=3D"font-weight: bold;" class=3D"">override</span>(A); // </span></span>=
</span><span style=3D"font-family: courier new,monospace;" class=3D"">Propo=
sed syntax, ovrride A::f(int) <br class=3D""><span style=3D"font-weight: bo=
ld;" class=3D"">  virtual void </span>f(<span style=3D"font-weight: bold;" =
class=3D"">int</span>) <span style=3D"font-weight: bold;" class=3D"">overri=
de</span>(B); // Override B::f(int) <br class=3D"">};<br class=3D""></span>=
<span style=3D"font-family: courier new,monospace;" class=3D""><span style=
=3D"" class=3D""><span style=3D"background-color: rgb(255, 255, 255);" clas=
s=3D""><span style=3D"font-family: verdana,sans-serif;" class=3D""> <br cla=
ss=3D"">Any comment?</span></span></span></span><br class=3D""></pre></div>=
<div class=3D""><br class=3D"webkit-block-placeholder"></div>

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

--Apple-Mail=_C6B7BF20-197E-4100-97F8-8D230EB60F09--

.


Author: lanxingcan@gmail.com
Date: Mon, 26 Oct 2015 06:58:49 -0700 (PDT)
Raw View
------=_Part_6025_336630735.1445867929816
Content-Type: multipart/alternative;
 boundary="----=_Part_6026_741193121.1445867929816"

------=_Part_6026_741193121.1445867929816
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Thanks for your attention.

You're right and I haven't considered that deep.=20

I went to check the MS C++/CLI syntax, it=E2=80=99s more reasonable than mi=
ne,=20
consisting with =3D 0|delete|default. Through this way may confuse people
 when function got renamed, it's still better than unable to clasify which=
=20
one to
overload at all, in my opions.

Any way thanks for your reply.

=E5=9C=A8 2015=E5=B9=B410=E6=9C=8826=E6=97=A5=E6=98=9F=E6=9C=9F=E4=B8=80 UT=
C+8=E4=B8=8B=E5=8D=889:11:51=EF=BC=8CAlisdair Meredith=E5=86=99=E9=81=93=EF=
=BC=9A
>
> This design was considered and rejected during the initial
> development of the current syntax.  There were a couple
> of variations, and we had some useful experience with the
> Microsoft C++/CLI model to draw upon too.
>
> The form you are proposing would require overloading on
> the =E2=80=98override=E2=80=99 keyword.  That would be very subtle, allow
> functions to potentially not override a method from one of
> their base classes (controversial new semantic) and require
> an ABI change to name mangling if we allowed it (ABI
> breakage is very controversial) so that two otherwise identical
> function signatures can overload on the override.  At the
> time of the proposal, even supporting =E2=80=98override=E2=80=99 was a ha=
rd
> sell as it did not have the same perceived values as =E2=80=98const=E2=80=
=99,
> we had been writing correct programs without it for a decade
> or longer, so it was being proposed as an attribute.  Overloading
> on attributes would have been even more controversial and was
> definitely out of scope for this feature.
>
> The alternative we considered was to allow the =E2=80=98override=E2=80=99=
 keyword
> to go on functions with a different name, and then say which function
> they override.  This solves the overloading problem, and potentially
> the ABI problem, but is very confusing when looking into deeper
> class hierarchies as it is no longer obvious which function will be
> invoked when a virtual function in a base is called.  This is closer
> to the MS C++/CLI model.
>
> The third model was the path of least resistance that we adopted:
> preserve the existing (familiar) semantics and ABI of C++, but
> add an extra check to validate assumptions, when requested.
> This as least likely to break anyone (and I have not even got
> started on the template cases yet ;))
>
> AlisdairM
>
> On Oct 26, 2015, at 7:25 AM, lanxi...@gmail.com <javascript:> wrote:
>
> Currently virtual function override is ambiguity when a class inheriates =
from=20
> multiple class and those class have member function with same name and si=
ngature.
> see http://stackoverflow.com/questions/3150310/c-virtual-override-functio=
ns-with-same-name
> I want to propose a new syntax to resolve this.
> =20
> class A
> {
> public:
>   virtual void f(int);
> };
>
> class B
> {
> public:
>   virtual void f(int);
> };
>
> class C : public A, public B
> {
> public:
>   virtual void f(int) override; // Both A::f(int) and B::f(int) are overr=
idden
> };
>
> class D : public A, public B
> {
> public:
>   virtual void f(int) override(A); // Proposed syntax, ovrride A::f(int)=
=20
>   virtual void f(int) override(B); // Override B::f(int)=20
> };
> =20
> Any comment?
>
>
> --=20
>
> ---=20
> You received this message because you are subscribed to the Google Groups=
=20
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an=
=20
> email to std-proposal...@isocpp.org <javascript:>.
> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
> Visit this group at=20
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
>
>

--=20

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

------=_Part_6026_741193121.1445867929816
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thanks for your attention.<br><br>You&#39;re right and I h=
aven&#39;t considered that deep. <br><br>I went to check the MS C++/CLI syn=
tax, it=E2=80=99s more reasonable than mine, <br>consisting with =3D 0|dele=
te|default. Through this way may confuse people<br>=C2=A0when function got =
renamed, it&#39;s still better than unable to clasify which one to<br>overl=
oad at all, in my opions.<br><br>Any way thanks for your reply.<br><br>=E5=
=9C=A8 2015=E5=B9=B410=E6=9C=8826=E6=97=A5=E6=98=9F=E6=9C=9F=E4=B8=80 UTC+8=
=E4=B8=8B=E5=8D=889:11:51=EF=BC=8CAlisdair Meredith=E5=86=99=E9=81=93=EF=BC=
=9A<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;=
border-left: 1px #ccc solid;padding-left: 1ex;"><div style=3D"word-wrap:bre=
ak-word">This design was considered and rejected during the initial<div>dev=
elopment of the current syntax. =C2=A0There were a couple</div><div>of vari=
ations, and we had some useful experience with the</div><div>Microsoft C++/=
CLI model to draw upon too.</div><div><br></div><div>The form you are propo=
sing would require overloading on</div><div>the =E2=80=98override=E2=80=99 =
keyword. =C2=A0That would be very subtle, allow</div><div>functions to pote=
ntially not override a method from one of</div><div>their base classes (con=
troversial new semantic) and require</div><div>an ABI change to name mangli=
ng if we allowed it (ABI</div><div>breakage is very controversial) so that =
two otherwise identical</div><div>function signatures can overload on the o=
verride. =C2=A0At the</div><div>time of the proposal, even supporting =E2=
=80=98override=E2=80=99 was a hard</div><div>sell as it did not have the sa=
me perceived values as =E2=80=98const=E2=80=99,</div><div>we had been writi=
ng correct programs without it for a decade</div><div>or longer, so it was =
being proposed as an attribute. =C2=A0Overloading</div><div>on attributes w=
ould have been even more controversial and was</div><div>definitely out of =
scope for this feature.</div><div><br></div><div>The alternative we conside=
red was to allow the =E2=80=98override=E2=80=99 keyword</div><div>to go on =
functions with a different name, and then say which function</div><div>they=
 override. =C2=A0This solves the overloading problem, and potentially</div>=
<div>the ABI problem, but is very confusing when looking into deeper</div><=
div>class hierarchies as it is no longer obvious which function will be</di=
v><div>invoked when a virtual function in a base is called. =C2=A0This is c=
loser</div><div>to the MS C++/CLI model.</div><div><br></div><div>The third=
 model was the path of least resistance that we adopted:</div><div>preserve=
 the existing (familiar) semantics and ABI of C++, but</div><div>add an ext=
ra check to validate assumptions, when requested.</div><div>This as least l=
ikely to break anyone (and I have not even got</div><div>started on the tem=
plate cases yet ;))</div><div><br></div><div>AlisdairM</div><div><br><div><=
blockquote type=3D"cite"><div>On Oct 26, 2015, at 7:25 AM, <a href=3D"javas=
cript:" target=3D"_blank" gdf-obfuscated-mailto=3D"WUm3k31DEgAJ" rel=3D"nof=
ollow" onmousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" oncli=
ck=3D"this.href=3D&#39;javascript:&#39;;return true;">lanxi...@gmail.com</a=
> wrote:</div><br><div><div dir=3D"ltr"><pre style=3D"font-size:9pt"><span =
style=3D"font-family:courier new,monospace"><span><span style=3D"background=
-color:rgb(255,255,255)"><span style=3D"font-family:verdana,sans-serif">Cur=
rently </span></span></span></span><span style=3D"font-family:courier new,m=
onospace"><span><span style=3D"background-color:rgb(255,255,255)"><span sty=
le=3D"font-family:verdana,sans-serif"><span style=3D"font-family:courier ne=
w,monospace"><span><span style=3D"background-color:rgb(255,255,255)"><span =
style=3D"font-family:verdana,sans-serif"></span></span></span></span>virtua=
l function override is ambiguity when a class inheriates from <br>multiple =
class and those class have member function with same name and singature.<br=
>see <a href=3D"http://stackoverflow.com/questions/3150310/c-virtual-overri=
de-functions-with-same-name" target=3D"_blank" rel=3D"nofollow" onmousedown=
=3D"this.href=3D&#39;http://www.google.com/url?q\75http%3A%2F%2Fstackoverfl=
ow.com%2Fquestions%2F3150310%2Fc-virtual-override-functions-with-same-name\=
46sa\75D\46sntz\0751\46usg\75AFQjCNFgWbnlz8809RonuBhUYPEym-K_TA&#39;;return=
 true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\75http%3A%2=
F%2Fstackoverflow.com%2Fquestions%2F3150310%2Fc-virtual-override-functions-=
with-same-name\46sa\75D\46sntz\0751\46usg\75AFQjCNFgWbnlz8809RonuBhUYPEym-K=
_TA&#39;;return true;">http://stackoverflow.com/<wbr>questions/3150310/c-vi=
rtual-<wbr>override-functions-with-same-<wbr>name</a><br>I want to propose =
a new syntax to resolve this.<br></span><span style=3D"font-weight:bold">=
=C2=A0<br>class </span>A<br>{<br><span style=3D"font-weight:bold">public</s=
pan>:<br>  <span style=3D"font-weight:bold">virtual void </span>f(<span sty=
le=3D"font-weight:bold">int</span>);<br>};<br><br><span style=3D"font-weigh=
t:bold">class </span>B<br>{<br><span style=3D"font-weight:bold">public</spa=
n>:<br>  <span style=3D"font-weight:bold">virtual void </span>f(<span style=
=3D"font-weight:bold">int</span>);<br>};<br><br><span style=3D"font-weight:=
bold">class </span>C : <span style=3D"font-weight:bold">public </span>A, <s=
pan style=3D"font-weight:bold">public </span>B<br>{<br><span style=3D"font-=
weight:bold">public</span>:<br>  <span style=3D"font-weight:bold">virtual v=
oid </span>f(<span style=3D"font-weight:bold">int</span>) <span style=3D"fo=
nt-weight:bold">override</span>; // Both A::f(int) and B::f(int) are overri=
dden<br>};<br><br><span style=3D"font-weight:bold">class </span>D : <span s=
tyle=3D"font-weight:bold">public </span>A, <span style=3D"font-weight:bold"=
>public </span>B<br>{<br><span style=3D"font-weight:bold">public</span>:<br=
>  <span style=3D"font-weight:bold">virtual void </span>f(<span style=3D"fo=
nt-weight:bold">int</span>) <span style=3D"font-weight:bold">override</span=
>(A); // </span></span></span><span style=3D"font-family:courier new,monosp=
ace">Proposed syntax, ovrride A::f(int) <br><span style=3D"font-weight:bold=
">  virtual void </span>f(<span style=3D"font-weight:bold">int</span>) <spa=
n style=3D"font-weight:bold">override</span>(B); // Override B::f(int) <br>=
};<br></span><span style=3D"font-family:courier new,monospace"><span><span =
style=3D"background-color:rgb(255,255,255)"><span style=3D"font-family:verd=
ana,sans-serif"> <br>Any comment?</span></span></span></span><br></pre></di=
v><div><br></div>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
WUm3k31DEgAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"WUm3k31DEgAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39=
;javascript:&#39;;return true;">std-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=
=3D&#39;http://groups.google.com/a/isocpp.org/group/std-proposals/&#39;;ret=
urn true;" onclick=3D"this.href=3D&#39;http://groups.google.com/a/isocpp.or=
g/group/std-proposals/&#39;;return true;">http://groups.google.com/a/<wbr>i=
socpp.org/group/std-<wbr>proposals/</a>.<br>
</div></blockquote></div><br></div></div></blockquote></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
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_6026_741193121.1445867929816--
------=_Part_6025_336630735.1445867929816--

.