Topic: inheritance restriction
Author: Vishal Oza <vickoza@gmail.com>
Date: Tue, 26 Jul 2016 20:57:21 -0700 (PDT)
Raw View
------=_Part_4974_239774857.1469591841086
Content-Type: multipart/alternative;
boundary="----=_Part_4975_1571010359.1469591841086"
------=_Part_4975_1571010359.1469591841086
Content-Type: text/plain; charset=UTF-8
I was think that C++ multiple inheritance is a feature that allow to build
smaller base class at the potential cost of diamond inheritance but in
language like C# or Java this is only partially avoid
this through having multiple interfaces but this only lessen the problem
and does not solve the problem and it also creates more boilerplate code.
It is up to the author of the class. If two different interfaces share
functions with the same name and input parameter but difference return type
or the same name, input parameter and return type
but difference responsibilities you still have the diamond inheritance
problem.
What I purpose is a restriction of inheritance. The best example I can
think of is the stream class (I also suggest not to do this as it might
break existing code in the current standard library) for this class you
have inputstream and outputstream. The inputstream class only handles input
and outputstream only handle output. You should *not* have a class the
handle but input and output in the same class but you might have a class
stringstream the works with string data or netstream the work with network
data and derived classes of both inputstream and outputstream want to
inherit form the new classes.
My proposal would look like something like
class outputstream;
class inputstream:!outputstream
{
....
};
class netinputstream :public inputstream, public netstream
{
....
};
class netoutputstream :public outputstream, public netstream
{
....
};
//this code will generate an error
class gnetstream:public netinputstream,public netoutputstream
{
....
};
I an not sure if this would be part of concept or a unique proposal by
itself
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/d8a118f9-3502-4ef2-aa1a-30182266e31e%40isocpp.org.
------=_Part_4975_1571010359.1469591841086
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div style=3D"text-align: left;"><span style=3D"line-heigh=
t: 17px;">I was think that C++ multiple inheritance is a feature that allow=
to build smaller base class at the=C2=A0potential=C2=A0cost of=C2=A0diamon=
d=C2=A0inheritance=C2=A0but in language like C# or Java this is only=C2=A0p=
artially avoid this=C2=A0through=C2=A0having=C2=A0multiple=C2=A0interfaces =
but this only lessen the problem and does not solve the problem and it also=
creates more boilerplate code. It is up to the=C2=A0author=C2=A0of the cla=
ss. If two=C2=A0different=C2=A0interfaces share functions with=C2=A0the sam=
e name and input parameter but=C2=A0difference=C2=A0return type or the same=
name, input parameter and return type but=C2=A0difference=C2=A0responsibil=
ities you still have the=C2=A0</span><span style=3D"line-height: 17px;">dia=
mond=C2=A0inheritance problem.</span></div><div><span style=3D"line-height:=
17px;"><br></span></div><div><span style=3D"line-height: 17px;">What I pur=
pose is a restriction=C2=A0of=C2=A0inheritance. The best example I can thin=
k of is the stream class (I also suggest not to do this as it might break e=
xisting code in the current standard library) for this class you have input=
stream and outputstream. The inputstream class only handles input and outpu=
tstream only handle output. You should </span><b style=3D"line-height: 17px=
;">not</b><span style=3D"line-height: 17px;">=C2=A0have a class the handle =
but input and output in the same class but you might have a class stringstr=
eam the works with string data or netstream the work with network data and=
=C2=A0derived=C2=A0classes of both=C2=A0inputstream</span><span style=3D"li=
ne-height: 17px;">=C2=A0and=C2=A0</span><span style=3D"line-height: 17px;">=
outputstream want to inherit form the new classes.</span></div><div><span s=
tyle=3D"line-height: 17px;"><br></span></div><div><span style=3D"line-heigh=
t: 17px;">My=C2=A0proposal=C2=A0would look like something like</span></div>=
<div><span style=3D"line-height: 17px;"><div class=3D"prettyprint" style=3D=
"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-co=
lor: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subpret=
typrint"><font color=3D"#660066"><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span></font><span style=3D"font-family: Arial, Helvetica, san=
s-serif; background-color: rgb(255, 255, 255);"><span style=3D"color: #000;=
" class=3D"styled-by-prettify">outputstream</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span></span><span style=3D"font-family: Arial, Helvetica, s=
ans-serif; background-color: rgb(255, 255, 255);"><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">inputstream</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">:!</span></span><span style=3D"color: rgb=
(0, 0, 0); font-family: Arial, Helvetica, sans-serif; background-color: rgb=
(255, 255, 255);"><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>outputstream<br></span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span><span style=3D"color: #660;" class=3D"styled-by-prettify">...</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">class</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> netinputstream </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">public</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span></span><span style=3D"color: rgb(0, 0,=
0); font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, =
255, 255);"><span style=3D"color: #000;" class=3D"styled-by-prettify">input=
stream</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">public</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> netstream<br></span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">...</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span></span><span style=3D"color: rgb(0, 0, 0); font=
-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255)=
;"><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">class</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> netoutputstream </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">public</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> out</span></span><span style=
=3D"color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; backgro=
und-color: rgb(255, 255, 255);"><span style=3D"color: #000;" class=3D"style=
d-by-prettify">putstream</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">publ=
ic</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> netstre=
am<br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">...</span><span sty=
le=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: #80=
0;" class=3D"styled-by-prettify">//this code will generate an error</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">class</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> gnetstream</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">public</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span></span><span style=3D"color: rgb=
(0, 0, 0); font-family: Arial, Helvetica, sans-serif; background-color: rgb=
(255, 255, 255);"><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>netinputstream</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">,</span><span style=3D"color: #008;" class=3D"styled-by-prettify">publ=
ic</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
</span><span style=3D"color: rgb(0, 0, 0); font-family: Arial, Helvetica, s=
ans-serif; background-color: rgb(255, 255, 255);"><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">netoutputstream<br></span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">...</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">};</span></span></div></code></div><div><span style=3D"line-h=
eight: 17px;"><br></span></div>I an not sure if this would be part of conce=
pt or a unique proposal by itself<br><br></span></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/d8a118f9-3502-4ef2-aa1a-30182266e31e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d8a118f9-3502-4ef2-aa1a-30182266e31e=
%40isocpp.org</a>.<br />
------=_Part_4975_1571010359.1469591841086--
------=_Part_4974_239774857.1469591841086--
.
Author: szollosi.lorand@gmail.com
Date: Thu, 28 Jul 2016 07:39:39 -0700 (PDT)
Raw View
------=_Part_561_718636468.1469716779248
Content-Type: multipart/alternative;
boundary="----=_Part_562_1173799312.1469716779249"
------=_Part_562_1173799312.1469716779249
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Hi,
Did you try to do this by an error method having a combination of=20
*static_assert(),* *std::enable_if<>, std::is_base_of<>*? You can put it in=
=20
a macro if you don't like the verbosity of this solution.
(That said, *final* classes went live as well and there was a well-known,=
=20
similar workaround for them, too.)
Regards,
-lorro
2016. j=C3=BAlius 27., szerda 5:57:21 UTC+2 id=C5=91pontban Vishal Oza a k=
=C3=B6vetkez=C5=91t=20
=C3=ADrta:
>
> I was think that C++ multiple inheritance is a feature that allow to buil=
d=20
> smaller base class at the potential cost of diamond inheritance but in=20
> language like C# or Java this is only partially avoid=20
> this through having multiple interfaces but this only lessen the problem=
=20
> and does not solve the problem and it also creates more boilerplate code.=
=20
> It is up to the author of the class. If two different interfaces share=20
> functions with the same name and input parameter but difference return ty=
pe=20
> or the same name, input parameter and return type=20
> but difference responsibilities you still have the diamond inheritance=20
> problem.
>
> What I purpose is a restriction of inheritance. The best example I can=20
> think of is the stream class (I also suggest not to do this as it might=
=20
> break existing code in the current standard library) for this class you=
=20
> have inputstream and outputstream. The inputstream class only handles inp=
ut=20
> and outputstream only handle output. You should *not* have a class the=20
> handle but input and output in the same class but you might have a class=
=20
> stringstream the works with string data or netstream the work with networ=
k=20
> data and derived classes of both inputstream and outputstream want to=20
> inherit form the new classes.
>
> My proposal would look like something like
> class outputstream;
> class inputstream:!outputstream
> {
> ...
> };
> class netinputstream :public inputstream, public netstream
> {
> ...
> };
>
> class netoutputstream :public outputstream, public netstream
> {
> ...
> };
>
> //this code will generate an error
> class gnetstream:public netinputstream,public netoutputstream
> {
> ...
> };
>
> I an not sure if this would be part of concept or a unique proposal by=20
> itself
>
>
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/d717b85f-52dd-48ff-b2d3-680d971ad15d%40isocpp.or=
g.
------=_Part_562_1173799312.1469716779249
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hi,<br><br>Did you try to do this by an error method havin=
g a combination of <i>static_assert(),</i> <i>std::enable_if<>, std::=
is_base_of<></i>? You can put it in a macro if you don't like the=
verbosity of this solution.<br>(That said, <i>final</i> classes went live =
as well and there was a well-known, similar workaround for them, too.)<br><=
br>Regards,<br>-lorro<br><br>2016. j=C3=BAlius 27., szerda 5:57:21 UTC+2 id=
=C5=91pontban Vishal Oza a k=C3=B6vetkez=C5=91t =C3=ADrta:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><div dir=3D"ltr"><div style=3D"text-align:left"=
><span style=3D"line-height:17px">I was think that C++ multiple inheritance=
is a feature that allow to build smaller base class at the=C2=A0potential=
=C2=A0cost of=C2=A0diamond=C2=A0inheritance=C2=A0but in language like C# or=
Java this is only=C2=A0partially avoid this=C2=A0through=C2=A0having=C2=A0=
multiple=C2=A0<wbr>interfaces but this only lessen the problem and does not=
solve the problem and it also creates more boilerplate code. It is up to t=
he=C2=A0author=C2=A0of the class. If two=C2=A0different=C2=A0interfaces sha=
re functions with=C2=A0the same name and input parameter but=C2=A0differenc=
e=C2=A0return type or the same name, input parameter and return type but=C2=
=A0difference=C2=A0<wbr>responsibilities you still have the=C2=A0</span><sp=
an style=3D"line-height:17px">diamond=C2=A0inheritance problem.</span></div=
><div><span style=3D"line-height:17px"><br></span></div><div><span style=3D=
"line-height:17px">What I purpose is a restriction=C2=A0of=C2=A0inheritance=
.. The best example I can think of is the stream class (I also suggest not t=
o do this as it might break existing code in the current standard library) =
for this class you have inputstream and outputstream. The inputstream class=
only handles input and outputstream only handle output. You should </span>=
<b style=3D"line-height:17px">not</b><span style=3D"line-height:17px">=C2=
=A0have a class the handle but input and output in the same class but you m=
ight have a class stringstream the works with string data or netstream the =
work with network data and=C2=A0derived=C2=A0classes of both=C2=A0inputstre=
am</span><span style=3D"line-height:17px">=C2=A0and=C2=A0</span><span style=
=3D"line-height:17px">outputstr<wbr>eam want to inherit form the new classe=
s.</span></div><div><span style=3D"line-height:17px"><br></span></div><div>=
<span style=3D"line-height:17px">My=C2=A0proposal=C2=A0would look like some=
thing like</span></div><div><span style=3D"line-height:17px"><div style=3D"=
border:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb=
(250,250,250)"><code><div><font color=3D"#660066"><span style=3D"color:#008=
">class</span><span style=3D"color:#000"> </span></font><span style=3D"font=
-family:Arial,Helvetica,sans-serif;background-color:rgb(255,255,255)"><span=
style=3D"color:#000">outputstream</span><span style=3D"color:#660">;</span=
><span style=3D"color:#000"><br></span><span style=3D"color:#008">class</sp=
an><span style=3D"color:#000"> </span></span><span style=3D"font-family:Ari=
al,Helvetica,sans-serif;background-color:rgb(255,255,255)"><span style=3D"c=
olor:#000">inputstream</span><span style=3D"color:#660">:!</span></span><sp=
an style=3D"color:rgb(0,0,0);font-family:Arial,Helvetica,sans-serif;backgro=
und-color:rgb(255,255,255)"><span style=3D"color:#000">outputstream<br></sp=
an><span style=3D"color:#660">{</span><span style=3D"color:#000"><br></span=
><span style=3D"color:#660">...</span><span style=3D"color:#000"><br></span=
><span style=3D"color:#660">};</span><span style=3D"color:#000"><br></span>=
<span style=3D"color:#008">class</span><span style=3D"color:#000"> netinput=
stream </span><span style=3D"color:#660">:</span><span style=3D"color:#008"=
>public</span><span style=3D"color:#000"> </span></span><span style=3D"colo=
r:rgb(0,0,0);font-family:Arial,Helvetica,sans-serif;background-color:rgb(25=
5,255,255)"><span style=3D"color:#000">inputstream</span><span style=3D"col=
or:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#0=
08">public</span><span style=3D"color:#000"> netstream<br></span><span styl=
e=3D"color:#660">{</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#660">...</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#660">};</span><span style=3D"color:#000"><br></span></span><span=
style=3D"color:rgb(0,0,0);font-family:Arial,Helvetica,sans-serif;backgroun=
d-color:rgb(255,255,255)"><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">class</span><span style=3D"color:#000"> netoutputstream </s=
pan><span style=3D"color:#660">:</span><span style=3D"color:#008">public</s=
pan><span style=3D"color:#000"> out</span></span><span style=3D"color:rgb(0=
,0,0);font-family:Arial,Helvetica,sans-serif;background-color:rgb(255,255,2=
55)"><span style=3D"color:#000">putstream</span><span style=3D"color:#660">=
,</span><span style=3D"color:#000"> </span><span style=3D"color:#008">publi=
c</span><span style=3D"color:#000"> netstream<br></span><span style=3D"colo=
r:#660">{</span><span style=3D"color:#000"><br></span><span style=3D"color:=
#660">...</span><span style=3D"color:#000"><br></span><span style=3D"color:=
#660">};</span><span style=3D"color:#000"><br><br></span><span style=3D"col=
or:#800">//this code will generate an error</span><span style=3D"color:#000=
"><br></span><span style=3D"color:#008">class</span><span style=3D"color:#0=
00"> gnetstream</span><span style=3D"color:#660">:</span><span style=3D"col=
or:#008">public</span><span style=3D"color:#000"> </span></span><span style=
=3D"color:rgb(0,0,0);font-family:Arial,Helvetica,sans-serif;background-colo=
r:rgb(255,255,255)"><span style=3D"color:#000">netinputstream</span><span s=
tyle=3D"color:#660">,</span><span style=3D"color:#008">public</span><span s=
tyle=3D"color:#000"> </span></span><span style=3D"color:rgb(0,0,0);font-fam=
ily:Arial,Helvetica,sans-serif;background-color:rgb(255,255,255)"><span sty=
le=3D"color:#000">netoutputstream<br></span><span style=3D"color:#660">{</s=
pan><span style=3D"color:#000"><br></span><span style=3D"color:#660">...</s=
pan><span style=3D"color:#000"><br></span><span style=3D"color:#660">};</sp=
an></span></div></code></div><div><span style=3D"line-height:17px"><br></sp=
an></div>I an not sure if this would be part of concept or a unique proposa=
l by itself<br><br></span></div></div></blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/d717b85f-52dd-48ff-b2d3-680d971ad15d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d717b85f-52dd-48ff-b2d3-680d971ad15d=
%40isocpp.org</a>.<br />
------=_Part_562_1173799312.1469716779249--
------=_Part_561_718636468.1469716779248--
.
Author: szollosi.lorand@gmail.com
Date: Thu, 4 Aug 2016 10:35:35 -0700 (PDT)
Raw View
------=_Part_849_833470813.1470332135489
Content-Type: multipart/alternative;
boundary="----=_Part_850_225543723.1470332135490"
------=_Part_850_225543723.1470332135490
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Hmm, after doing some checks, I've found that it's far from trivial. In=20
fact, I could only come up w/ a cooperative solution (descendant class must=
=20
be aware of the pattern and cooperate, which is kind of killing the=20
purpose). This is as long as we don't have conditional template friend=20
class declarations. Thus I'm for the language-based solution.
Thanks,
-lorro
2016. j=C3=BAlius 28., cs=C3=BCt=C3=B6rt=C3=B6k 16:39:39 UTC+2 id=C5=91pont=
ban szollos...@gmail.com=20
a k=C3=B6vetkez=C5=91t =C3=ADrta:
>
> Hi,
>
> Did you try to do this by an error method having a combination of=20
> *static_assert(),* *std::enable_if<>, std::is_base_of<>*? You can put it=
=20
> in a macro if you don't like the verbosity of this solution.
> (That said, *final* classes went live as well and there was a well-known,=
=20
> similar workaround for them, too.)
>
> Regards,
> -lorro
>
> 2016. j=C3=BAlius 27., szerda 5:57:21 UTC+2 id=C5=91pontban Vishal Oza a =
k=C3=B6vetkez=C5=91t=20
> =C3=ADrta:
>>
>> I was think that C++ multiple inheritance is a feature that allow to=20
>> build smaller base class at the potential cost of diamond inheritance bu=
t=20
>> in language like C# or Java this is only partially avoid=20
>> this through having multiple interfaces but this only lessen the problem=
=20
>> and does not solve the problem and it also creates more boilerplate code=
..=20
>> It is up to the author of the class. If two different interfaces share=
=20
>> functions with the same name and input parameter but difference return t=
ype=20
>> or the same name, input parameter and return type=20
>> but difference responsibilities you still have the diamond inheritance=
=20
>> problem.
>>
>> What I purpose is a restriction of inheritance. The best example I can=
=20
>> think of is the stream class (I also suggest not to do this as it might=
=20
>> break existing code in the current standard library) for this class you=
=20
>> have inputstream and outputstream. The inputstream class only handles in=
put=20
>> and outputstream only handle output. You should *not* have a class the=
=20
>> handle but input and output in the same class but you might have a class=
=20
>> stringstream the works with string data or netstream the work with netwo=
rk=20
>> data and derived classes of both inputstream and outputstream want to=20
>> inherit form the new classes.
>>
>> My proposal would look like something like
>> class outputstream;
>> class inputstream:!outputstream
>> {
>> ...
>> };
>> class netinputstream :public inputstream, public netstream
>> {
>> ...
>> };
>>
>> class netoutputstream :public outputstream, public netstream
>> {
>> ...
>> };
>>
>> //this code will generate an error
>> class gnetstream:public netinputstream,public netoutputstream
>> {
>> ...
>> };
>>
>> I an not sure if this would be part of concept or a unique proposal by=
=20
>> itself
>>
>>
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/a7c50766-b1cb-48c9-b89b-d47495dc5ac4%40isocpp.or=
g.
------=_Part_850_225543723.1470332135490
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hmm, after doing some checks, I've found that it's=
far from trivial. In fact, I could only come up w/ a cooperative solution =
(descendant class must be aware of the pattern and cooperate, which is kind=
of killing the purpose). This is as long as we don't have conditional =
template friend class declarations. Thus I'm for the language-based sol=
ution.<br><br>Thanks,<br>-lorro<br><br>2016. j=C3=BAlius 28., cs=C3=BCt=C3=
=B6rt=C3=B6k 16:39:39 UTC+2 id=C5=91pontban szollos...@gmail.com a k=C3=B6v=
etkez=C5=91t =C3=ADrta:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div di=
r=3D"ltr">Hi,<br><br>Did you try to do this by an error method having a com=
bination of <i>static_assert(),</i> <i>std::enable_if<>, std::is_base=
_of<></i>? You can put it in a macro if you don't like the verbos=
ity of this solution.<br>(That said, <i>final</i> classes went live as well=
and there was a well-known, similar workaround for them, too.)<br><br>Rega=
rds,<br>-lorro<br><br>2016. j=C3=BAlius 27., szerda 5:57:21 UTC+2 id=C5=91p=
ontban Vishal Oza a k=C3=B6vetkez=C5=91t =C3=ADrta:<blockquote class=3D"gma=
il_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;pa=
dding-left:1ex"><div dir=3D"ltr"><div style=3D"text-align:left"><span style=
=3D"line-height:17px">I was think that C++ multiple inheritance is a featur=
e that allow to build smaller base class at the=C2=A0potential=C2=A0cost of=
=C2=A0diamond=C2=A0inheritance=C2=A0but in language like C# or Java this is=
only=C2=A0partially avoid this=C2=A0through=C2=A0having=C2=A0multiple=C2=
=A0<wbr>interfaces but this only lessen the problem and does not solve the =
problem and it also creates more boilerplate code. It is up to the=C2=A0aut=
hor=C2=A0of the class. If two=C2=A0different=C2=A0interfaces share function=
s with=C2=A0the same name and input parameter but=C2=A0difference=C2=A0retu=
rn type or the same name, input parameter and return type but=C2=A0differen=
ce=C2=A0<wbr>responsibilities you still have the=C2=A0</span><span style=3D=
"line-height:17px">diamond=C2=A0inheritance problem.</span></div><div><span=
style=3D"line-height:17px"><br></span></div><div><span style=3D"line-heigh=
t:17px">What I purpose is a restriction=C2=A0of=C2=A0inheritance. The best =
example I can think of is the stream class (I also suggest not to do this a=
s it might break existing code in the current standard library) for this cl=
ass you have inputstream and outputstream. The inputstream class only handl=
es input and outputstream only handle output. You should </span><b style=3D=
"line-height:17px">not</b><span style=3D"line-height:17px">=C2=A0have a cla=
ss the handle but input and output in the same class but you might have a c=
lass stringstream the works with string data or netstream the work with net=
work data and=C2=A0derived=C2=A0classes of both=C2=A0inputstream</span><spa=
n style=3D"line-height:17px">=C2=A0and=C2=A0</span><span style=3D"line-heig=
ht:17px">outputstr<wbr>eam want to inherit form the new classes.</span></di=
v><div><span style=3D"line-height:17px"><br></span></div><div><span style=
=3D"line-height:17px">My=C2=A0proposal=C2=A0would look like something like<=
/span></div><div><span style=3D"line-height:17px"><div style=3D"border:1px =
solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,25=
0)"><code><div><font color=3D"#660066"><span style=3D"color:#008">class</sp=
an><span style=3D"color:#000"> </span></font><span style=3D"font-family:Ari=
al,Helvetica,sans-serif;background-color:rgb(255,255,255)"><span style=3D"c=
olor:#000">outputstream</span><span style=3D"color:#660">;</span><span styl=
e=3D"color:#000"><br></span><span style=3D"color:#008">class</span><span st=
yle=3D"color:#000"> </span></span><span style=3D"font-family:Arial,Helvetic=
a,sans-serif;background-color:rgb(255,255,255)"><span style=3D"color:#000">=
inputstream</span><span style=3D"color:#660">:!</span></span><span style=3D=
"color:rgb(0,0,0);font-family:Arial,Helvetica,sans-serif;background-color:r=
gb(255,255,255)"><span style=3D"color:#000">outputstream<br></span><span st=
yle=3D"color:#660">{</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#660">...</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#660">};</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">class</span><span style=3D"color:#000"> netinputstream </sp=
an><span style=3D"color:#660">:</span><span style=3D"color:#008">public</sp=
an><span style=3D"color:#000"> </span></span><span style=3D"color:rgb(0,0,0=
);font-family:Arial,Helvetica,sans-serif;background-color:rgb(255,255,255)"=
><span style=3D"color:#000">inputstream</span><span style=3D"color:#660">,<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#008">public<=
/span><span style=3D"color:#000"> netstream<br></span><span style=3D"color:=
#660">{</span><span style=3D"color:#000"><br></span><span style=3D"color:#6=
60">...</span><span style=3D"color:#000"><br></span><span style=3D"color:#6=
60">};</span><span style=3D"color:#000"><br></span></span><span style=3D"co=
lor:rgb(0,0,0);font-family:Arial,Helvetica,sans-serif;background-color:rgb(=
255,255,255)"><span style=3D"color:#000"><br></span><span style=3D"color:#0=
08">class</span><span style=3D"color:#000"> netoutputstream </span><span st=
yle=3D"color:#660">:</span><span style=3D"color:#008">public</span><span st=
yle=3D"color:#000"> out</span></span><span style=3D"color:rgb(0,0,0);font-f=
amily:Arial,Helvetica,sans-serif;background-color:rgb(255,255,255)"><span s=
tyle=3D"color:#000">putstream</span><span style=3D"color:#660">,</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#008">public</span><spa=
n style=3D"color:#000"> netstream<br></span><span style=3D"color:#660">{</s=
pan><span style=3D"color:#000"><br></span><span style=3D"color:#660">...</s=
pan><span style=3D"color:#000"><br></span><span style=3D"color:#660">};</sp=
an><span style=3D"color:#000"><br><br></span><span style=3D"color:#800">//t=
his code will generate an error</span><span style=3D"color:#000"><br></span=
><span style=3D"color:#008">class</span><span style=3D"color:#000"> gnetstr=
eam</span><span style=3D"color:#660">:</span><span style=3D"color:#008">pub=
lic</span><span style=3D"color:#000"> </span></span><span style=3D"color:rg=
b(0,0,0);font-family:Arial,Helvetica,sans-serif;background-color:rgb(255,25=
5,255)"><span style=3D"color:#000">netinputstream</span><span style=3D"colo=
r:#660">,</span><span style=3D"color:#008">public</span><span style=3D"colo=
r:#000"> </span></span><span style=3D"color:rgb(0,0,0);font-family:Arial,He=
lvetica,sans-serif;background-color:rgb(255,255,255)"><span style=3D"color:=
#000">netoutputstream<br></span><span style=3D"color:#660">{</span><span st=
yle=3D"color:#000"><br></span><span style=3D"color:#660">...</span><span st=
yle=3D"color:#000"><br></span><span style=3D"color:#660">};</span></span></=
div></code></div><div><span style=3D"line-height:17px"><br></span></div>I a=
n not sure if this would be part of concept or a unique proposal by itself<=
br><br></span></div></div></blockquote></div></blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a7c50766-b1cb-48c9-b89b-d47495dc5ac4%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a7c50766-b1cb-48c9-b89b-d47495dc5ac4=
%40isocpp.org</a>.<br />
------=_Part_850_225543723.1470332135490--
------=_Part_849_833470813.1470332135489--
.