Topic: Introduce "interface" concept, like in C#


Author: pfight77@gmail.com
Date: Sun, 10 Aug 2014 00:24:49 -0700 (PDT)
Raw View
------=_Part_1046_1336521471.1407655489643
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hello,

I suggest to introduce "interface" concept, like in C#. Interface will be=
=20
like a class with only pure virtual functions, and without any data=20
members. Inheritance of interface will be always virtual. Casting from=20
interface type will be allowed via static_cast.

Motivation

Diamon of Death situation:

class A {};
class B : virtual public A {};class C : virtual public A {};
class D: public B, public C {};

D* d;

A* a =3D static_cast<A*>(d); // error: =E2=80=98A=E2=80=99 is an ambiguous =
base of =E2=80=98D=E2=80=99


Virtual inheritance allow to avoid Diamon of Death situation. In case if=20
base class is like "interface" (see above), then virtual inheritance have=
=20
no side effects: we do not need to make pointer calculations for data=20
members, because there is no any of them. But, virtual inheritance forbid=
=20
use of static_cast:

class A {};
class B : virtual public A {};class C : virtual public A {};
class D: public B, public C {};

A* a;

D* d =3D static_cast<D*>(a); // error: cannot convert from base =E2=80=98A=
=E2=80=99 to derived type =E2=80=98D=E2=80=99 via virtual base =E2=80=98A=
=E2=80=99

That's why, now we can't imitate interfaces from C# with existing tools.=20
Introducing interfaces will allow use diamond inheritance for them without=
=20
any troubles.

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

<div dir=3D"ltr">Hello,<div><br></div><div>I suggest to introduce "interfac=
e" concept, like in C#. Interface will be like a class with only pure virtu=
al functions, and without any data members. Inheritance of interface will b=
e always virtual. Casting from interface type will be allowed via static_ca=
st.</div><div><br></div><div>Motivation</div><div><br></div><div>Diamon of =
Death situation:<br></div><div><br></div><div><pre class=3D"" style=3D"marg=
in-bottom: 10px; padding: 5px; font-size: 14px; background-color: rgb(238, =
238, 238); font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberat=
ion Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', m=
onospace, serif; overflow: auto; width: auto; max-height: 600px; word-wrap:=
 normal; color: rgb(0, 0, 0); line-height: 18px;"><code style=3D"font-famil=
y: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sa=
ns Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; whit=
e-space: inherit;"><span class=3D"" style=3D"background-color: transparent;=
 color: rgb(0, 0, 139);">class</span><span class=3D"" style=3D"background-c=
olor: transparent;"> A </span><span class=3D"" style=3D"background-color: t=
ransparent;">{};</span><span class=3D"" style=3D"background-color: transpar=
ent;">

</span><span class=3D"" style=3D"background-color: transparent; color: rgb(=
0, 0, 139);">class</span><span class=3D"" style=3D"background-color: transp=
arent;"> B </span><span class=3D"" style=3D"background-color: transparent;"=
>:</span><span class=3D"" style=3D"background-color: transparent;"> </span>=
<span class=3D"" style=3D"background-color: transparent; color: rgb(0, 0, 1=
39);">virtual</span><span class=3D"" style=3D"background-color: transparent=
;"> </span><span class=3D"" style=3D"background-color: transparent; color: =
rgb(0, 0, 139);">public</span><span class=3D"" style=3D"background-color: t=
ransparent;"> A </span><span class=3D"" style=3D"background-color: transpar=
ent;">{};</span><span class=3D"" style=3D"background-color: transparent;">
</span><span class=3D"" style=3D"background-color: transparent; color: rgb(=
0, 0, 139);">class</span><span class=3D"" style=3D"background-color: transp=
arent;"> C </span><span class=3D"" style=3D"background-color: transparent;"=
>:</span><span class=3D"" style=3D"background-color: transparent;"> </span>=
<span class=3D"" style=3D"background-color: transparent; color: rgb(0, 0, 1=
39);">virtual</span><span class=3D"" style=3D"background-color: transparent=
;"> </span><span class=3D"" style=3D"background-color: transparent; color: =
rgb(0, 0, 139);">public</span><span class=3D"" style=3D"background-color: t=
ransparent;"> A </span><span class=3D"" style=3D"background-color: transpar=
ent;">{};</span><span class=3D"" style=3D"background-color: transparent;">

</span><span class=3D"" style=3D"background-color: transparent; color: rgb(=
0, 0, 139);">class</span><span class=3D"" style=3D"background-color: transp=
arent;"> D</span><span class=3D"" style=3D"background-color: transparent;">=
:</span><span class=3D"" style=3D"background-color: transparent;"> </span><=
span class=3D"" style=3D"background-color: transparent; color: rgb(0, 0, 13=
9);">public</span><span class=3D"" style=3D"background-color: transparent;"=
> B</span><span class=3D"" style=3D"background-color: transparent;">,</span=
><span class=3D"" style=3D"background-color: transparent;"> </span><span cl=
ass=3D"" style=3D"background-color: transparent; color: rgb(0, 0, 139);">pu=
blic</span><span class=3D"" style=3D"background-color: transparent;"> C </s=
pan><span class=3D"" style=3D"background-color: transparent;">{};</span></c=
ode></pre><pre class=3D"" style=3D"margin-bottom: 10px; padding: 5px; font-=
size: 14px; background-color: rgb(238, 238, 238); font-family: Consolas, Me=
nlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bits=
tream Vera Sans Mono', 'Courier New', monospace, serif; overflow: auto; wid=
th: auto; max-height: 600px; word-wrap: normal; color: rgb(0, 0, 0); line-h=
eight: 18px;"><span style=3D"background-color: transparent;">D* d;</span><b=
r></pre><pre class=3D"" style=3D"margin-bottom: 10px; padding: 5px; backgro=
und-color: rgb(238, 238, 238); overflow: auto; width: auto; max-height: 600=
px; word-wrap: normal;"><code><span class=3D"" style=3D"background-color: t=
ransparent;"><font color=3D"#000000" face=3D"Consolas, Menlo, Monaco, Lucid=
a Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Cou=
rier New, monospace, serif"><span style=3D"font-size: 14px; line-height: 18=
px;">A* a =3D static_cast&lt;A*&gt;(d); // </span></font></span></code><fon=
t color=3D"#000000" face=3D"Consolas, Menlo, Monaco, Lucida Console, Libera=
tion Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospa=
ce, serif"><span style=3D"font-size: 14px; line-height: 18px;">error: =E2=
=80=98A=E2=80=99 is an ambiguous base of =E2=80=98D=E2=80=99</span></font><=
/pre></div><div><br></div><div>Virtual inheritance allow to avoid Diamon of=
 Death situation. In case if base class is like "interface" (see above), th=
en virtual inheritance have no side effects: we do not need to make pointer=
 calculations for data members, because there is no any of them. But, virtu=
al inheritance forbid use of static_cast:</div><div><br></div><div><pre cla=
ss=3D"" style=3D"margin-bottom: 10px; padding: 5px; font-size: 14px; backgr=
ound-color: rgb(238, 238, 238); font-family: Consolas, Menlo, Monaco, 'Luci=
da Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mo=
no', 'Courier New', monospace, serif; overflow: auto; width: auto; max-heig=
ht: 600px; word-wrap: normal; color: rgb(0, 0, 0); line-height: 18px;"><cod=
e style=3D"font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberat=
ion Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', m=
onospace, serif; white-space: inherit;"><span class=3D"" style=3D"backgroun=
d-color: transparent; color: rgb(0, 0, 139);">class</span><span class=3D"" =
style=3D"background-color: transparent;"> A </span><span class=3D"" style=
=3D"background-color: transparent;">{};</span><span class=3D"" style=3D"bac=
kground-color: transparent;">

</span><span class=3D"" style=3D"background-color: transparent; color: rgb(=
0, 0, 139);">class</span><span class=3D"" style=3D"background-color: transp=
arent;"> B </span><span class=3D"" style=3D"background-color: transparent;"=
>:</span><span class=3D"" style=3D"background-color: transparent;"> </span>=
<span class=3D"" style=3D"background-color: transparent; color: rgb(0, 0, 1=
39);">virtual</span><span class=3D"" style=3D"background-color: transparent=
;"> </span><span class=3D"" style=3D"background-color: transparent; color: =
rgb(0, 0, 139);">public</span><span class=3D"" style=3D"background-color: t=
ransparent;"> A </span><span class=3D"" style=3D"background-color: transpar=
ent;">{};</span><span class=3D"" style=3D"background-color: transparent;">
</span><span class=3D"" style=3D"background-color: transparent; color: rgb(=
0, 0, 139);">class</span><span class=3D"" style=3D"background-color: transp=
arent;"> C </span><span class=3D"" style=3D"background-color: transparent;"=
>:</span><span class=3D"" style=3D"background-color: transparent;"> </span>=
<span class=3D"" style=3D"background-color: transparent; color: rgb(0, 0, 1=
39);">virtual</span><span class=3D"" style=3D"background-color: transparent=
;"> </span><span class=3D"" style=3D"background-color: transparent; color: =
rgb(0, 0, 139);">public</span><span class=3D"" style=3D"background-color: t=
ransparent;"> A </span><span class=3D"" style=3D"background-color: transpar=
ent;">{};</span><span class=3D"" style=3D"background-color: transparent;">

</span><span class=3D"" style=3D"background-color: transparent; color: rgb(=
0, 0, 139);">class</span><span class=3D"" style=3D"background-color: transp=
arent;"> D</span><span class=3D"" style=3D"background-color: transparent;">=
:</span><span class=3D"" style=3D"background-color: transparent;"> </span><=
span class=3D"" style=3D"background-color: transparent; color: rgb(0, 0, 13=
9);">public</span><span class=3D"" style=3D"background-color: transparent;"=
> B</span><span class=3D"" style=3D"background-color: transparent;">,</span=
><span class=3D"" style=3D"background-color: transparent;"> </span><span cl=
ass=3D"" style=3D"background-color: transparent; color: rgb(0, 0, 139);">pu=
blic</span><span class=3D"" style=3D"background-color: transparent;"> C </s=
pan><span class=3D"" style=3D"background-color: transparent;">{};</span></c=
ode></pre><pre class=3D"" style=3D"margin-bottom: 10px; padding: 5px; font-=
size: 14px; background-color: rgb(238, 238, 238); font-family: Consolas, Me=
nlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bits=
tream Vera Sans Mono', 'Courier New', monospace, serif; overflow: auto; wid=
th: auto; max-height: 600px; word-wrap: normal; color: rgb(0, 0, 0); line-h=
eight: 18px;"><span style=3D"font-family: Arial, 'Liberation Sans', 'DejaVu=
 Sans', sans-serif;">A* a;</span></pre><pre class=3D"" style=3D"margin-bott=
om: 10px; padding: 5px; font-size: 14px; background-color: rgb(238, 238, 23=
8); font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mon=
o', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospac=
e, serif; overflow: auto; width: auto; max-height: 600px; word-wrap: normal=
; color: rgb(0, 0, 0); line-height: 18px;"><span style=3D"font-family: Aria=
l, 'Liberation Sans', 'DejaVu Sans', sans-serif;">D* d =3D static_cast&lt;D=
*&gt;(a); //&nbsp;error: cannot convert from base =E2=80=98A=E2=80=99 to de=
rived type =E2=80=98D=E2=80=99 via virtual base =E2=80=98A=E2=80=99</span><=
/pre><p style=3D"font-size: small; line-height: normal; font-family: arial;=
 clear: both;"><span style=3D"color: rgb(0, 0, 0); font-family: Arial, 'Lib=
eration Sans', 'DejaVu Sans', sans-serif; font-size: 13px; line-height: 18p=
x;">That's why, now we can't imitate interfaces from C# with existing tools=
.. Introducing interfaces will allow use diamond inheritance for them withou=
t any troubles.</span><br></p></div><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&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_1046_1336521471.1407655489643--

.


Author: Brian Bi <bbi5291@gmail.com>
Date: Sun, 10 Aug 2014 03:27:42 -0400
Raw View
--001a11c363ecbfe93e0500415fe7
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

And where would this pointer obtained by static_cast point?
On Aug 10, 2014 3:24 AM, <pfight77@gmail.com> wrote:

> Hello,
>
> I suggest to introduce "interface" concept, like in C#. Interface will be
> like a class with only pure virtual functions, and without any data
> members. Inheritance of interface will be always virtual. Casting from
> interface type will be allowed via static_cast.
>
> Motivation
>
> Diamon of Death situation:
>
> class A {};
> class B : virtual public A {};class C : virtual public A {};
> class D: public B, public C {};
>
> D* d;
>
> A* a =3D static_cast<A*>(d); // error: =E2=80=98A=E2=80=99 is an ambiguou=
s base of =E2=80=98D=E2=80=99
>
>
> Virtual inheritance allow to avoid Diamon of Death situation. In case if
> base class is like "interface" (see above), then virtual inheritance have
> no side effects: we do not need to make pointer calculations for data
> members, because there is no any of them. But, virtual inheritance forbid
> use of static_cast:
>
> class A {};
> class B : virtual public A {};class C : virtual public A {};
> class D: public B, public C {};
>
> A* a;
>
> D* d =3D static_cast<D*>(a); // error: cannot convert from base =E2=80=98=
A=E2=80=99 to derived type =E2=80=98D=E2=80=99 via virtual base =E2=80=98A=
=E2=80=99
>
> That's why, now we can't imitate interfaces from C# with existing tools.
> Introducing interfaces will allow use diamond inheritance for them withou=
t
> any troubles.
>
>  --
>
> ---
> 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/.
>

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

--001a11c363ecbfe93e0500415fe7
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<p dir=3D"ltr">And where would this pointer obtained by static_cast point?<=
/p>
<div class=3D"gmail_quote">On Aug 10, 2014 3:24 AM,  &lt;<a href=3D"mailto:=
pfight77@gmail.com">pfight77@gmail.com</a>&gt; wrote:<br type=3D"attributio=
n"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Hello,<div><br></div><div>I suggest to introduce &quot;int=
erface&quot; concept, like in C#. Interface will be like a class with only =
pure virtual functions, and without any data members. Inheritance of interf=
ace will be always virtual. Casting from interface type will be allowed via=
 static_cast.</div>
<div><br></div><div>Motivation</div><div><br></div><div>Diamon of Death sit=
uation:<br></div><div><br></div><div><pre style=3D"margin-bottom:10px;paddi=
ng:5px;font-size:14px;background-color:rgb(238,238,238);font-family:Consola=
s,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;Deja=
Vu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,=
monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;=
color:rgb(0,0,0);line-height:18px">
<code style=3D"font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&=
#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera San=
s Mono&#39;,&#39;Courier New&#39;,monospace,serif;white-space:inherit"><spa=
n style=3D"background-color:transparent;color:rgb(0,0,139)">class</span><sp=
an style=3D"background-color:transparent"> A </span><span style=3D"backgrou=
nd-color:transparent">{};</span><span style=3D"background-color:transparent=
">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>
<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#3=
9;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera=
 Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;overflow:auto;width:a=
