Topic: pure virtual functions
Author: Columbo <r.hl@gmx.net>
Date: Mon, 20 Apr 2015 09:52:59 -0700 (PDT)
Raw View
------=_Part_3224_81129756.1429548779922
Content-Type: multipart/alternative;
boundary="----=_Part_3225_2043176894.1429548779922"
------=_Part_3225_2043176894.1429548779922
Content-Type: text/plain; charset=UTF-8
Is there an objective reason that
virtual void f() = 0 {};
virtual void g() = 0 = default;
should not be allowed? Is it possible to alter the definition of
*function-definition* to allow *pure-specifiers*? It seems to me that
parsers are fine with it,
and it's a hassle to define pure virtual destructors outside a class or
class template. The changes necessary seem rather straightforward:
Change the grammar and make one or two semantical paragraphs (i.e.
forbidding the use of *pure-specifier*s for anything but in-class virtual
member function definitions).
--
---
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_3225_2043176894.1429548779922
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Is there an objective reason that <br><div class=3D"pretty=
print" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187=
, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-word;=
"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">virtual</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> f</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: #660;" class=3D"styled-by-pretti=
fy">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{};</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">virtual</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> g</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">default</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span></div></code></div>should not be allowed? Is=
it possible to alter the definition of <i>function-definition</i> to allow=
<i>pure-specifiers</i>? It seems to me that parsers are fine with it,<br>a=
nd it's a hassle to define pure virtual destructors outside a class or clas=
s template. The changes necessary seem rather straightforward:<br>Change th=
e grammar and make one or two semantical paragraphs (i.e. forbidding the us=
e of <i>pure-specifier</i>s for anything but in-class virtual member functi=
on definitions).<br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <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_3225_2043176894.1429548779922--
------=_Part_3224_81129756.1429548779922--
.
Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Thu, 23 Apr 2015 15:43:40 +0100
Raw View
--001a113d3082399e310514654ef8
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Mon, Apr 20, 2015 at 5:52 PM, Columbo <r.hl@gmx.net> wrote:
> Is there an objective reason that
> virtual void f() =3D 0 {};
> virtual void g() =3D 0 =3D default;
>
I don=E2=80=99t understand what you would expect these definitions to do. =
To me,
the =E2=80=98=3D 0=E2=80=99 indicating the functions are pure virtual and t=
hus have no body,
conflict with the {} or =3Ddefault parts, which state otherwise. Please
could you elaborate.
> should not be allowed? Is it possible to alter the definition of
> *function-definition* to allow *pure-specifiers*? It seems to me that
> parsers are fine with it,
> and it's a hassle to define pure virtual destructors outside a class or
> class template. The changes necessary seem rather straightforward:
> Change the grammar and make one or two semantical paragraphs (i.e.
> forbidding the use of *pure-specifier*s for anything but in-class virtual
> member function definitions).
>
> --
>
> ---
> 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/.
--001a113d3082399e310514654ef8
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div class=3D"gmail_quote">On Mon, Apr 20, 2015 at 5:52 PM, Columbo <span d=
ir=3D"ltr"><<a href=3D"mailto:r.hl@gmx.net" target=3D"_blank">r.hl@gmx.n=
et</a>></span> wrote:<br>
<blockquote style=3D"BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PA=
DDING-LEFT:1ex" class=3D"gmail_quote">
<div dir=3D"ltr">Is there an objective reason that <br>
<div style=3D"BORDER-BOTTOM:rgb(187,187,187) 1px solid;BORDER-LEFT:rgb(187,=
187,187) 1px solid;BACKGROUND-COLOR:rgb(250,250,250);WORD-WRAP:break-word;B=
ORDER-TOP:rgb(187,187,187) 1px solid;BORDER-RIGHT:rgb(187,187,187) 1px soli=
d"><code>
<div><span style=3D"COLOR:#000">=C2=A0 =C2=A0 </span><span style=3D"COLOR:#=
008">virtual</span><span style=3D"COLOR:#000"> </span><span style=3D"COLOR:=
#008">void</span><span style=3D"COLOR:#000"> f</span><span style=3D"COLOR:#=
660">()</span><span style=3D"COLOR:#000"> </span><span style=3D"COLOR:#660"=
>=3D</span><span style=3D"COLOR:#000"> </span><span style=3D"COLOR:#066">0<=
/span><span style=3D"COLOR:#000"> </span><span style=3D"COLOR:#660">{};</sp=
an><span style=3D"COLOR:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"COLOR=
:#008">virtual</span><span style=3D"COLOR:#000"> </span><span style=3D"COLO=
R:#008">void</span><span style=3D"COLOR:#000"> g</span><span style=3D"COLOR=
:#660">()</span><span style=3D"COLOR:#000"> </span><span style=3D"COLOR:#66=
0">=3D</span><span style=3D"COLOR:#000"> </span><span style=3D"COLOR:#066">=
0</span><span style=3D"COLOR:#000"> </span><span style=3D"COLOR:#660">=3D</=
span><span style=3D"COLOR:#000"> </span><span style=3D"COLOR:#008">default<=
/span><span style=3D"COLOR:#660">;</span><span style=3D"COLOR:#000"><br></s=
pan></div></code></div></div></blockquote>
<div>=C2=A0</div>
<div>I don=E2=80=99t understand what you would expect these definitions to =
do.=C2=A0 To me, the =E2=80=98=3D 0=E2=80=99 indicating the functions are p=
ure virtual and thus have no body, conflict with the {} or =3Ddefault parts=
, which state otherwise.=C2=A0 Please could you elaborate.</div>
<div>=C2=A0</div>
<blockquote style=3D"BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PA=
DDING-LEFT:1ex" class=3D"gmail_quote">
<div dir=3D"ltr">should not be allowed? Is it possible to alter the definit=
ion of <i>function-definition</i> to allow <i>pure-specifiers</i>? It seems=
to me that parsers are fine with it,<br>and it's a hassle to define pu=
re virtual destructors outside a class or class template. The changes neces=
sary seem rather straightforward:<br>Change the grammar and make one or two=
semantical paragraphs (i.e. forbidding the use of <i>pure-specifier</i>s f=
or anything but in-class virtual member function definitions).<span class=
=3D"HOEnZb"><font color=3D"#888888"><br></font></span></div><span class=3D"=
HOEnZb"><font color=3D"#888888">
<p></p>-- <br><br>--- <br>You received this message because you are subscri=
bed to the Google Groups "ISO C++ Standard - Future Proposals" gr=
oup.<br>To unsubscribe from this group and stop receiving emails from it, s=
end an email to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" tar=
get=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"ht=
tp://groups.google.com/a/isocpp.org/group/std-proposals/" target=3D"_blank"=
>http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br></font>=
</span></blockquote></div><br>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <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 />
--001a113d3082399e310514654ef8--
.
Author: Columbo <r.hl@gmx.net>
Date: Thu, 23 Apr 2015 07:46:10 -0700 (PDT)
Raw View
------=_Part_189_8395851.1429800370434
Content-Type: multipart/alternative;
boundary="----=_Part_190_1522630702.1429800370434"
------=_Part_190_1522630702.1429800370434
Content-Type: text/plain; charset=UTF-8
(This is a double post. This thread did not appear until after I tried to
post it a second time.)
--
---
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_190_1522630702.1429800370434
Content-Type: text/html; charset=UTF-8
<div dir="ltr">(This is a double post. This thread did not appear until after I tried to post it a second time.)<br></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 email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />
------=_Part_190_1522630702.1429800370434--
------=_Part_189_8395851.1429800370434--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Thu, 23 Apr 2015 09:56:11 -0500
Raw View
--001a11c3ce1466fb490514657dee
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On 23 April 2015 at 09:43, Douglas Boffey <douglas.boffey@gmail.com> wrote:
> On Mon, Apr 20, 2015 at 5:52 PM, Columbo <r.hl@gmx.net> wrote:
>
>> Is there an objective reason that
>> virtual void f() =3D 0 {};
>> virtual void g() =3D 0 =3D default;
>>
>
> I don=E2=80=99t understand what you would expect these definitions to do.=
To me,
> the =E2=80=98=3D 0=E2=80=99 indicating the functions are pure virtual and=
thus have no body,
> conflict with the {} or =3Ddefault parts, which state otherwise. Please
> could you elaborate.
>
=3D 0 means that the base class is abstract *and* that the function must be
overridden by the time we have a concrete derived class.
{} or =3D default gives an implementation to that function, which, for
instance, may be called directly from a derived class.
They are not in conflict, and we can do that now.
Example:
struct Base {
virtual void Alpha() =3D 0;
};
void Base::Alpha() { std::cout << "Base\n"; }
struct Derived : Base {
void Alpha() override { std::cout << "Derived\n"; Base::Alpha(); }
};
--=20
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
--=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/.
--001a11c3ce1466fb490514657dee
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 2=
3 April 2015 at 09:43, Douglas Boffey <span dir=3D"ltr"><<a href=3D"mail=
to:douglas.boffey@gmail.com" target=3D"_blank">douglas.boffey@gmail.com</a>=
></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px=
0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);bor=
der-left-style:solid;padding-left:1ex"><div class=3D"gmail_quote"><span>On =
Mon, Apr 20, 2015 at 5:52 PM, Columbo <span dir=3D"ltr"><<a href=3D"mail=
to:r.hl@gmx.net" target=3D"_blank">r.hl@gmx.net</a>></span> wrote:<br>
<blockquote style=3D"border-left-color:rgb(204,204,204);border-left-width:1=
px;border-left-style:solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class=
=3D"gmail_quote">
<div dir=3D"ltr">Is there an objective reason that <br>
<div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;backgr=
ound-color:rgb(250,250,250)"><code>
<div><span style=3D"color:rgb(0,0,0)">=C2=A0 =C2=A0 </span><span style=3D"c=
olor:rgb(0,0,136)">virtual</span><span style=3D"color:rgb(0,0,0)"> </span><=
span style=3D"color:rgb(0,0,136)">void</span><span style=3D"color:rgb(0,0,0=
)"> f</span><span style=3D"color:rgb(102,102,0)">()</span><span style=3D"co=
lor:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">=3D</span><spa=
n style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,102,102)">0=
</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(10=
2,102,0)">{};</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 </sp=
an><span style=3D"color:rgb(0,0,136)">virtual</span><span style=3D"color:rg=
b(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">void</span><span style=
=3D"color:rgb(0,0,0)"> g</span><span style=3D"color:rgb(102,102,0)">()</spa=
n><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102=
,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"colo=
r:rgb(0,102,102)">0</span><span style=3D"color:rgb(0,0,0)"> </span><span st=
yle=3D"color:rgb(102,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> </=
span><span style=3D"color:rgb(0,0,136)">default</span><span style=3D"color:=
rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br></span></div><=
/code></div></div></blockquote>
<div>=C2=A0</div>
</span><div>I don=E2=80=99t understand what you would expect these definiti=
ons to do.=C2=A0 To me, the =E2=80=98=3D 0=E2=80=99 indicating the function=
s are pure virtual and thus have no body, conflict with the {} or =3Ddefaul=
t parts, which state otherwise.=C2=A0 Please could you elaborate.</div></di=
v></blockquote><div><br></div><div>=3D 0 means that the base class is abstr=
act <i>and</i> that the function must be overridden by the time we have a c=
oncrete derived class.</div><div><br></div><div>{} or =3D default gives an =
implementation to that function, which, for instance, may be called directl=
y from a derived class.</div><div><br></div><div>They are not in conflict, =
and we can do that now.</div><div><br></div><div>Example:</div><div><br></d=
iv><div><div><font face=3D"monospace, monospace" size=3D"1">struct Base {</=
font></div><div><font face=3D"monospace, monospace" size=3D"1">=C2=A0 =C2=
=A0 virtual void Alpha() =3D 0;</font></div><div><font face=3D"monospace, m=
onospace" size=3D"1">};</font></div><div><font face=3D"monospace, monospace=
" size=3D"1"><br></font></div><div><font face=3D"monospace, monospace" size=
=3D"1">void Base::Alpha() { std::cout << "Base\n"; }</font>=
</div><div><font face=3D"monospace, monospace" size=3D"1"><br></font></div>=
<div><font face=3D"monospace, monospace" size=3D"1">struct Derived : Base {=
</font></div><div><font face=3D"monospace, monospace" size=3D"1">=C2=A0 =C2=
=A0 void Alpha() override { std::cout << "Derived\n"; Base:=
:Alpha(); }</font></div><div><font face=3D"monospace, monospace" size=3D"1"=
>};</font></div></div><div><br></div></div>-- <br><div>=C2=A0Nevin ":-=
)" Liber=C2=A0 <mailto:<a href=3D"mailto:nevin@eviloverlord.com" ta=
rget=3D"_blank">nevin@eviloverlord.com</a>>=C2=A0 <a href=3D"tel:%28847%=
29%20691-1404" value=3D"+18476911404" target=3D"_blank">(847) 691-1404</a><=
/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" 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 />
--001a11c3ce1466fb490514657dee--
.