uto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:18px">
<span style=3D"background-color:transparent">D* d;</span><br></pre><pre sty=
le=3D"margin-bottom:10px;padding:5px;background-color:rgb(238,238,238);over=
flow:auto;width:auto;max-height:600px;word-wrap:normal"><code><span style=
=3D"background-color:transparent"><font color=3D"#000000" face=3D"Consolas,=
 Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstrea=
m Vera Sans Mono, Courier New, monospace, serif"><span style=3D"font-size:1=
4px;line-height:18px">A* a =3D static_cast&lt;A*&gt;(d); // </span></font><=
/span></code><font color=3D"#000000" face=3D"Consolas, Menlo, Monaco, Lucid=
a Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Cou=
rier New, monospace, serif"><span style=3D"font-size:14px;line-height:18px"=
>error: =E2=80=98A=E2=80=99 is an ambiguous base of =E2=80=98D=E2=80=99</sp=
an></font></pre>
</div><div><br></div><div>Virtual inheritance allow to avoid Diamon of Deat=
h situation. In case if base class is like &quot;interface&quot; (see above=
), then virtual inheritance have no side effects: we do not need to make po=
inter calculations for data members, because there is no any of them. But, =
virtual inheritance forbid use of static_cast:</div>
<div><br></div><div><pre style=3D"margin-bottom:10px;padding:5px;font-size:=
14px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#=
39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;=
,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;o=
verflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);=
line-height:18px">
<code style=3D"font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&=
#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera San=
s Mono&#39;,&#39;Courier New&#39;,monospace,serif;white-space:inherit"><spa=
n style=3D"background-color:transparent;color:rgb(0,0,139)">class</span><sp=
an style=3D"background-color:transparent"> A </span><span style=3D"backgrou=
nd-color:transparent">{};</span><span style=3D"background-color:transparent=
">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>
<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#3=
9;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera=
 Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;overflow:auto;width:a=
uto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:18px">
<span style=3D"font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans=
&#39;,sans-serif">A* a;</span></pre><pre style=3D"margin-bottom:10px;paddin=
g:5px;font-size:14px;background-color:rgb(238,238,238);font-family:Consolas=
,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaV=
u Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,m=
onospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;c=
olor:rgb(0,0,0);line-height:18px">
<span style=3D"font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans=
&#39;,sans-serif">D* d =3D static_cast&lt;D*&gt;(a); //=C2=A0error: cannot =
convert from base =E2=80=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 v=
ia virtual base =E2=80=98A=E2=80=99</span></pre><p style=3D"font-size:small=
;line-height:normal;font-family:arial;clear:both">
<span style=3D"color:rgb(0,0,0);font-family:Arial,&#39;Liberation Sans&#39;=
,&#39;DejaVu Sans&#39;,sans-serif;font-size:13px;line-height:18px">That&#39=
;s why, now we can&#39;t imitate interfaces from C# with existing tools. In=
troducing interfaces will allow use diamond inheritance for them without an=
y troubles.</span><br>
</p></div><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&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" 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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</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 />

--001a11c363ecbfe93e0500415fe7--

.


Author: pfight77@gmail.com
Date: Sun, 10 Aug 2014 00:32:17 -0700 (PDT)
Raw View
------=_Part_1033_1181195105.1407655937881
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

static_cast can return pointer without any modifications, like=20
reinterpret_cast (or almost like it). Interface has no data members and do=
=20
not need any pointer calculations to access them.

=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =D0=
=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 11:27:45 UTC+4 =D0=BF=
=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian Bi=
=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> And where would this pointer obtained by static_cast point?
> On Aug 10, 2014 3:24 AM, <pfig...@gmail.com <javascript:>> wrote:
>
>> Hello,
>>
>> I suggest to introduce "interface" concept, like in C#. Interface will b=
e=20
>> like a class with only pure virtual functions, and without any data=20
>> members. Inheritance of interface will be always virtual. Casting from=
=20
>> interface type will be allowed via static_cast.
>>
>> Motivation
>>
>> Diamon of Death situation:
>>
>> class A {};
>> class B : virtual public A {};class C : virtual public A {};
>> class D: public B, public C {};
>>
>> D* d;
>>
>> A* a =3D static_cast<A*>(d); // error: =E2=80=98A=E2=80=99 is an ambiguo=
us base of =E2=80=98D=E2=80=99
>>
>>
>> Virtual inheritance allow to avoid Diamon of Death situation. In case if=
=20
>> base class is like "interface" (see above), then virtual inheritance hav=
e=20
>> no side effects: we do not need to make pointer calculations for data=20
>> members, because there is no any of them. But, virtual inheritance forbi=
d=20
>> use of static_cast:
>>
>> class A {};
>> class B : virtual public A {};class C : virtual public A {};
>> class D: public B, public C {};
>>
>> A* a;
>>
>> D* d =3D static_cast<D*>(a); // error: cannot convert from base =E2=80=
=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 via virtual base =E2=80=
=98A=E2=80=99
>>
>> That's why, now we can't imitate interfaces from C# with existing tools.=
=20
>> Introducing interfaces will allow use diamond inheritance for them witho=
ut=20
>> any troubles.
>>
>>  --=20
>>
>> ---=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=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_1033_1181195105.1407655937881
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">static_cast can return pointer without any modifications, =
like reinterpret_cast (or almost like it). Interface has no data members an=
d do not need any pointer calculations to access them.<br><br>=D0=B2=D0=BE=
=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =D0=B0=D0=B2=D0=
=B3=D1=83=D1=81=D1=82=D0=B0 2014&nbsp;=D0=B3., 11:27:45 UTC+4 =D0=BF=D0=BE=
=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian Bi =D0=
=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gmail_quote" s=
tyle=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-le=
ft: 1ex;"><p dir=3D"ltr">And where would this pointer obtained by static_ca=
st point?</p>
<div class=3D"gmail_quote">On Aug 10, 2014 3:24 AM,  &lt;<a href=3D"javascr=
ipt:" target=3D"_blank" gdf-obfuscated-mailto=3D"DGLjckycfvUJ" onmousedown=
=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascr=
ipt:';return true;">pfig...@gmail.com</a>&gt; wrote:<br type=3D"attribution=
"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:=
1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Hello,<div><br></div><div>I suggest to introduce "interfac=
e" concept, like in C#. Interface will be like a class with only pure virtu=
al functions, and without any data members. Inheritance of interface will b=
e always virtual. Casting from interface type will be allowed via static_ca=
st.</div>
<div><br></div><div>Motivation</div><div><br></div><div>Diamon of Death sit=
uation:<br></div><div><br></div><div><pre style=3D"margin-bottom:10px;paddi=
ng:5px;font-size:14px;background-color:rgb(238,238,238);font-family:Consola=
s,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitst=
ream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto=
;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:18px"><code=
 style=3D"font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mo=
no','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,s=
erif;white-space:inherit"><span style=3D"background-color:transparent;color=
:rgb(0,0,139)">class</span><span style=3D"background-color:transparent"> A =
</span><span style=3D"background-color:transparent">{};</span><span style=
=3D"background-color:transparent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>
<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Libe=
ration Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',mo=
nospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;co=
lor:rgb(0,0,0);line-height:18px"><span style=3D"background-color:transparen=
t">D* d;</span><br></pre><pre style=3D"margin-bottom:10px;padding:5px;backg=
round-color:rgb(238,238,238);overflow:auto;width:auto;max-height:600px;word=
-wrap:normal"><code><span style=3D"background-color:transparent"><font colo=
r=3D"#000000" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liberation M=
ono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, se=
rif"><span style=3D"font-size:14px;line-height:18px">A* a =3D static_cast&l=
t;A*&gt;(d); // </span></font></span></code><font color=3D"#000000" face=3D=
"Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono=
, Bitstream Vera Sans Mono, Courier New, monospace, serif"><span style=3D"f=
ont-size:14px;line-height:18px">error: =E2=80=98A=E2=80=99 is an ambiguous =
base of =E2=80=98D=E2=80=99</span></font></pre>
</div><div><br></div><div>Virtual inheritance allow to avoid Diamon of Deat=
h situation. In case if base class is like "interface" (see above), then vi=
rtual inheritance have no side effects: we do not need to make pointer calc=
ulations for data members, because there is no any of them. But, virtual in=
heritance forbid use of static_cast:</div>
<div><br></div><div><pre style=3D"margin-bottom:10px;padding:5px;font-size:=
14px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'L=
ucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mo=
no','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px=
;word-wrap:normal;color:rgb(0,0,0);line-height:18px"><code style=3D"font-fa=
mily:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans =
Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:=
inherit"><span style=3D"background-color:transparent;color:rgb(0,0,139)">cl=
ass</span><span style=3D"background-color:transparent"> A </span><span styl=
e=3D"background-color:transparent">{};</span><span style=3D"background-colo=
r:transparent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>
<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Libe=
ration Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',mo=
nospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;co=
lor:rgb(0,0,0);line-height:18px"><span style=3D"font-family:Arial,'Liberati=
on Sans','DejaVu Sans',sans-serif">A* a;</span></pre><pre style=3D"margin-b=
ottom:10px;padding:5px;font-size:14px;background-color:rgb(238,238,238);fon=
t-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu S=
ans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow=
:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-he=
ight:18px"><span style=3D"font-family:Arial,'Liberation Sans','DejaVu Sans'=
,sans-serif">D* d =3D static_cast&lt;D*&gt;(a); //&nbsp;error: cannot conve=
rt from base =E2=80=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 via vi=
rtual base =E2=80=98A=E2=80=99</span></pre><p style=3D"font-size:small;line=
-height:normal;font-family:arial;clear:both">
<span style=3D"color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu=
 Sans',sans-serif;font-size:13px;line-height:18px">That's why, now we can't=
 imitate interfaces from C# with existing tools. Introducing interfaces wil=
l allow use diamond inheritance for them without any troubles.</span><br>
</p></div><div><br></div></div>

<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 e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
DGLjckycfvUJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">std-proposal...@<wbr>isocpp.or=
g</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"DGLjckycfvUJ" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;">s=
td-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" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</blockquote></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_1033_1181195105.1407655937881--

.


Author: pfight77@gmail.com
Date: Sun, 10 Aug 2014 00:48:37 -0700 (PDT)
Raw View
------=_Part_986_544052898.1407656917601
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

There is problem, where place vtable for interface. I think, there can be=
=20
solution like this: all interfaces will have one vtable in object. Shift to=
=20
this interfaces vtable can be placed as a record to all other vtables (of=
=20
all base classes).=20

=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =D0=
=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 11:27:45 UTC+4 =D0=BF=
=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian Bi=
=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> And where would this pointer obtained by static_cast point?
> On Aug 10, 2014 3:24 AM, <pfig...@gmail.com <javascript:>> wrote:
>
>> Hello,
>>
>> I suggest to introduce "interface" concept, like in C#. Interface will b=
e=20
>> like a class with only pure virtual functions, and without any data=20
>> members. Inheritance of interface will be always virtual. Casting from=
=20
>> interface type will be allowed via static_cast.
>>
>> Motivation
>>
>> Diamon of Death situation:
>>
>> class A {};
>> class B : virtual public A {};class C : virtual public A {};
>> class D: public B, public C {};
>>
>> D* d;
>>
>> A* a =3D static_cast<A*>(d); // error: =E2=80=98A=E2=80=99 is an ambiguo=
us base of =E2=80=98D=E2=80=99
>>
>>
>> Virtual inheritance allow to avoid Diamon of Death situation. In case if=
=20
>> base class is like "interface" (see above), then virtual inheritance hav=
e=20
>> no side effects: we do not need to make pointer calculations for data=20
>> members, because there is no any of them. But, virtual inheritance forbi=
d=20
>> use of static_cast:
>>
>> class A {};
>> class B : virtual public A {};class C : virtual public A {};
>> class D: public B, public C {};
>>
>> A* a;
>>
>> D* d =3D static_cast<D*>(a); // error: cannot convert from base =E2=80=
=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 via virtual base =E2=80=
=98A=E2=80=99
>>
>> That's why, now we can't imitate interfaces from C# with existing tools.=
=20
>> Introducing interfaces will allow use diamond inheritance for them witho=
ut=20
>> any troubles.
>>
>>  --=20
>>
>> ---=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=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_986_544052898.1407656917601
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">There is problem, where place vtable for interface. I thin=
k, there can be solution like this: all interfaces will have one vtable in =
object. Shift to this interfaces vtable can be placed as a record to all ot=
her vtables (of all base classes).&nbsp;<br><br>=D0=B2=D0=BE=D1=81=D0=BA=D1=
=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =D0=B0=D0=B2=D0=B3=D1=83=D1=81=
=D1=82=D0=B0 2014&nbsp;=D0=B3., 11:27:45 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=
=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian Bi =D0=BD=D0=B0=D0=BF=
=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gmail_quote" style=3D"margin:=
 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><p di=
r=3D"ltr">And where would this pointer obtained by static_cast point?</p>
<div class=3D"gmail_quote">On Aug 10, 2014 3:24 AM,  &lt;<a href=3D"javascr=
ipt:" target=3D"_blank" gdf-obfuscated-mailto=3D"DGLjckycfvUJ" onmousedown=
=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascr=
ipt:';return true;">pfig...@gmail.com</a>&gt; wrote:<br type=3D"attribution=
"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:=
1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Hello,<div><br></div><div>I suggest to introduce "interfac=
e" concept, like in C#. Interface will be like a class with only pure virtu=
al functions, and without any data members. Inheritance of interface will b=
e always virtual. Casting from interface type will be allowed via static_ca=
st.</div>
<div><br></div><div>Motivation</div><div><br></div><div>Diamon of Death sit=
uation:<br></div><div><br></div><div><pre style=3D"margin-bottom:10px;paddi=
ng:5px;font-size:14px;background-color:rgb(238,238,238);font-family:Consola=
s,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitst=
ream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto=
;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:18px"><code=
 style=3D"font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mo=
no','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,s=
erif;white-space:inherit"><span style=3D"background-color:transparent;color=
:rgb(0,0,139)">class</span><span style=3D"background-color:transparent"> A =
</span><span style=3D"background-color:transparent">{};</span><span style=
=3D"background-color:transparent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>
<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Libe=
ration Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',mo=
nospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;co=
lor:rgb(0,0,0);line-height:18px"><span style=3D"background-color:transparen=
t">D* d;</span><br></pre><pre style=3D"margin-bottom:10px;padding:5px;backg=
round-color:rgb(238,238,238);overflow:auto;width:auto;max-height:600px;word=
-wrap:normal"><code><span style=3D"background-color:transparent"><font colo=
r=3D"#000000" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liberation M=
ono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, se=
rif"><span style=3D"font-size:14px;line-height:18px">A* a =3D static_cast&l=
t;A*&gt;(d); // </span></font></span></code><font color=3D"#000000" face=3D=
"Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono=
, Bitstream Vera Sans Mono, Courier New, monospace, serif"><span style=3D"f=
ont-size:14px;line-height:18px">error: =E2=80=98A=E2=80=99 is an ambiguous =
base of =E2=80=98D=E2=80=99</span></font></pre>
</div><div><br></div><div>Virtual inheritance allow to avoid Diamon of Deat=
h situation. In case if base class is like "interface" (see above), then vi=
rtual inheritance have no side effects: we do not need to make pointer calc=
ulations for data members, because there is no any of them. But, virtual in=
heritance forbid use of static_cast:</div>
<div><br></div><div><pre style=3D"margin-bottom:10px;padding:5px;font-size:=
14px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'L=
ucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mo=
no','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px=
;word-wrap:normal;color:rgb(0,0,0);line-height:18px"><code style=3D"font-fa=
mily:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans =
Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:=
inherit"><span style=3D"background-color:transparent;color:rgb(0,0,139)">cl=
ass</span><span style=3D"background-color:transparent"> A </span><span styl=
e=3D"background-color:transparent">{};</span><span style=3D"background-colo=
r:transparent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>
<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Libe=
ration Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',mo=
nospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;co=
lor:rgb(0,0,0);line-height:18px"><span style=3D"font-family:Arial,'Liberati=
on Sans','DejaVu Sans',sans-serif">A* a;</span></pre><pre style=3D"margin-b=
ottom:10px;padding:5px;font-size:14px;background-color:rgb(238,238,238);fon=
t-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu S=
ans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow=
:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-he=
ight:18px"><span style=3D"font-family:Arial,'Liberation Sans','DejaVu Sans'=
,sans-serif">D* d =3D static_cast&lt;D*&gt;(a); //&nbsp;error: cannot conve=
rt from base =E2=80=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 via vi=
rtual base =E2=80=98A=E2=80=99</span></pre><p style=3D"font-size:small;line=
-height:normal;font-family:arial;clear:both">
<span style=3D"color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu=
 Sans',sans-serif;font-size:13px;line-height:18px">That's why, now we can't=
 imitate interfaces from C# with existing tools. Introducing interfaces wil=
l allow use diamond inheritance for them without any troubles.</span><br>
</p></div><div><br></div></div>

<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 e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
DGLjckycfvUJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">std-proposal...@<wbr>isocpp.or=
g</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"DGLjckycfvUJ" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;">s=
td-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" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</blockquote></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_986_544052898.1407656917601--

.


Author: Brian Bi <bbi5291@gmail.com>
Date: Sun, 10 Aug 2014 04:12:05 -0400
Raw View
--001a11c3640e7b85c3050041fe96
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Wait, hang on a sec here. You *can* use static_cast for a conversion to a
virtual base; in fact such a conversion can even be done implicitly. Your
first example appears to suggest otherwise.
There is problem, where place vtable for interface. I think, there can be
solution like this: all interfaces will have one vtable in object. Shift to
this interfaces vtable can be placed as a record to all other vtables (of
all base classes).

=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =D0=
=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 11:27:45 UTC+4 =D0=BF=
=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian Bi
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> And where would this pointer obtained by static_cast point?
> On Aug 10, 2014 3:24 AM, <pfig...@gmail.com> wrote:
>
>> Hello,
>>
>> I suggest to introduce "interface" concept, like in C#. Interface will b=
e
>> like a class with only pure virtual functions, and without any data
>> members. Inheritance of interface will be always virtual. Casting from
>> interface type will be allowed via static_cast.
>>
>> Motivation
>>
>> Diamon of Death situation:
>>
>> class A {};
>> class B : virtual public A {};class C : virtual public A {};
>> class D: public B, public C {};
>>
>> D* d;
>>
>> A* a =3D static_cast<A*>(d); // error: =E2=80=98A=E2=80=99 is an ambiguo=
us base of =E2=80=98D=E2=80=99
>>
>>
>> Virtual inheritance allow to avoid Diamon of Death situation. In case if
>> base class is like "interface" (see above), then virtual inheritance hav=
e
>> no side effects: we do not need to make pointer calculations for data
>> members, because there is no any of them. But, virtual inheritance forbi=
d
>> use of static_cast:
>>
>> class A {};
>> class B : virtual public A {};class C : virtual public A {};
>> class D: public B, public C {};
>>
>> A* a;
>>
>> D* d =3D static_cast<D*>(a); // error: cannot convert from base =E2=80=
=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 via virtual base =E2=80=
=98A=E2=80=99
>>
>> That's why, now we can't imitate interfaces from C# with existing tools.
>> Introducing interfaces will allow use diamond inheritance for them witho=
ut
>> any troubles.
>>
>>  --
>>
>> ---
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> email to std-proposal...@isocpp.org.
>> To post to this group, send email to std-pr...@isocpp.org.
>> Visit this group at http://groups.google.com/a/isocpp.org/group/std-
>> proposals/.
>>
>  --

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

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

--001a11c3640e7b85c3050041fe96
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<p dir=3D"ltr">Wait, hang on a sec here. You *can* use static_cast for a co=
nversion to a virtual base; in fact such a conversion can even be done impl=
icitly. Your first example appears to suggest otherwise.</p>
<div class=3D"gmail_quot&lt;blockquote class=3D" style=3D"margin:0 0 0 .8ex=
;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">There is pro=
blem, where place vtable for interface. I think, there can be solution like=
 this: all interfaces will have one vtable in object. Shift to this interfa=
ces vtable can be placed as a record to all other vtables (of all base clas=
ses).=C2=A0<br>
<br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014=C2=A0=D0=B3., 11:27:45 UTC+=
4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C =
Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><p dir=3D"ltr">And where would this pointer obtained by st=
atic_cast point?</p>

<div class=3D"gmail_quote">On Aug 10, 2014 3:24 AM,  &lt;<a>pfig...@gmail.c=
om</a>&gt; wrote:<br type=3D"attribution"><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Hello,<div><br></div><div>I suggest to introduce &quot;int=
erface&quot; concept, like in C#. Interface will be like a class with only =
pure virtual functions, and without any data members. Inheritance of interf=
ace will be always virtual. Casting from interface type will be allowed via=
 static_cast.</div>

<div><br></div><div>Motivation</div><div><br></div><div>Diamon of Death sit=
uation:<br></div><div><br></div><div><pre style=3D"margin-bottom:10px;paddi=
ng:5px;font-size:14px;background-color:rgb(238,238,238);font-family:Consola=
s,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;Deja=
Vu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,=
monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;=
color:rgb(0,0,0);line-height:18px">
<code style=3D"font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&=
#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera San=
s Mono&#39;,&#39;Courier New&#39;,monospace,serif;white-space:inherit"><spa=
n style=3D"background-color:transparent;color:rgb(0,0,139)">class</span><sp=
an style=3D"background-color:transparent"> A </span><span style=3D"backgrou=
nd-color:transparent">{};</span><span style=3D"background-color:transparent=
">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>

<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#3=
9;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera=
 Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;overflow:auto;width:a=
uto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:18px">
<span style=3D"background-color:transparent">D* d;</span><br></pre><pre sty=
le=3D"margin-bottom:10px;padding:5px;background-color:rgb(238,238,238);over=
flow:auto;width:auto;max-height:600px;word-wrap:normal"><code><span style=
=3D"background-color:transparent"><font color=3D"#000000" face=3D"Consolas,=
 Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstrea=
m Vera Sans Mono, Courier New, monospace, serif"><span style=3D"font-size:1=
4px;line-height:18px">A* a =3D static_cast&lt;A*&gt;(d); // </span></font><=
/span></code><font color=3D"#000000" face=3D"Consolas, Menlo, Monaco, Lucid=
a Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Cou=
rier New, monospace, serif"><span style=3D"font-size:14px;line-height:18px"=
>error: =E2=80=98A=E2=80=99 is an ambiguous base of =E2=80=98D=E2=80=99</sp=
an></font></pre>

</div><div><br></div><div>Virtual inheritance allow to avoid Diamon of Deat=
h situation. In case if base class is like &quot;interface&quot; (see above=
), then virtual inheritance have no side effects: we do not need to make po=
inter calculations for data members, because there is no any of them. But, =
virtual inheritance forbid use of static_cast:</div>

<div><br></div><div><pre style=3D"margin-bottom:10px;padding:5px;font-size:=
14px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#=
39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;=
,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;o=
verflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);=
line-height:18px">
<code style=3D"font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&=
#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera San=
s Mono&#39;,&#39;Courier New&#39;,monospace,serif;white-space:inherit"><spa=
n style=3D"background-color:transparent;color:rgb(0,0,139)">class</span><sp=
an style=3D"background-color:transparent"> A </span><span style=3D"backgrou=
nd-color:transparent">{};</span><span style=3D"background-color:transparent=
">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>

<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#3=
9;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera=
 Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;overflow:auto;width:a=
uto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:18px">
<span style=3D"font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans=
&#39;,sans-serif">A* a;</span></pre><pre style=3D"margin-bottom:10px;paddin=
g:5px;font-size:14px;background-color:rgb(238,238,238);font-family:Consolas=
,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaV=
u Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,m=
onospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;c=
olor:rgb(0,0,0);line-height:18px">
<span style=3D"font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans=
&#39;,sans-serif">D* d =3D static_cast&lt;D*&gt;(a); //=C2=A0error: cannot =
convert from base =E2=80=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 v=
ia virtual base =E2=80=98A=E2=80=99</span></pre><p style=3D"font-size:small=
;line-height:normal;font-family:arial;clear:both">

<span style=3D"color:rgb(0,0,0);font-family:Arial,&#39;Liberation Sans&#39;=
,&#39;DejaVu Sans&#39;,sans-serif;font-size:13px;line-height:18px">That&#39=
;s why, now we can&#39;t imitate interfaces from C# with existing tools. In=
troducing interfaces will allow use diamond inheritance for them without an=
y troubles.</span><br>

</p></div><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&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>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">http://groups.google.com/a/<u></u>isocpp.=
org/group/std-<u></u>proposals/</a>.<br>
</blockquote></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" 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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<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&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 />

--001a11c3640e7b85c3050041fe96--

.


Author: pfight77@gmail.com
Date: Sun, 10 Aug 2014 01:26:32 -0700 (PDT)
Raw View
------=_Part_974_34002165.1407659192452
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Oh, sory, it is mistype. In first example should be simple inheritance, not=
=20
virtual.
And to subject of place for vtable. We can place shift to interfaces vtable=
=20
not to all other vtables, but to vtables of all top-most base classes in=20
inheritance tree (in case of multiply inheritance there is can be several=
=20
top-most base classes).=20

=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =D0=
=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 12:12:08 UTC+4 =D0=BF=
=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian Bi=
=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> Wait, hang on a sec here. You *can* use static_cast for a conversion to a=
=20
> virtual base; in fact such a conversion can even be done implicitly. Your=
=20
> first example appears to suggest otherwise.
> There is problem, where place vtable for interface. I think, there can be=
=20
> solution like this: all interfaces will have one vtable in object. Shift =
to=20
> this interfaces vtable can be placed as a record to all other vtables (of=
=20
> all base classes).=20
>
> =D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 11:27:45 UTC+4 =D0=
=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian=
 Bi=20
> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>
>> And where would this pointer obtained by static_cast point?
>> On Aug 10, 2014 3:24 AM, <pfig...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I suggest to introduce "interface" concept, like in C#. Interface will=
=20
>>> be like a class with only pure virtual functions, and without any data=
=20
>>> members. Inheritance of interface will be always virtual. Casting from=
=20
>>> interface type will be allowed via static_cast.
>>>
>>> Motivation
>>>
>>> Diamon of Death situation:
>>>
>>> class A {};
>>> class B : virtual public A {};class C : virtual public A {};
>>> class D: public B, public C {};
>>>
>>> D* d;
>>>
>>> A* a =3D static_cast<A*>(d); // error: =E2=80=98A=E2=80=99 is an ambigu=
ous base of =E2=80=98D=E2=80=99
>>>
>>>
>>> Virtual inheritance allow to avoid Diamon of Death situation. In case i=
f=20
>>> base class is like "interface" (see above), then virtual inheritance ha=
ve=20
>>> no side effects: we do not need to make pointer calculations for data=
=20
>>> members, because there is no any of them. But, virtual inheritance forb=
id=20
>>> use of static_cast:
>>>
>>> class A {};
>>> class B : virtual public A {};class C : virtual public A {};
>>> class D: public B, public C {};
>>>
>>> A* a;
>>>
>>> D* d =3D static_cast<D*>(a); // error: cannot convert from base =E2=80=
=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 via virtual base =E2=80=
=98A=E2=80=99
>>>
>>> That's why, now we can't imitate interfaces from C# with existing tools=
..=20
>>> Introducing interfaces will allow use diamond inheritance for them with=
out=20
>>> any troubles.
>>>
>>>  --=20
>>>
>>> ---=20
>>> You received this message because you are subscribed to the Google=20
>>> Groups "ISO C++ Standard - Future Proposals" group.
>>> To unsubscribe from this group and stop receiving emails from it, send=
=20
>>> an email to std-proposal...@isocpp.org.
>>> To post to this group, send email to std-pr...@isocpp.org.
>>> Visit this group at http://groups.google.com/a/isocpp.org/group/std-
>>> proposals/.
>>>
>>  --=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

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

<div dir=3D"ltr">Oh, sory, it is mistype. In first example should be simple=
 inheritance, not virtual.<br>And to subject of place for vtable. We can pl=
ace shift to interfaces vtable not to all other vtables, but to vtables of =
all top-most base classes in inheritance tree (in case of multiply inherita=
nce there is can be several top-most base classes).&nbsp;<br><br>=D0=B2=D0=
=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =D0=B0=D0=B2=
=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014&nbsp;=D0=B3., 12:12:08 UTC+4 =D0=BF=D0=
=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian Bi =
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gmail_quote=
" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding=
-left: 1ex;"><p dir=3D"ltr">Wait, hang on a sec here. You *can* use static_=
cast for a conversion to a virtual base; in fact such a conversion can even=
 be done implicitly. Your first example appears to suggest otherwise.</p>
<div style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex=
"><div dir=3D"ltr">There is problem, where place vtable for interface. I th=
ink, there can be solution like this: all interfaces will have one vtable i=
n object. Shift to this interfaces vtable can be placed as a record to all =
other vtables (of all base classes).&nbsp;<br>
<br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014&nbsp;=D0=B3., 11:27:45 UTC+=
4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C =
Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><p dir=3D"ltr">And where would this pointer obtained by st=
atic_cast point?</p>

<div class=3D"gmail_quote">On Aug 10, 2014 3:24 AM,  &lt;<a>pfig...@gmail.c=
om</a>&gt; wrote:<br type=3D"attribution"><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Hello,<div><br></div><div>I suggest to introduce "interfac=
e" concept, like in C#. Interface will be like a class with only pure virtu=
al functions, and without any data members. Inheritance of interface will b=
e always virtual. Casting from interface type will be allowed via static_ca=
st.</div>

<div><br></div><div>Motivation</div><div><br></div><div>Diamon of Death sit=
uation:<br></div><div><br></div><div><pre style=3D"margin-bottom:10px;paddi=
ng:5px;font-size:14px;background-color:rgb(238,238,238);font-family:Consola=
s,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitst=
ream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto=
;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:18px"><code=
 style=3D"font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mo=
no','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,s=
erif;white-space:inherit"><span style=3D"background-color:transparent;color=
:rgb(0,0,139)">class</span><span style=3D"background-color:transparent"> A =
</span><span style=3D"background-color:transparent">{};</span><span style=
=3D"background-color:transparent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>

<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Libe=
ration Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',mo=
nospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;co=
lor:rgb(0,0,0);line-height:18px"><span style=3D"background-color:transparen=
t">D* d;</span><br></pre><pre style=3D"margin-bottom:10px;padding:5px;backg=
round-color:rgb(238,238,238);overflow:auto;width:auto;max-height:600px;word=
-wrap:normal"><code><span style=3D"background-color:transparent"><font colo=
r=3D"#000000" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liberation M=
ono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, se=
rif"><span style=3D"font-size:14px;line-height:18px">A* a =3D static_cast&l=
t;A*&gt;(d); // </span></font></span></code><font color=3D"#000000" face=3D=
"Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono=
, Bitstream Vera Sans Mono, Courier New, monospace, serif"><span style=3D"f=
ont-size:14px;line-height:18px">error: =E2=80=98A=E2=80=99 is an ambiguous =
base of =E2=80=98D=E2=80=99</span></font></pre>

</div><div><br></div><div>Virtual inheritance allow to avoid Diamon of Deat=
h situation. In case if base class is like "interface" (see above), then vi=
rtual inheritance have no side effects: we do not need to make pointer calc=
ulations for data members, because there is no any of them. But, virtual in=
heritance forbid use of static_cast:</div>

<div><br></div><div><pre style=3D"margin-bottom:10px;padding:5px;font-size:=
14px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'L=
ucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mo=
no','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px=
;word-wrap:normal;color:rgb(0,0,0);line-height:18px"><code style=3D"font-fa=
mily:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans =
Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:=
inherit"><span style=3D"background-color:transparent;color:rgb(0,0,139)">cl=
ass</span><span style=3D"background-color:transparent"> A </span><span styl=
e=3D"background-color:transparent">{};</span><span style=3D"background-colo=
r:transparent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>

<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Libe=
ration Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',mo=
nospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;co=
lor:rgb(0,0,0);line-height:18px"><span style=3D"font-family:Arial,'Liberati=
on Sans','DejaVu Sans',sans-serif">A* a;</span></pre><pre style=3D"margin-b=
ottom:10px;padding:5px;font-size:14px;background-color:rgb(238,238,238);fon=
t-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu S=
ans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow=
:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-he=
ight:18px"><span style=3D"font-family:Arial,'Liberation Sans','DejaVu Sans'=
,sans-serif">D* d =3D static_cast&lt;D*&gt;(a); //&nbsp;error: cannot conve=
rt from base =E2=80=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 via vi=
rtual base =E2=80=98A=E2=80=99</span></pre><p style=3D"font-size:small;line=
-height:normal;font-family:arial;clear:both">

<span style=3D"color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu=
 Sans',sans-serif;font-size:13px;line-height:18px">That's why, now we can't=
 imitate interfaces from C# with existing tools. Introducing interfaces wil=
l allow use diamond inheritance for them without any troubles.</span><br>

</p></div><div><br></div></div>

<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 e=
mail to <a>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>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" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<u></u>iso<wbr>cpp.org/group/std-<u></u=
>proposals/</a>.<br>
</blockquote></div>
</blockquote></div>

<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 e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
qbu6I8rZKLAJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">std-proposal...@<wbr>isocpp.or=
g</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"qbu6I8rZKLAJ" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;">s=
td-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" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</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_974_34002165.1407659192452--

.


Author: Brian Bi <bbi5291@gmail.com>
Date: Sun, 10 Aug 2014 04:33:16 -0400
Raw View
--089e0116156a31a3de0500424aae
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Anyway, to be clear, then, you want the ability to static_cast from
interface to derived class? Can't you use dynamic_cast instead?

Or are you saying that this feature would make it easier to write code by
avoiding the need to write "virtual" in a bunch of places?
On Aug 10, 2014 4:26 AM, <pfight77@gmail.com> wrote:

> Oh, sory, it is mistype. In first example should be simple inheritance,
> not virtual.
> And to subject of place for vtable. We can place shift to interfaces
> vtable not to all other vtables, but to vtables of all top-most base
> classes in inheritance tree (in case of multiply inheritance there is can
> be several top-most base classes).
>
> =D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 12:12:08 UTC+4 =D0=
=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian=
 Bi
> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>
>> Wait, hang on a sec here. You *can* use static_cast for a conversion to =
a
>> virtual base; in fact such a conversion can even be done implicitly. You=
r
>> first example appears to suggest otherwise.
>> There is problem, where place vtable for interface. I think, there can b=
e
>> solution like this: all interfaces will have one vtable in object. Shift=
 to
>> this interfaces vtable can be placed as a record to all other vtables (o=
f
>> all base classes).
>>
>> =D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 11:27:45 UTC+4 =D0=
=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian=
 Bi
>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>
>>> And where would this pointer obtained by static_cast point?
>>> On Aug 10, 2014 3:24 AM, <pfig...@gmail.com> wrote:
>>>
>>>> Hello,
>>>>
>>>> I suggest to introduce "interface" concept, like in C#. Interface will
>>>> be like a class with only pure virtual functions, and without any data
>>>> members. Inheritance of interface will be always virtual. Casting from
>>>> interface type will be allowed via static_cast.
>>>>
>>>> Motivation
>>>>
>>>> Diamon of Death situation:
>>>>
>>>> class A {};
>>>> class B : virtual public A {};class C : virtual public A {};
>>>> class D: public B, public C {};
>>>>
>>>> D* d;
>>>>
>>>> A* a =3D static_cast<A*>(d); // error: =E2=80=98A=E2=80=99 is an ambig=
uous base of =E2=80=98D=E2=80=99
>>>>
>>>>
>>>> Virtual inheritance allow to avoid Diamon of Death situation. In case
>>>> if base class is like "interface" (see above), then virtual inheritanc=
e
>>>> have no side effects: we do not need to make pointer calculations for =
data
>>>> members, because there is no any of them. But, virtual inheritance for=
bid
>>>> use of static_cast:
>>>>
>>>> class A {};
>>>> class B : virtual public A {};class C : virtual public A {};
>>>> class D: public B, public C {};
>>>>
>>>> A* a;
>>>>
>>>> D* d =3D static_cast<D*>(a); // error: cannot convert from base =E2=80=
=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 via virtual base =E2=80=
=98A=E2=80=99
>>>>
>>>> That's why, now we can't imitate interfaces from C# with existing
>>>> tools. Introducing interfaces will allow use diamond inheritance for t=
hem
>>>> without any troubles.
>>>>
>>>>  --
>>>>
>>>> ---
>>>> 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-proposal...@isocpp.org.
>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>> Visit this group at http://groups.google.com/a/isocpp.org/group/std-
>>>> proposals/.
>>>>
>>>  --
>>
>> ---
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> email to std-proposal...@isocpp.org.
>> To post to this group, send email to std-pr...@isocpp.org.
>> Visit this group at http://groups.google.com/a/isocpp.org/group/std-
>> proposals/.
>>
>  --
>
> ---
> 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/.
>

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

--089e0116156a31a3de0500424aae
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<p dir=3D"ltr">Anyway, to be clear, then, you want the ability to static_ca=
st from interface to derived class? Can&#39;t you use dynamic_cast instead?=
</p>
<p dir=3D"ltr">Or are you saying that this feature would make it easier to =
write code by avoiding the need to write &quot;virtual&quot; in a bunch of =
places?</p>
<div class=3D"gmail_quote">On Aug 10, 2014 4:26 AM,  &lt;<a href=3D"mailto:=
pfight77@gmail.com">pfight77@gmail.com</a>&gt; wrote:<br type=3D"attributio=
n"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Oh, sory, it is mistype. In first example should be simple=
 inheritance, not virtual.<br>And to subject of place for vtable. We can pl=
ace shift to interfaces vtable not to all other vtables, but to vtables of =
all top-most base classes in inheritance tree (in case of multiply inherita=
nce there is can be several top-most base classes).=C2=A0<br>
<br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014=C2=A0=D0=B3., 12:12:08 UTC+=
4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C =
Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><p dir=3D"ltr">Wait, hang on a sec here. You *can* use sta=
tic_cast for a conversion to a virtual base; in fact such a conversion can =
even be done implicitly. Your first example appears to suggest otherwise.</=
p>

<div style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex=
"><div dir=3D"ltr">There is problem, where place vtable for interface. I th=
ink, there can be solution like this: all interfaces will have one vtable i=
n object. Shift to this interfaces vtable can be placed as a record to all =
other vtables (of all base classes).=C2=A0<br>

<br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014=C2=A0=D0=B3., 11:27:45 UTC+=
4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C =
Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><p dir=3D"ltr">And where would this pointer obtained by st=
atic_cast point?</p>


<div class=3D"gmail_quote">On Aug 10, 2014 3:24 AM,  &lt;<a>pfig...@gmail.c=
om</a>&gt; wrote:<br type=3D"attribution"><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Hello,<div><br></div><div>I suggest to introduce &quot;int=
erface&quot; concept, like in C#. Interface will be like a class with only =
pure virtual functions, and without any data members. Inheritance of interf=
ace will be always virtual. Casting from interface type will be allowed via=
 static_cast.</div>


<div><br></div><div>Motivation</div><div><br></div><div>Diamon of Death sit=
uation:<br></div><div><br></div><div><pre style=3D"margin-bottom:10px;paddi=
ng:5px;font-size:14px;background-color:rgb(238,238,238);font-family:Consola=
s,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;Deja=
Vu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,=
monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;=
color:rgb(0,0,0);line-height:18px">
<code style=3D"font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&=
#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera San=
s Mono&#39;,&#39;Courier New&#39;,monospace,serif;white-space:inherit"><spa=
n style=3D"background-color:transparent;color:rgb(0,0,139)">class</span><sp=
an style=3D"background-color:transparent"> A </span><span style=3D"backgrou=
nd-color:transparent">{};</span><span style=3D"background-color:transparent=
">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>


<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#3=
9;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera=
 Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;overflow:auto;width:a=
uto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:18px">
<span style=3D"background-color:transparent">D* d;</span><br></pre><pre sty=
le=3D"margin-bottom:10px;padding:5px;background-color:rgb(238,238,238);over=
flow:auto;width:auto;max-height:600px;word-wrap:normal"><code><span style=
=3D"background-color:transparent"><font color=3D"#000000" face=3D"Consolas,=
 Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstrea=
m Vera Sans Mono, Courier New, monospace, serif"><span style=3D"font-size:1=
4px;line-height:18px">A* a =3D static_cast&lt;A*&gt;(d); // </span></font><=
/span></code><font color=3D"#000000" face=3D"Consolas, Menlo, Monaco, Lucid=
a Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Cou=
rier New, monospace, serif"><span style=3D"font-size:14px;line-height:18px"=
>error: =E2=80=98A=E2=80=99 is an ambiguous base of =E2=80=98D=E2=80=99</sp=
an></font></pre>


</div><div><br></div><div>Virtual inheritance allow to avoid Diamon of Deat=
h situation. In case if base class is like &quot;interface&quot; (see above=
), then virtual inheritance have no side effects: we do not need to make po=
inter calculations for data members, because there is no any of them. But, =
virtual inheritance forbid use of static_cast:</div>


<div><br></div><div><pre style=3D"margin-bottom:10px;padding:5px;font-size:=
14px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#=
39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;=
,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;o=
verflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);=
line-height:18px">
<code style=3D"font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&=
#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera San=
s Mono&#39;,&#39;Courier New&#39;,monospace,serif;white-space:inherit"><spa=
n style=3D"background-color:transparent;color:rgb(0,0,139)">class</span><sp=
an style=3D"background-color:transparent"> A </span><span style=3D"backgrou=
nd-color:transparent">{};</span><span style=3D"background-color:transparent=
">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>


<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#3=
9;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera=
 Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;overflow:auto;width:a=
uto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:18px">
<span style=3D"font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans=
&#39;,sans-serif">A* a;</span></pre><pre style=3D"margin-bottom:10px;paddin=
g:5px;font-size:14px;background-color:rgb(238,238,238);font-family:Consolas=
,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaV=
u Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,m=
onospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;c=
olor:rgb(0,0,0);line-height:18px">
<span style=3D"font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans=
&#39;,sans-serif">D* d =3D static_cast&lt;D*&gt;(a); //=C2=A0error: cannot =
convert from base =E2=80=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 v=
ia virtual base =E2=80=98A=E2=80=99</span></pre><p style=3D"font-size:small=
;line-height:normal;font-family:arial;clear:both">


<span style=3D"color:rgb(0,0,0);font-family:Arial,&#39;Liberation Sans&#39;=
,&#39;DejaVu Sans&#39;,sans-serif;font-size:13px;line-height:18px">That&#39=
;s why, now we can&#39;t imitate interfaces from C# with existing tools. In=
troducing interfaces will allow use diamond inheritance for them without an=
y troubles.</span><br>


</p></div><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&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>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">http://groups.google.com/a/<u></u>iso<u><=
/u>cpp.org/group/std-<u></u>proposals/</a>.<br>
</blockquote></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>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>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">http://groups.google.com/a/<u></u>isocpp.=
org/group/std-<u></u>proposals/</a>.<br>
</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" 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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</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 />

--089e0116156a31a3de0500424aae--

.


Author: pfight77@gmail.com
Date: Sun, 10 Aug 2014 01:39:06 -0700 (PDT)
Raw View
------=_Part_5_896127819.1407659946601
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Yes, the ability to static_cast from interface to derived class.=20
dynamic_cast is slower, that's why it is not solution. And yes, writing=20
virtual anywhere is not nice.
That's more, I think interface is a good idea as a concept. Developer can=
=20
easy recognize role of the class in the program by watching to keyword=20
"interface" instead of "class".

=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =D0=
=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 12:33:19 UTC+4 =D0=BF=
=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian Bi=
=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> Anyway, to be clear, then, you want the ability to static_cast from=20
> interface to derived class? Can't you use dynamic_cast instead?
>
> Or are you saying that this feature would make it easier to write code by=
=20
> avoiding the need to write "virtual" in a bunch of places?
> On Aug 10, 2014 4:26 AM, <pfig...@gmail.com <javascript:>> wrote:
>
>> Oh, sory, it is mistype. In first example should be simple inheritance,=
=20
>> not virtual.
>> And to subject of place for vtable. We can place shift to interfaces=20
>> vtable not to all other vtables, but to vtables of all top-most base=20
>> classes in inheritance tree (in case of multiply inheritance there is ca=
n=20
>> be several top-most base classes).=20
>>
>> =D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 12:12:08 UTC+4 =D0=
=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian=
 Bi=20
>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>
>>> Wait, hang on a sec here. You *can* use static_cast for a conversion to=
=20
>>> a virtual base; in fact such a conversion can even be done implicitly. =
Your=20
>>> first example appears to suggest otherwise.
>>> There is problem, where place vtable for interface. I think, there can=
=20
>>> be solution like this: all interfaces will have one vtable in object. S=
hift=20
>>> to this interfaces vtable can be placed as a record to all other vtable=
s=20
>>> (of all base classes).=20
>>>
>>> =D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 11:27:45 UTC+4 =D0=
=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian=
 Bi=20
>>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>>
>>>> And where would this pointer obtained by static_cast point?
>>>> On Aug 10, 2014 3:24 AM, <pfig...@gmail.com> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I suggest to introduce "interface" concept, like in C#. Interface wil=
l=20
>>>>> be like a class with only pure virtual functions, and without any dat=
a=20
>>>>> members. Inheritance of interface will be always virtual. Casting fro=
m=20
>>>>> interface type will be allowed via static_cast.
>>>>>
>>>>> Motivation
>>>>>
>>>>> Diamon of Death situation:
>>>>>
>>>>> class A {};
>>>>> class B : virtual public A {};class C : virtual public A {};
>>>>> class D: public B, public C {};
>>>>>
>>>>> D* d;
>>>>>
>>>>> A* a =3D static_cast<A*>(d); // error: =E2=80=98A=E2=80=99 is an ambi=
guous base of =E2=80=98D=E2=80=99
>>>>>
>>>>>
>>>>> Virtual inheritance allow to avoid Diamon of Death situation. In case=
=20
>>>>> if base class is like "interface" (see above), then virtual inheritan=
ce=20
>>>>> have no side effects: we do not need to make pointer calculations for=
 data=20
>>>>> members, because there is no any of them. But, virtual inheritance fo=
rbid=20
>>>>> use of static_cast:
>>>>>
>>>>> class A {};
>>>>> class B : virtual public A {};class C : virtual public A {};
>>>>> class D: public B, public C {};
>>>>>
>>>>> A* a;
>>>>>
>>>>> D* d =3D static_cast<D*>(a); // error: cannot convert from base =E2=
=80=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 via virtual base =E2=
=80=98A=E2=80=99
>>>>>
>>>>> That's why, now we can't imitate interfaces from C# with existing=20
>>>>> tools. Introducing interfaces will allow use diamond inheritance for =
them=20
>>>>> without any troubles.
>>>>>
>>>>>  --=20
>>>>>
>>>>> ---=20
>>>>> You received this message because you are subscribed to the Google=20
>>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, sen=
d=20
>>>>> an email to std-proposal...@isocpp.org.
>>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>>> Visit this group at http://groups.google.com/a/isocpp.org/group/std-
>>>>> proposals/.
>>>>>
>>>>  --=20
>>>
>>> ---=20
>>> You received this message because you are subscribed to the Google=20
>>> Groups "ISO C++ Standard - Future Proposals" group.
>>> To unsubscribe from this group and stop receiving emails from it, send=
=20
>>> an email to std-proposal...@isocpp.org.
>>> To post to this group, send email to std-pr...@isocpp.org.
>>> Visit this group at http://groups.google.com/a/isocpp.org/group/std-
>>> proposals/.
>>> =20
>>  --=20
>>
>> ---=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=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_5_896127819.1407659946601
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Yes,&nbsp;the ability to static_cast from interface to der=
ived class. dynamic_cast is slower, that's why it is not solution. And yes,=
 writing virtual anywhere is not nice.<div>That's more, I think interface i=
s a good idea as a concept. Developer can easy recognize role of the class =
in the program by watching to keyword "interface" instead of "class".<br><d=
iv><br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, =
10 =D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014&nbsp;=D0=B3., 12:33:19 U=
TC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=
=8C Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><p dir=3D"ltr">Anyway, to be clear, then, you w=
ant the ability to static_cast from interface to derived class? Can't you u=
se dynamic_cast instead?</p>
<p dir=3D"ltr">Or are you saying that this feature would make it easier to =
write code by avoiding the need to write "virtual" in a bunch of places?</p=
>
<div class=3D"gmail_quote">On Aug 10, 2014 4:26 AM,  &lt;<a href=3D"javascr=
ipt:" target=3D"_blank" gdf-obfuscated-mailto=3D"YykRzjGCrnoJ" onmousedown=
=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascr=
ipt:';return true;">pfig...@gmail.com</a>&gt; wrote:<br type=3D"attribution=
"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:=
1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Oh, sory, it is mistype. In first example should be simple=
 inheritance, not virtual.<br>And to subject of place for vtable. We can pl=
ace shift to interfaces vtable not to all other vtables, but to vtables of =
all top-most base classes in inheritance tree (in case of multiply inherita=
nce there is can be several top-most base classes).&nbsp;<br>
<br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014&nbsp;=D0=B3., 12:12:08 UTC+=
4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C =
Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><p dir=3D"ltr">Wait, hang on a sec here. You *can* use sta=
tic_cast for a conversion to a virtual base; in fact such a conversion can =
even be done implicitly. Your first example appears to suggest otherwise.</=
p>

<div style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex=
"><div dir=3D"ltr">There is problem, where place vtable for interface. I th=
ink, there can be solution like this: all interfaces will have one vtable i=
n object. Shift to this interfaces vtable can be placed as a record to all =
other vtables (of all base classes).&nbsp;<br>

<br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014&nbsp;=D0=B3., 11:27:45 UTC+=
4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C =
Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><p dir=3D"ltr">And where would this pointer obtained by st=
atic_cast point?</p>


<div class=3D"gmail_quote">On Aug 10, 2014 3:24 AM,  &lt;<a>pfig...@gmail.c=
om</a>&gt; wrote:<br type=3D"attribution"><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Hello,<div><br></div><div>I suggest to introduce "interfac=
e" concept, like in C#. Interface will be like a class with only pure virtu=
al functions, and without any data members. Inheritance of interface will b=
e always virtual. Casting from interface type will be allowed via static_ca=
st.</div>


<div><br></div><div>Motivation</div><div><br></div><div>Diamon of Death sit=
uation:<br></div><div><br></div><div><pre style=3D"margin-bottom:10px;paddi=
ng:5px;font-size:14px;background-color:rgb(238,238,238);font-family:Consola=
s,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitst=
ream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto=
;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:18px"><code=
 style=3D"font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mo=
no','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,s=
erif;white-space:inherit"><span style=3D"background-color:transparent;color=
:rgb(0,0,139)">class</span><span style=3D"background-color:transparent"> A =
</span><span style=3D"background-color:transparent">{};</span><span style=
=3D"background-color:transparent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>


<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Libe=
ration Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',mo=
nospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;co=
lor:rgb(0,0,0);line-height:18px"><span style=3D"background-color:transparen=
t">D* d;</span><br></pre><pre style=3D"margin-bottom:10px;padding:5px;backg=
round-color:rgb(238,238,238);overflow:auto;width:auto;max-height:600px;word=
-wrap:normal"><code><span style=3D"background-color:transparent"><font colo=
r=3D"#000000" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liberation M=
ono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, se=
rif"><span style=3D"font-size:14px;line-height:18px">A* a =3D static_cast&l=
t;A*&gt;(d); // </span></font></span></code><font color=3D"#000000" face=3D=
"Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono=
, Bitstream Vera Sans Mono, Courier New, monospace, serif"><span style=3D"f=
ont-size:14px;line-height:18px">error: =E2=80=98A=E2=80=99 is an ambiguous =
base of =E2=80=98D=E2=80=99</span></font></pre>


</div><div><br></div><div>Virtual inheritance allow to avoid Diamon of Deat=
h situation. In case if base class is like "interface" (see above), then vi=
rtual inheritance have no side effects: we do not need to make pointer calc=
ulations for data members, because there is no any of them. But, virtual in=
heritance forbid use of static_cast:</div>


<div><br></div><div><pre style=3D"margin-bottom:10px;padding:5px;font-size:=
14px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'L=
ucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mo=
no','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px=
;word-wrap:normal;color:rgb(0,0,0);line-height:18px"><code style=3D"font-fa=
mily:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans =
Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:=
inherit"><span style=3D"background-color:transparent;color:rgb(0,0,139)">cl=
ass</span><span style=3D"background-color:transparent"> A </span><span styl=
e=3D"background-color:transparent">{};</span><span style=3D"background-colo=
r:transparent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>


<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Libe=
ration Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',mo=
nospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;co=
lor:rgb(0,0,0);line-height:18px"><span style=3D"font-family:Arial,'Liberati=
on Sans','DejaVu Sans',sans-serif">A* a;</span></pre><pre style=3D"margin-b=
ottom:10px;padding:5px;font-size:14px;background-color:rgb(238,238,238);fon=
t-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu S=
ans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow=
:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-he=
ight:18px"><span style=3D"font-family:Arial,'Liberation Sans','DejaVu Sans'=
,sans-serif">D* d =3D static_cast&lt;D*&gt;(a); //&nbsp;error: cannot conve=
rt from base =E2=80=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 via vi=
rtual base =E2=80=98A=E2=80=99</span></pre><p style=3D"font-size:small;line=
-height:normal;font-family:arial;clear:both">


<span style=3D"color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu=
 Sans',sans-serif;font-size:13px;line-height:18px">That's why, now we can't=
 imitate interfaces from C# with existing tools. Introducing interfaces wil=
l allow use diamond inheritance for them without any troubles.</span><br>


</p></div><div><br></div></div>

<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 e=
mail to <a>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>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" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<u></u>iso<u></u><wbr>cpp.org/group/std=
-<u></u>proposals/</a>.<br>
</blockquote></div>
</blockquote></div>

<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 e=
mail to <a>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>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" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<u></u>iso<wbr>cpp.org/group/std-<u></u=
>proposals/</a>.<br>
</div>
</blockquote></div>

<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 e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
YykRzjGCrnoJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">std-proposal...@<wbr>isocpp.or=
g</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"YykRzjGCrnoJ" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;">s=
td-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" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</blockquote></div>
</blockquote></div></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&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_5_896127819.1407659946601--

.


Author: Brian Bi <bbi5291@gmail.com>
Date: Sun, 10 Aug 2014 04:47:48 -0400
Raw View
--089e0158b5be34e2180500427ead
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

So you are proposing a more efficient cast, but your implementation would
require extra work for dispatching from an interface compared to ordinary
virtual calls. I mean, if you have a pointer to the virtual base, you look
up the method in the vtable and then call it, but in your proposal, first
you have to look at the derived vtable to find the interface vptr, then
look up the method. So there is an extra step.

Considering that a program will almost always downcast much less than it
invokes virtual methods (AFAIK), this doesn't seem like a win for
performance.
On Aug 10, 2014 4:39 AM, <pfight77@gmail.com> wrote:

> Yes, the ability to static_cast from interface to derived class.
> dynamic_cast is slower, that's why it is not solution. And yes, writing
> virtual anywhere is not nice.
> That's more, I think interface is a good idea as a concept. Developer can
> easy recognize role of the class in the program by watching to keyword
> "interface" instead of "class".
>
> =D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 12:33:19 UTC+4 =D0=
=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian=
 Bi
> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>
>> Anyway, to be clear, then, you want the ability to static_cast from
>> interface to derived class? Can't you use dynamic_cast instead?
>>
>> Or are you saying that this feature would make it easier to write code b=
y
>> avoiding the need to write "virtual" in a bunch of places?
>> On Aug 10, 2014 4:26 AM, <pfig...@gmail.com> wrote:
>>
>>> Oh, sory, it is mistype. In first example should be simple inheritance,
>>> not virtual.
>>> And to subject of place for vtable. We can place shift to interfaces
>>> vtable not to all other vtables, but to vtables of all top-most base
>>> classes in inheritance tree (in case of multiply inheritance there is c=
an
>>> be several top-most base classes).
>>>
>>> =D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 12:12:08 UTC+4 =D0=
=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian=
 Bi
>>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>>
>>>> Wait, hang on a sec here. You *can* use static_cast for a conversion t=
o
>>>> a virtual base; in fact such a conversion can even be done implicitly.=
 Your
>>>> first example appears to suggest otherwise.
>>>> There is problem, where place vtable for interface. I think, there can
>>>> be solution like this: all interfaces will have one vtable in object. =
Shift
>>>> to this interfaces vtable can be placed as a record to all other vtabl=
es
>>>> (of all base classes).
>>>>
>>>> =D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10=
 =D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 11:27:45 UTC+4 =
=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Br=
ian Bi
>>>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>>>
>>>>> And where would this pointer obtained by static_cast point?
>>>>> On Aug 10, 2014 3:24 AM, <pfig...@gmail.com> wrote:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I suggest to introduce "interface" concept, like in C#. Interface
>>>>>> will be like a class with only pure virtual functions, and without a=
ny data
>>>>>> members. Inheritance of interface will be always virtual. Casting fr=
om
>>>>>> interface type will be allowed via static_cast.
>>>>>>
>>>>>> Motivation
>>>>>>
>>>>>> Diamon of Death situation:
>>>>>>
>>>>>> class A {};
>>>>>> class B : virtual public A {};class C : virtual public A {};
>>>>>> class D: public B, public C {};
>>>>>>
>>>>>> D* d;
>>>>>>
>>>>>> A* a =3D static_cast<A*>(d); // error: =E2=80=98A=E2=80=99 is an amb=
iguous base of =E2=80=98D=E2=80=99
>>>>>>
>>>>>>
>>>>>> Virtual inheritance allow to avoid Diamon of Death situation. In cas=
e
>>>>>> if base class is like "interface" (see above), then virtual inherita=
nce
>>>>>> have no side effects: we do not need to make pointer calculations fo=
r data
>>>>>> members, because there is no any of them. But, virtual inheritance f=
orbid
>>>>>> use of static_cast:
>>>>>>
>>>>>> class A {};
>>>>>> class B : virtual public A {};class C : virtual public A {};
>>>>>> class D: public B, public C {};
>>>>>>
>>>>>> A* a;
>>>>>>
>>>>>> D* d =3D static_cast<D*>(a); // error: cannot convert from base =E2=
=80=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 via virtual base =E2=
=80=98A=E2=80=99
>>>>>>
>>>>>> That's why, now we can't imitate interfaces from C# with existing
>>>>>> tools. Introducing interfaces will allow use diamond inheritance for=
 them
>>>>>> without any troubles.
>>>>>>
>>>>>>  --
>>>>>>
>>>>>> ---
>>>>>> 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-proposal...@isocpp.org.
>>>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>>>> Visit this group at http://groups.google.com/a/isocpp.org/group/std-
>>>>>> proposals/.
>>>>>>
>>>>>  --
>>>>
>>>> ---
>>>> 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-proposal...@isocpp.org.
>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>> Visit this group at http://groups.google.com/a/isocpp.org/group/std-
>>>> proposals/.
>>>>
>>>  --
>>>
>>> ---
>>> 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-proposal...@isocpp.org.
>>> To post to this group, send email to std-pr...@isocpp.org.
>>> Visit this group at http://groups.google.com/a/isocpp.org/group/std-
>>> proposals/.
>>>
>>  --
>
> ---
> 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/.
>

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

--089e0158b5be34e2180500427ead
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<p dir=3D"ltr">So you are proposing a more efficient cast, but your impleme=
ntation would require extra work for dispatching from an interface compared=
 to ordinary virtual calls. I mean, if you have a pointer to the virtual ba=
se, you look up the method in the vtable and then call it, but in your prop=
osal, first you have to look at the derived vtable to find the interface vp=
tr, then look up the method. So there is an extra step.</p>

<p dir=3D"ltr">Considering that a program will almost always downcast much =
less than it invokes virtual methods (AFAIK), this doesn&#39;t seem like a =
win for performance.</p>
<div class=3D"gmail_quote">On Aug 10, 2014 4:39 AM,  &lt;<a href=3D"mailto:=
pfight77@gmail.com">pfight77@gmail.com</a>&gt; wrote:<br type=3D"attributio=
n"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Yes,=C2=A0the ability to static_cast from interface to der=
ived class. dynamic_cast is slower, that&#39;s why it is not solution. And =
yes, writing virtual anywhere is not nice.<div>That&#39;s more, I think int=
erface is a good idea as a concept. Developer can easy recognize role of th=
e class in the program by watching to keyword &quot;interface&quot; instead=
 of &quot;class&quot;.<br>
<div><br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5=
, 10 =D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014=C2=A0=D0=B3., 12:33:19=
 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=
=D1=8C Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote clas=
s=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc =
solid;padding-left:1ex"><p dir=3D"ltr">Anyway, to be clear, then, you want =
the ability to static_cast from interface to derived class? Can&#39;t you u=
se dynamic_cast instead?</p>

<p dir=3D"ltr">Or are you saying that this feature would make it easier to =
write code by avoiding the need to write &quot;virtual&quot; in a bunch of =
places?</p>
<div class=3D"gmail_quote">On Aug 10, 2014 4:26 AM,  &lt;<a>pfig...@gmail.c=
om</a>&gt; wrote:<br type=3D"attribution"><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Oh, sory, it is mistype. In first example should be simple=
 inheritance, not virtual.<br>And to subject of place for vtable. We can pl=
ace shift to interfaces vtable not to all other vtables, but to vtables of =
all top-most base classes in inheritance tree (in case of multiply inherita=
nce there is can be several top-most base classes).=C2=A0<br>

<br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014=C2=A0=D0=B3., 12:12:08 UTC+=
4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C =
Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><p dir=3D"ltr">Wait, hang on a sec here. You *can* use sta=
tic_cast for a conversion to a virtual base; in fact such a conversion can =
even be done implicitly. Your first example appears to suggest otherwise.</=
p>


<div style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex=
"><div dir=3D"ltr">There is problem, where place vtable for interface. I th=
ink, there can be solution like this: all interfaces will have one vtable i=
n object. Shift to this interfaces vtable can be placed as a record to all =
other vtables (of all base classes).=C2=A0<br>


<br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014=C2=A0=D0=B3., 11:27:45 UTC+=
4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C =
Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><p dir=3D"ltr">And where would this pointer obtained by st=
atic_cast point?</p>



<div class=3D"gmail_quote">On Aug 10, 2014 3:24 AM,  &lt;<a>pfig...@gmail.c=
om</a>&gt; wrote:<br type=3D"attribution"><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Hello,<div><br></div><div>I suggest to introduce &quot;int=
erface&quot; concept, like in C#. Interface will be like a class with only =
pure virtual functions, and without any data members. Inheritance of interf=
ace will be always virtual. Casting from interface type will be allowed via=
 static_cast.</div>



<div><br></div><div>Motivation</div><div><br></div><div>Diamon of Death sit=
uation:<br></div><div><br></div><div><pre style=3D"margin-bottom:10px;paddi=
ng:5px;font-size:14px;background-color:rgb(238,238,238);font-family:Consola=
s,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;Deja=
Vu Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,=
monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;=
color:rgb(0,0,0);line-height:18px">
<code style=3D"font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&=
#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera San=
s Mono&#39;,&#39;Courier New&#39;,monospace,serif;white-space:inherit"><spa=
n style=3D"background-color:transparent;color:rgb(0,0,139)">class</span><sp=
an style=3D"background-color:transparent"> A </span><span style=3D"backgrou=
nd-color:transparent">{};</span><span style=3D"background-color:transparent=
">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>



<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#3=
9;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera=
 Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;overflow:auto;width:a=
uto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:18px">
<span style=3D"background-color:transparent">D* d;</span><br></pre><pre sty=
le=3D"margin-bottom:10px;padding:5px;background-color:rgb(238,238,238);over=
flow:auto;width:auto;max-height:600px;word-wrap:normal"><code><span style=
=3D"background-color:transparent"><font color=3D"#000000" face=3D"Consolas,=
 Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstrea=
m Vera Sans Mono, Courier New, monospace, serif"><span style=3D"font-size:1=
4px;line-height:18px">A* a =3D static_cast&lt;A*&gt;(d); // </span></font><=
/span></code><font color=3D"#000000" face=3D"Consolas, Menlo, Monaco, Lucid=
a Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Cou=
rier New, monospace, serif"><span style=3D"font-size:14px;line-height:18px"=
>error: =E2=80=98A=E2=80=99 is an ambiguous base of =E2=80=98D=E2=80=99</sp=
an></font></pre>



</div><div><br></div><div>Virtual inheritance allow to avoid Diamon of Deat=
h situation. In case if base class is like &quot;interface&quot; (see above=
), then virtual inheritance have no side effects: we do not need to make po=
inter calculations for data members, because there is no any of them. But, =
virtual inheritance forbid use of static_cast:</div>



<div><br></div><div><pre style=3D"margin-bottom:10px;padding:5px;font-size:=
14px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#=
39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;=
,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;o=
verflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);=
line-height:18px">
<code style=3D"font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#39;,&=
#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera San=
s Mono&#39;,&#39;Courier New&#39;,monospace,serif;white-space:inherit"><spa=
n style=3D"background-color:transparent;color:rgb(0,0,139)">class</span><sp=
an style=3D"background-color:transparent"> A </span><span style=3D"backgrou=
nd-color:transparent">{};</span><span style=3D"background-color:transparent=
">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>



<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,&#39;Lucida Console&#3=
9;,&#39;Liberation Mono&#39;,&#39;DejaVu Sans Mono&#39;,&#39;Bitstream Vera=
 Sans Mono&#39;,&#39;Courier New&#39;,monospace,serif;overflow:auto;width:a=
uto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:18px">
<span style=3D"font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans=
&#39;,sans-serif">A* a;</span></pre><pre style=3D"margin-bottom:10px;paddin=
g:5px;font-size:14px;background-color:rgb(238,238,238);font-family:Consolas=
,Menlo,Monaco,&#39;Lucida Console&#39;,&#39;Liberation Mono&#39;,&#39;DejaV=
u Sans Mono&#39;,&#39;Bitstream Vera Sans Mono&#39;,&#39;Courier New&#39;,m=
onospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;c=
olor:rgb(0,0,0);line-height:18px">
<span style=3D"font-family:Arial,&#39;Liberation Sans&#39;,&#39;DejaVu Sans=
&#39;,sans-serif">D* d =3D static_cast&lt;D*&gt;(a); //=C2=A0error: cannot =
convert from base =E2=80=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 v=
ia virtual base =E2=80=98A=E2=80=99</span></pre><p style=3D"font-size:small=
;line-height:normal;font-family:arial;clear:both">



<span style=3D"color:rgb(0,0,0);font-family:Arial,&#39;Liberation Sans&#39;=
,&#39;DejaVu Sans&#39;,sans-serif;font-size:13px;line-height:18px">That&#39=
;s why, now we can&#39;t imitate interfaces from C# with existing tools. In=
troducing interfaces will allow use diamond inheritance for them without an=
y troubles.</span><br>



</p></div><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&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>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">http://groups.google.com/a/<u></u>iso<u><=
/u><u></u>cpp.org/group/std-<u></u>proposals/</a>.<br>
</blockquote></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>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>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">http://groups.google.com/a/<u></u>iso<u><=
/u>cpp.org/group/std-<u></u>proposals/</a>.<br>
</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>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>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">http://groups.google.com/a/<u></u>isocpp.=
org/group/std-<u></u>proposals/</a>.<br>
</blockquote></div>
</blockquote></div></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&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" 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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</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 />

--089e0158b5be34e2180500427ead--

.


Author: pfight77@gmail.com
Date: Sun, 10 Aug 2014 02:07:15 -0700 (PDT)
Raw View
------=_Part_978_1755708785.1407661635565
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Oh, sure, you are right, another step is not good. How about to place one=
=20
copy of interfaces vtable in vtables of every top-most base class? A count=
=20
of top-most base classes should be not very big (at most cases one), so=20
memory waste will be not very big in common case. Especially if take in=20
attention, that Diamond Death is not very frequent situation. When there is=
=20
no Diamond Death we can use plain old schemes of inheritance. So,=20
additional memory will be needed only in case of Diamond Death of=20
interfaces with several top-most base classes in inheritance tree. Quit=20
rare situation.

=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =D0=
=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 12:47:51 UTC+4 =D0=BF=
=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian Bi=
=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> So you are proposing a more efficient cast, but your implementation would=
=20
> require extra work for dispatching from an interface compared to ordinary=
=20
> virtual calls. I mean, if you have a pointer to the virtual base, you loo=
k=20
> up the method in the vtable and then call it, but in your proposal, first=
=20
> you have to look at the derived vtable to find the interface vptr, then=
=20
> look up the method. So there is an extra step.
>
> Considering that a program will almost always downcast much less than it=
=20
> invokes virtual methods (AFAIK), this doesn't seem like a win for=20
> performance.
> On Aug 10, 2014 4:39 AM, <pfig...@gmail.com <javascript:>> wrote:
>
>> Yes, the ability to static_cast from interface to derived class.=20
>> dynamic_cast is slower, that's why it is not solution. And yes, writing=
=20
>> virtual anywhere is not nice.
>> That's more, I think interface is a good idea as a concept. Developer ca=
n=20
>> easy recognize role of the class in the program by watching to keyword=
=20
>> "interface" instead of "class".
>>
>> =D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 12:33:19 UTC+4 =D0=
=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian=
 Bi=20
>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>
>>> Anyway, to be clear, then, you want the ability to static_cast from=20
>>> interface to derived class? Can't you use dynamic_cast instead?
>>>
>>> Or are you saying that this feature would make it easier to write code=
=20
>>> by avoiding the need to write "virtual" in a bunch of places?
>>> On Aug 10, 2014 4:26 AM, <pfig...@gmail.com> wrote:
>>>
>>>> Oh, sory, it is mistype. In first example should be simple inheritance=
,=20
>>>> not virtual.
>>>> And to subject of place for vtable. We can place shift to interfaces=
=20
>>>> vtable not to all other vtables, but to vtables of all top-most base=
=20
>>>> classes in inheritance tree (in case of multiply inheritance there is =
can=20
>>>> be several top-most base classes).=20
>>>>
>>>> =D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10=
 =D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 12:12:08 UTC+4 =
=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Br=
ian Bi=20
>>>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>>>
>>>>> Wait, hang on a sec here. You *can* use static_cast for a conversion=
=20
>>>>> to a virtual base; in fact such a conversion can even be done implici=
tly.=20
>>>>> Your first example appears to suggest otherwise.
>>>>> There is problem, where place vtable for interface. I think, there ca=
n=20
>>>>> be solution like this: all interfaces will have one vtable in object.=
 Shift=20
>>>>> to this interfaces vtable can be placed as a record to all other vtab=
les=20
>>>>> (of all base classes).=20
>>>>>
>>>>> =D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 1=
0 =D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 11:27:45 UTC+4 =
=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Br=
ian Bi=20
>>>>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>>>>
>>>>>> And where would this pointer obtained by static_cast point?
>>>>>> On Aug 10, 2014 3:24 AM, <pfig...@gmail.com> wrote:
>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> I suggest to introduce "interface" concept, like in C#. Interface=
=20
>>>>>>> will be like a class with only pure virtual functions, and without =
any data=20
>>>>>>> members. Inheritance of interface will be always virtual. Casting f=
rom=20
>>>>>>> interface type will be allowed via static_cast.
>>>>>>>
>>>>>>> Motivation
>>>>>>>
>>>>>>> Diamon of Death situation:
>>>>>>>
>>>>>>> class A {};
>>>>>>> class B : virtual public A {};class C : virtual public A {};
>>>>>>> class D: public B, public C {};
>>>>>>>
>>>>>>> D* d;
>>>>>>>
>>>>>>> A* a =3D static_cast<A*>(d); // error: =E2=80=98A=E2=80=99 is an am=
biguous base of =E2=80=98D=E2=80=99
>>>>>>>
>>>>>>>
>>>>>>> Virtual inheritance allow to avoid Diamon of Death situation. In=20
>>>>>>> case if base class is like "interface" (see above), then virtual=20
>>>>>>> inheritance have no side effects: we do not need to make pointer=20
>>>>>>> calculations for data members, because there is no any of them. But=
,=20
>>>>>>> virtual inheritance forbid use of static_cast:
>>>>>>>
>>>>>>> class A {};
>>>>>>> class B : virtual public A {};class C : virtual public A {};
>>>>>>> class D: public B, public C {};
>>>>>>>
>>>>>>> A* a;
>>>>>>>
>>>>>>> D* d =3D static_cast<D*>(a); // error: cannot convert from base =E2=
=80=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 via virtual base =E2=
=80=98A=E2=80=99
>>>>>>>
>>>>>>> That's why, now we can't imitate interfaces from C# with existing=
=20
>>>>>>> tools. Introducing interfaces will allow use diamond inheritance fo=
r them=20
>>>>>>> without any troubles.
>>>>>>>
>>>>>>>  --=20
>>>>>>>
>>>>>>> ---=20
>>>>>>> You received this message because you are subscribed to the Google=
=20
>>>>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,=
=20
>>>>>>> send an email to std-proposal...@isocpp.org.
>>>>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>>>>> Visit this group at http://groups.google.com/a/isocpp.org/group/std=
-
>>>>>>> proposals/.
>>>>>>>
>>>>>>  --=20
>>>>>
>>>>> ---=20
>>>>> You received this message because you are subscribed to the Google=20
>>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, sen=
d=20
>>>>> an email to std-proposal...@isocpp.org.
>>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>>> Visit this group at http://groups.google.com/a/isocpp.org/group/std-
>>>>> proposals/.
>>>>> =20
>>>>  --=20
>>>>
>>>> ---=20
>>>> You received this message because you are subscribed to the Google=20
>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send=
=20
>>>> an email to std-proposal...@isocpp.org.
>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>> Visit this group at http://groups.google.com/a/isocpp.org/group/std-
>>>> proposals/.
>>>>
>>>  --=20
>>
>> ---=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=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_978_1755708785.1407661635565
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Oh, sure, you are right, another step is not good. How abo=
ut to place one copy of interfaces vtable in vtables of every top-most base=
 class? A count of top-most base classes should be not very big (at most ca=
ses one), so memory waste will be not very big in common case. Especially i=
f take in attention, that Diamond Death is not very frequent situation. Whe=
n there is no Diamond Death we can use plain old schemes of inheritance. So=
, additional memory will be needed only in case of Diamond Death of interfa=
ces with several top-most base classes in inheritance tree. Quit rare situa=
tion.<br><br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=
=D0=B5, 10 =D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014&nbsp;=D0=B3., 12=
:47:51 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=
=D0=BB=D1=8C Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquot=
e class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: =
1px #ccc solid;padding-left: 1ex;"><p dir=3D"ltr">So you are proposing a mo=
re efficient cast, but your implementation would require extra work for dis=
patching from an interface compared to ordinary virtual calls. I mean, if y=
ou have a pointer to the virtual base, you look up the method in the vtable=
 and then call it, but in your proposal, first you have to look at the deri=
ved vtable to find the interface vptr, then look up the method. So there is=
 an extra step.</p>

<p dir=3D"ltr">Considering that a program will almost always downcast much =
less than it invokes virtual methods (AFAIK), this doesn't seem like a win =
for performance.</p>
<div class=3D"gmail_quote">On Aug 10, 2014 4:39 AM,  &lt;<a href=3D"javascr=
ipt:" target=3D"_blank" gdf-obfuscated-mailto=3D"ynNVZgwONf0J" onmousedown=
=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascr=
ipt:';return true;">pfig...@gmail.com</a>&gt; wrote:<br type=3D"attribution=
"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:=
1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Yes,&nbsp;the ability to static_cast from interface to der=
ived class. dynamic_cast is slower, that's why it is not solution. And yes,=
 writing virtual anywhere is not nice.<div>That's more, I think interface i=
s a good idea as a concept. Developer can easy recognize role of the class =
in the program by watching to keyword "interface" instead of "class".<br>
<div><br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5=
, 10 =D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014&nbsp;=D0=B3., 12:33:19=
 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=
=D1=8C Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote clas=
s=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc =
solid;padding-left:1ex"><p dir=3D"ltr">Anyway, to be clear, then, you want =
the ability to static_cast from interface to derived class? Can't you use d=
ynamic_cast instead?</p>

<p dir=3D"ltr">Or are you saying that this feature would make it easier to =
write code by avoiding the need to write "virtual" in a bunch of places?</p=
>
<div class=3D"gmail_quote">On Aug 10, 2014 4:26 AM,  &lt;<a>pfig...@gmail.c=
om</a>&gt; wrote:<br type=3D"attribution"><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Oh, sory, it is mistype. In first example should be simple=
 inheritance, not virtual.<br>And to subject of place for vtable. We can pl=
ace shift to interfaces vtable not to all other vtables, but to vtables of =
all top-most base classes in inheritance tree (in case of multiply inherita=
nce there is can be several top-most base classes).&nbsp;<br>

<br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014&nbsp;=D0=B3., 12:12:08 UTC+=
4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C =
Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><p dir=3D"ltr">Wait, hang on a sec here. You *can* use sta=
tic_cast for a conversion to a virtual base; in fact such a conversion can =
even be done implicitly. Your first example appears to suggest otherwise.</=
p>


<div style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex=
"><div dir=3D"ltr">There is problem, where place vtable for interface. I th=
ink, there can be solution like this: all interfaces will have one vtable i=
n object. Shift to this interfaces vtable can be placed as a record to all =
other vtables (of all base classes).&nbsp;<br>


<br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014&nbsp;=D0=B3., 11:27:45 UTC+=
4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C =
Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><p dir=3D"ltr">And where would this pointer obtained by st=
atic_cast point?</p>



<div class=3D"gmail_quote">On Aug 10, 2014 3:24 AM,  &lt;<a>pfig...@gmail.c=
om</a>&gt; wrote:<br type=3D"attribution"><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Hello,<div><br></div><div>I suggest to introduce "interfac=
e" concept, like in C#. Interface will be like a class with only pure virtu=
al functions, and without any data members. Inheritance of interface will b=
e always virtual. Casting from interface type will be allowed via static_ca=
st.</div>



<div><br></div><div>Motivation</div><div><br></div><div>Diamon of Death sit=
uation:<br></div><div><br></div><div><pre style=3D"margin-bottom:10px;paddi=
ng:5px;font-size:14px;background-color:rgb(238,238,238);font-family:Consola=
s,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitst=
ream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto=
;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:18px"><code=
 style=3D"font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mo=
no','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,s=
erif;white-space:inherit"><span style=3D"background-color:transparent;color=
:rgb(0,0,139)">class</span><span style=3D"background-color:transparent"> A =
</span><span style=3D"background-color:transparent">{};</span><span style=
=3D"background-color:transparent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>



<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Libe=
ration Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',mo=
nospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;co=
lor:rgb(0,0,0);line-height:18px"><span style=3D"background-color:transparen=
t">D* d;</span><br></pre><pre style=3D"margin-bottom:10px;padding:5px;backg=
round-color:rgb(238,238,238);overflow:auto;width:auto;max-height:600px;word=
-wrap:normal"><code><span style=3D"background-color:transparent"><font colo=
r=3D"#000000" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liberation M=
ono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, se=
rif"><span style=3D"font-size:14px;line-height:18px">A* a =3D static_cast&l=
t;A*&gt;(d); // </span></font></span></code><font color=3D"#000000" face=3D=
"Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono=
, Bitstream Vera Sans Mono, Courier New, monospace, serif"><span style=3D"f=
ont-size:14px;line-height:18px">error: =E2=80=98A=E2=80=99 is an ambiguous =
base of =E2=80=98D=E2=80=99</span></font></pre>



</div><div><br></div><div>Virtual inheritance allow to avoid Diamon of Deat=
h situation. In case if base class is like "interface" (see above), then vi=
rtual inheritance have no side effects: we do not need to make pointer calc=
ulations for data members, because there is no any of them. But, virtual in=
heritance forbid use of static_cast:</div>



<div><br></div><div><pre style=3D"margin-bottom:10px;padding:5px;font-size:=
14px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'L=
ucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mo=
no','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px=
;word-wrap:normal;color:rgb(0,0,0);line-height:18px"><code style=3D"font-fa=
mily:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans =
Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:=
inherit"><span style=3D"background-color:transparent;color:rgb(0,0,139)">cl=
ass</span><span style=3D"background-color:transparent"> A </span><span styl=
e=3D"background-color:transparent">{};</span><span style=3D"background-colo=
r:transparent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>



<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Libe=
ration Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',mo=
nospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;co=
lor:rgb(0,0,0);line-height:18px"><span style=3D"font-family:Arial,'Liberati=
on Sans','DejaVu Sans',sans-serif">A* a;</span></pre><pre style=3D"margin-b=
ottom:10px;padding:5px;font-size:14px;background-color:rgb(238,238,238);fon=
t-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu S=
ans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow=
:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-he=
ight:18px"><span style=3D"font-family:Arial,'Liberation Sans','DejaVu Sans'=
,sans-serif">D* d =3D static_cast&lt;D*&gt;(a); //&nbsp;error: cannot conve=
rt from base =E2=80=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 via vi=
rtual base =E2=80=98A=E2=80=99</span></pre><p style=3D"font-size:small;line=
-height:normal;font-family:arial;clear:both">



<span style=3D"color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu=
 Sans',sans-serif;font-size:13px;line-height:18px">That's why, now we can't=
 imitate interfaces from C# with existing tools. Introducing interfaces wil=
l allow use diamond inheritance for them without any troubles.</span><br>



</p></div><div><br></div></div>

<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 e=
mail to <a>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>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" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<u></u>iso<u></u><u></u><wbr>cpp.org/gr=
oup/std-<u></u>proposals/</a>.<br>
</blockquote></div>
</blockquote></div>

<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 e=
mail to <a>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>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" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<u></u>iso<u></u><wbr>cpp.org/group/std=
-<u></u>proposals/</a>.<br>
</div>
</blockquote></div>

<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 e=
mail to <a>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>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" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<u></u>iso<wbr>cpp.org/group/std-<u></u=
>proposals/</a>.<br>
</blockquote></div>
</blockquote></div></div></div>

<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 e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
ynNVZgwONf0J" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">std-proposal...@<wbr>isocpp.or=
g</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"ynNVZgwONf0J" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;">s=
td-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" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</blockquote></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_978_1755708785.1407661635565--

.


Author: pfight77@gmail.com
Date: Sun, 10 Aug 2014 04:28:00 -0700 (PDT)
Raw View
------=_Part_28_1828355960.1407670080763
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Oh, there is more simple solution: make usual (not virtual) inheritance for=
=20
interfaces, but when upward conversion (from derived to interface) will be=
=20
needed, select any random copy of interface. In other words, when "error:=
=20
=E2=80=98A=E2=80=99 is an ambiguous base of =E2=80=98D=E2=80=99" appears, s=
elect any copy of A from=20
available. There is no difference between "A of B" and "A of C", because=20
all of them contains only vtables and nothing more. There also is memory=20
wasting, but it is standard behavior, accepted by standard.

=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =D0=
=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 12:47:51 UTC+4 =D0=BF=
=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian Bi=
=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> So you are proposing a more efficient cast, but your implementation would=
=20
> require extra work for dispatching from an interface compared to ordinary=
=20
> virtual calls. I mean, if you have a pointer to the virtual base, you loo=
k=20
> up the method in the vtable and then call it, but in your proposal, first=
=20
> you have to look at the derived vtable to find the interface vptr, then=
=20
> look up the method. So there is an extra step.
>
> Considering that a program will almost always downcast much less than it=
=20
> invokes virtual methods (AFAIK), this doesn't seem like a win for=20
> performance.
> On Aug 10, 2014 4:39 AM, <pfig...@gmail.com <javascript:>> wrote:
>
>> Yes, the ability to static_cast from interface to derived class.=20
>> dynamic_cast is slower, that's why it is not solution. And yes, writing=
=20
>> virtual anywhere is not nice.
>> That's more, I think interface is a good idea as a concept. Developer ca=
n=20
>> easy recognize role of the class in the program by watching to keyword=
=20
>> "interface" instead of "class".
>>
>> =D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 12:33:19 UTC+4 =D0=
=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Brian=
 Bi=20
>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>
>>> Anyway, to be clear, then, you want the ability to static_cast from=20
>>> interface to derived class? Can't you use dynamic_cast instead?
>>>
>>> Or are you saying that this feature would make it easier to write code=
=20
>>> by avoiding the need to write "virtual" in a bunch of places?
>>> On Aug 10, 2014 4:26 AM, <pfig...@gmail.com> wrote:
>>>
>>>> Oh, sory, it is mistype. In first example should be simple inheritance=
,=20
>>>> not virtual.
>>>> And to subject of place for vtable. We can place shift to interfaces=
=20
>>>> vtable not to all other vtables, but to vtables of all top-most base=
=20
>>>> classes in inheritance tree (in case of multiply inheritance there is =
can=20
>>>> be several top-most base classes).=20
>>>>
>>>> =D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10=
 =D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 12:12:08 UTC+4 =
=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Br=
ian Bi=20
>>>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>>>
>>>>> Wait, hang on a sec here. You *can* use static_cast for a conversion=
=20
>>>>> to a virtual base; in fact such a conversion can even be done implici=
tly.=20
>>>>> Your first example appears to suggest otherwise.
>>>>> There is problem, where place vtable for interface. I think, there ca=
n=20
>>>>> be solution like this: all interfaces will have one vtable in object.=
 Shift=20
>>>>> to this interfaces vtable can be placed as a record to all other vtab=
les=20
>>>>> (of all base classes).=20
>>>>>
>>>>> =D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 1=
0 =D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014 =D0=B3., 11:27:45 UTC+4 =
=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Br=
ian Bi=20
>>>>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>>>>
>>>>>> And where would this pointer obtained by static_cast point?
>>>>>> On Aug 10, 2014 3:24 AM, <pfig...@gmail.com> wrote:
>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> I suggest to introduce "interface" concept, like in C#. Interface=
=20
>>>>>>> will be like a class with only pure virtual functions, and without =
any data=20
>>>>>>> members. Inheritance of interface will be always virtual. Casting f=
rom=20
>>>>>>> interface type will be allowed via static_cast.
>>>>>>>
>>>>>>> Motivation
>>>>>>>
>>>>>>> Diamon of Death situation:
>>>>>>>
>>>>>>> class A {};
>>>>>>> class B : virtual public A {};class C : virtual public A {};
>>>>>>> class D: public B, public C {};
>>>>>>>
>>>>>>> D* d;
>>>>>>>
>>>>>>> A* a =3D static_cast<A*>(d); // error: =E2=80=98A=E2=80=99 is an am=
biguous base of =E2=80=98D=E2=80=99
>>>>>>>
>>>>>>>
>>>>>>> Virtual inheritance allow to avoid Diamon of Death situation. In=20
>>>>>>> case if base class is like "interface" (see above), then virtual=20
>>>>>>> inheritance have no side effects: we do not need to make pointer=20
>>>>>>> calculations for data members, because there is no any of them. But=
,=20
>>>>>>> virtual inheritance forbid use of static_cast:
>>>>>>>
>>>>>>> class A {};
>>>>>>> class B : virtual public A {};class C : virtual public A {};
>>>>>>> class D: public B, public C {};
>>>>>>>
>>>>>>> A* a;
>>>>>>>
>>>>>>> D* d =3D static_cast<D*>(a); // error: cannot convert from base =E2=
=80=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 via virtual base =E2=
=80=98A=E2=80=99
>>>>>>>
>>>>>>> That's why, now we can't imitate interfaces from C# with existing=
=20
>>>>>>> tools. Introducing interfaces will allow use diamond inheritance fo=
r them=20
>>>>>>> without any troubles.
>>>>>>>
>>>>>>>  --=20
>>>>>>>
>>>>>>> ---=20
>>>>>>> You received this message because you are subscribed to the Google=
=20
>>>>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,=
=20
>>>>>>> send an email to std-proposal...@isocpp.org.
>>>>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>>>>> Visit this group at http://groups.google.com/a/isocpp.org/group/std=
-
>>>>>>> proposals/.
>>>>>>>
>>>>>>  --=20
>>>>>
>>>>> ---=20
>>>>> You received this message because you are subscribed to the Google=20
>>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, sen=
d=20
>>>>> an email to std-proposal...@isocpp.org.
>>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>>> Visit this group at http://groups.google.com/a/isocpp.org/group/std-
>>>>> proposals/.
>>>>> =20
>>>>  --=20
>>>>
>>>> ---=20
>>>> You received this message because you are subscribed to the Google=20
>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send=
=20
>>>> an email to std-proposal...@isocpp.org.
>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>> Visit this group at http://groups.google.com/a/isocpp.org/group/std-
>>>> proposals/.
>>>>
>>>  --=20
>>
>> ---=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=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_28_1828355960.1407670080763
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Oh, there is more simple solution: make usual (not virtual=
) inheritance for interfaces, but when upward conversion&nbsp;(from derived=
 to interface)&nbsp;will be needed, select any random copy of interface. In=
 other words, when "<span style=3D"font-size: 14px; line-height: 18px; colo=
r: rgb(0, 0, 0); font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'L=
iberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier N=
ew', monospace, serif; background-color: rgb(238, 238, 238);">error: =E2=80=
=98A=E2=80=99 is an ambiguous base of =E2=80=98D=E2=80=99"</span>&nbsp;appe=
ars, select any copy of A from available. There is no difference between "A=
 of B" and "A of C", because all of them contains only vtables and nothing =
more. There also is memory wasting, but it is standard behavior, accepted b=
y standard.<br><br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=
=D1=8C=D0=B5, 10 =D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014&nbsp;=D0=
=B3., 12:47:51 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=
=D0=B5=D0=BB=D1=8C Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blo=
ckquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-=
left: 1px #ccc solid;padding-left: 1ex;"><p dir=3D"ltr">So you are proposin=
g a more efficient cast, but your implementation would require extra work f=
or dispatching from an interface compared to ordinary virtual calls. I mean=
, if you have a pointer to the virtual base, you look up the method in the =
vtable and then call it, but in your proposal, first you have to look at th=
e derived vtable to find the interface vptr, then look up the method. So th=
ere is an extra step.</p>

<p dir=3D"ltr">Considering that a program will almost always downcast much =
less than it invokes virtual methods (AFAIK), this doesn't seem like a win =
for performance.</p>
<div class=3D"gmail_quote">On Aug 10, 2014 4:39 AM,  &lt;<a href=3D"javascr=
ipt:" target=3D"_blank" gdf-obfuscated-mailto=3D"ynNVZgwONf0J" onmousedown=
=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascr=
ipt:';return true;">pfig...@gmail.com</a>&gt; wrote:<br type=3D"attribution=
"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:=
1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Yes,&nbsp;the ability to static_cast from interface to der=
ived class. dynamic_cast is slower, that's why it is not solution. And yes,=
 writing virtual anywhere is not nice.<div>That's more, I think interface i=
s a good idea as a concept. Developer can easy recognize role of the class =
in the program by watching to keyword "interface" instead of "class".<br>
<div><br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5=
, 10 =D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014&nbsp;=D0=B3., 12:33:19=
 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=
=D1=8C Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote clas=
s=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc =
solid;padding-left:1ex"><p dir=3D"ltr">Anyway, to be clear, then, you want =
the ability to static_cast from interface to derived class? Can't you use d=
ynamic_cast instead?</p>

<p dir=3D"ltr">Or are you saying that this feature would make it easier to =
write code by avoiding the need to write "virtual" in a bunch of places?</p=
>
<div class=3D"gmail_quote">On Aug 10, 2014 4:26 AM,  &lt;<a>pfig...@gmail.c=
om</a>&gt; wrote:<br type=3D"attribution"><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Oh, sory, it is mistype. In first example should be simple=
 inheritance, not virtual.<br>And to subject of place for vtable. We can pl=
ace shift to interfaces vtable not to all other vtables, but to vtables of =
all top-most base classes in inheritance tree (in case of multiply inherita=
nce there is can be several top-most base classes).&nbsp;<br>

<br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014&nbsp;=D0=B3., 12:12:08 UTC+=
4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C =
Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><p dir=3D"ltr">Wait, hang on a sec here. You *can* use sta=
tic_cast for a conversion to a virtual base; in fact such a conversion can =
even be done implicitly. Your first example appears to suggest otherwise.</=
p>


<div style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex=
"><div dir=3D"ltr">There is problem, where place vtable for interface. I th=
ink, there can be solution like this: all interfaces will have one vtable i=
n object. Shift to this interfaces vtable can be placed as a record to all =
other vtables (of all base classes).&nbsp;<br>


<br>=D0=B2=D0=BE=D1=81=D0=BA=D1=80=D0=B5=D1=81=D0=B5=D0=BD=D1=8C=D0=B5, 10 =
=D0=B0=D0=B2=D0=B3=D1=83=D1=81=D1=82=D0=B0 2014&nbsp;=D0=B3., 11:27:45 UTC+=
4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C =
Brian Bi =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><p dir=3D"ltr">And where would this pointer obtained by st=
atic_cast point?</p>



<div class=3D"gmail_quote">On Aug 10, 2014 3:24 AM,  &lt;<a>pfig...@gmail.c=
om</a>&gt; wrote:<br type=3D"attribution"><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Hello,<div><br></div><div>I suggest to introduce "interfac=
e" concept, like in C#. Interface will be like a class with only pure virtu=
al functions, and without any data members. Inheritance of interface will b=
e always virtual. Casting from interface type will be allowed via static_ca=
st.</div>



<div><br></div><div>Motivation</div><div><br></div><div>Diamon of Death sit=
uation:<br></div><div><br></div><div><pre style=3D"margin-bottom:10px;paddi=
ng:5px;font-size:14px;background-color:rgb(238,238,238);font-family:Consola=
s,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitst=
ream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto=
;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:18px"><code=
 style=3D"font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mo=
no','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,s=
erif;white-space:inherit"><span style=3D"background-color:transparent;color=
:rgb(0,0,139)">class</span><span style=3D"background-color:transparent"> A =
</span><span style=3D"background-color:transparent">{};</span><span style=
=3D"background-color:transparent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>



<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Libe=
ration Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',mo=
nospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;co=
lor:rgb(0,0,0);line-height:18px"><span style=3D"background-color:transparen=
t">D* d;</span><br></pre><pre style=3D"margin-bottom:10px;padding:5px;backg=
round-color:rgb(238,238,238);overflow:auto;width:auto;max-height:600px;word=
-wrap:normal"><code><span style=3D"background-color:transparent"><font colo=
r=3D"#000000" face=3D"Consolas, Menlo, Monaco, Lucida Console, Liberation M=
ono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, se=
rif"><span style=3D"font-size:14px;line-height:18px">A* a =3D static_cast&l=
t;A*&gt;(d); // </span></font></span></code><font color=3D"#000000" face=3D=
"Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono=
, Bitstream Vera Sans Mono, Courier New, monospace, serif"><span style=3D"f=
ont-size:14px;line-height:18px">error: =E2=80=98A=E2=80=99 is an ambiguous =
base of =E2=80=98D=E2=80=99</span></font></pre>



</div><div><br></div><div>Virtual inheritance allow to avoid Diamon of Deat=
h situation. In case if base class is like "interface" (see above), then vi=
rtual inheritance have no side effects: we do not need to make pointer calc=
ulations for data members, because there is no any of them. But, virtual in=
heritance forbid use of static_cast:</div>



<div><br></div><div><pre style=3D"margin-bottom:10px;padding:5px;font-size:=
14px;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'L=
ucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mo=
no','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px=
;word-wrap:normal;color:rgb(0,0,0);line-height:18px"><code style=3D"font-fa=
mily:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans =
Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:=
inherit"><span style=3D"background-color:transparent;color:rgb(0,0,139)">cl=
ass</span><span style=3D"background-color:transparent"> A </span><span styl=
e=3D"background-color:transparent">{};</span><span style=3D"background-colo=
r:transparent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> B </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">
</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> C </span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">virtual</span><span style=3D"background-color:transparent"> </span=
><span style=3D"background-color:transparent;color:rgb(0,0,139)">public</sp=
an><span style=3D"background-color:transparent"> A </span><span style=3D"ba=
ckground-color:transparent">{};</span><span style=3D"background-color:trans=
parent">

</span><span style=3D"background-color:transparent;color:rgb(0,0,139)">clas=
s</span><span style=3D"background-color:transparent"> D</span><span style=
=3D"background-color:transparent">:</span><span style=3D"background-color:t=
ransparent"> </span><span style=3D"background-color:transparent;color:rgb(0=
,0,139)">public</span><span style=3D"background-color:transparent"> B</span=
><span style=3D"background-color:transparent">,</span><span style=3D"backgr=
ound-color:transparent"> </span><span style=3D"background-color:transparent=
;color:rgb(0,0,139)">public</span><span style=3D"background-color:transpare=
nt"> C </span><span style=3D"background-color:transparent">{};</span></code=
></pre>



<pre style=3D"margin-bottom:10px;padding:5px;font-size:14px;background-colo=
r:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Libe=
ration Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',mo=
nospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;co=
lor:rgb(0,0,0);line-height:18px"><span style=3D"font-family:Arial,'Liberati=
on Sans','DejaVu Sans',sans-serif">A* a;</span></pre><pre style=3D"margin-b=
ottom:10px;padding:5px;font-size:14px;background-color:rgb(238,238,238);fon=
t-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu S=
ans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow=
:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-he=
ight:18px"><span style=3D"font-family:Arial,'Liberation Sans','DejaVu Sans'=
,sans-serif">D* d =3D static_cast&lt;D*&gt;(a); //&nbsp;error: cannot conve=
rt from base =E2=80=98A=E2=80=99 to derived type =E2=80=98D=E2=80=99 via vi=
rtual base =E2=80=98A=E2=80=99</span></pre><p style=3D"font-size:small;line=
-height:normal;font-family:arial;clear:both">



<span style=3D"color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu=
 Sans',sans-serif;font-size:13px;line-height:18px">That's why, now we can't=
 imitate interfaces from C# with existing tools. Introducing interfaces wil=
l allow use diamond inheritance for them without any troubles.</span><br>



</p></div><div><br></div></div>

<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 e=
mail to <a>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>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" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<u></u>iso<u></u><u></u><wbr>cpp.org/gr=
oup/std-<u></u>proposals/</a>.<br>
</blockquote></div>
</blockquote></div>

<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 e=
mail to <a>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>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" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<u></u>iso<u></u><wbr>cpp.org/group/std=
-<u></u>proposals/</a>.<br>
</div>
</blockquote></div>

<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 e=
mail to <a>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>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" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<u></u>iso<wbr>cpp.org/group/std-<u></u=
>proposals/</a>.<br>
</blockquote></div>
</blockquote></div></div></div>

<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 e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
ynNVZgwONf0J" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">std-proposal...@<wbr>isocpp.or=
g</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"ynNVZgwONf0J" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;">s=
td-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" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</blockquote></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_28_1828355960.1407670080763--

.


Author: Stack Machine <stackmachine@hotmail.com>
Date: Tue, 12 Aug 2014 04:57:54 -0700 (PDT)
Raw View
------=_Part_3869_1393653174.1407844675044
Content-Type: text/plain; charset=UTF-8

One thing I'd like to be able to see is being able to implement a virtual
function by inheriting from another class.
Example:
struct Animal
{
    virtual void greet() = 0;
};

struct DogHelper : virtual Animal
{
    virtual void greet() override final
    {
        std::cout << "*bark*";
    }
};

struct Dog : virtual Animal, private DogHelper
{};
The problem is that virtual is needed every time a class "implements"
Animal, and implicit casts from Dog to Animal won't work, because the
compiler does not know which path of the hierarchy I want to cast through.
(it doesn't actually matter)
Interfaces can solve both of these problems.

--

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

<div dir=3D"ltr">One thing I'd like to be able to see is being able to impl=
ement a virtual function by inheriting from another class.<br>Example:<br><=
div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); bo=
rder-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; wor=
d-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettypri=
nt"><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #606;" class=3D"styled-by-prettify">Animal</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: #000=
;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">virtual</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> greet</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #066;" class=3D"styled-by-prettify">0</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: #000;"=
 class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">DogHelper</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">virtual</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #606;" class=3D"styled-by-prettify">Animal</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: #000=
;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">virtual</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> greet</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">override</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">final</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &n=
bsp; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nb=
sp; &nbsp; &nbsp; std</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">cout </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&l=
t;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #080;" class=3D"styled-by-prettify">"*bark*"</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </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 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: #0=
08;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D=
"styled-by-prettify">Dog</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">virtual</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #606;" class=3D"styled-by-prettify">Animal</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">private</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"sty=
led-by-prettify">DogHelper</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">{};</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br></span></div></code></div>The problem is that virtual is needed ever=
y time a class "implements" Animal, and implicit casts from Dog to Animal w=
on't work, because the compiler does not know which path of the hierarchy I=
 want to cast through. (it doesn't actually matter)<br>Interfaces can solve=
 both of these problems.<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&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_3869_1393653174.1407844675044--

.


Author: Jean-Marc Bourguet <jm.bourguet@gmail.com>
Date: Fri, 15 Aug 2014 03:55:13 -0700 (PDT)
Raw View
------=_Part_194_210448781.1408100113367
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Le mardi 12 ao=C3=BBt 2014 13:57:55 UTC+2, Stack Machine a =C3=A9crit :
>
> The problem is that virtual is needed every time a class "implements"=20
> Animal, and implicit casts from Dog to Animal won't work, because the=20
> compiler does not know which path of the hierarchy I want to cast through=
..=20
> (it doesn't actually matter)
> Interfaces can solve both of these problems.
>

So you want a way to ensure that a class is implicitly and always inherited=
=20
from virtually?

Yours,

--=20
Jean-Marc=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/.

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

<div dir=3D"ltr">Le mardi 12 ao=C3=BBt 2014 13:57:55 UTC+2, Stack Machine a=
 =C3=A9crit&nbsp;:<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">The problem is that virtual is needed every time a class "implements" =
Animal, and implicit casts from Dog to Animal won't work, because the compi=
ler does not know which path of the hierarchy I want to cast through. (it d=
oesn't actually matter)<br>Interfaces can solve both of these problems.<br>=
</div></blockquote><div><br>So you want a way to ensure that a class is imp=
licitly and always inherited from virtually?<br><br>Yours,<br><br>-- <br>Je=
an-Marc <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&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_194_210448781.1408100113367--

.