Topic: A virtual method that must *always* be overridden?


Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Thu, 4 Apr 2019 13:18:52 -0400
Raw View
While adding a `virtual Self* clone() = 0` to a class yesterday, I
realized something... why does C++ not have a way to mark a method that
must *always* be overridden? I'm talking about something *more* than a
pure virtual, i.e.:

  struct Root
  {
    virtual Root* foo() bikeshed;
  };

  struct Derived : Root
  {
  };

  struct MoreDerived : Derived
  {
    virtual Root* foo();
  };

  Root x; // okay
  Derived y; // error: 'foo' was not overridden
  MoreDerived z; // okay

Would this be useful?

--
Matthew

--
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/42fc876e-a4c7-a247-bc7f-632efbe1b28d%40gmail.com.

.


Author: Brian Bi <bbi5291@gmail.com>
Date: Thu, 4 Apr 2019 12:35:36 -0500
Raw View
--000000000000f8764e0585b7cc88
Content-Type: text/plain; charset="UTF-8"

How is this different from a pure virtual method?

Since foo() is not overridden in Derived, Derived is an abstract class and
cannot be instantiated.

By "must *always* be overridden" I had thought you meant that the
definition of Derived would be ill-formed, or something like that. And was
going to ask why you would ever want that.

On Thu, Apr 4, 2019 at 12:18 PM Matthew Woehlke <mwoehlke.floss@gmail.com>
wrote:

> While adding a `virtual Self* clone() = 0` to a class yesterday, I
> realized something... why does C++ not have a way to mark a method that
> must *always* be overridden? I'm talking about something *more* than a
> pure virtual, i.e.:
>
>   struct Root
>   {
>     virtual Root* foo() bikeshed;
>   };
>
>   struct Derived : Root
>   {
>   };
>
>   struct MoreDerived : Derived
>   {
>     virtual Root* foo();
>   };
>
>   Root x; // okay
>   Derived y; // error: 'foo' was not overridden
>   MoreDerived z; // okay
>
> Would this be useful?
>
> --
> Matthew
>
> --
> 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/42fc876e-a4c7-a247-bc7f-632efbe1b28d%40gmail.com
> .
>


--
*Brian Bi*

--
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/CAMmfjbNEN_eeXk8n%3DR12uCHV3ZM9TQfgMtBdGAYqX%2B9n051g3g%40mail.gmail.com.

--000000000000f8764e0585b7cc88
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">How is this different from a pure virtual method?<div><br>=
</div><div>Since foo() is not overridden in Derived, Derived is an abstract=
 class and cannot be instantiated.</div><div><br></div><div>By &quot;must *=
always* be overridden&quot; I had thought you meant that the definition of =
Derived would be ill-formed, or something like that. And was going to ask w=
hy you would ever want that.</div></div><br><div class=3D"gmail_quote"><div=
 dir=3D"ltr" class=3D"gmail_attr">On Thu, Apr 4, 2019 at 12:18 PM Matthew W=
oehlke &lt;<a href=3D"mailto:mwoehlke.floss@gmail.com">mwoehlke.floss@gmail=
..com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1=
ex">While adding a `virtual Self* clone() =3D 0` to a class yesterday, I<br=
>
realized something... why does C++ not have a way to mark a method that<br>
must *always* be overridden? I&#39;m talking about something *more* than a<=
br>
pure virtual, i.e.:<br>
<br>
=C2=A0 struct Root<br>
=C2=A0 {<br>
=C2=A0 =C2=A0 virtual Root* foo() bikeshed;<br>
=C2=A0 };<br>
<br>
=C2=A0 struct Derived : Root<br>
=C2=A0 {<br>
=C2=A0 };<br>
<br>
=C2=A0 struct MoreDerived : Derived<br>
=C2=A0 {<br>
=C2=A0 =C2=A0 virtual Root* foo();<br>
=C2=A0 };<br>
<br>
=C2=A0 Root x; // okay<br>
=C2=A0 Derived y; // error: &#39;foo&#39; was not overridden<br>
=C2=A0 MoreDerived z; // okay<br>
<br>
Would this be useful?<br>
<br>
-- <br>
Matthew<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%2Bunsubscribe@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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/42fc876e-a4c7-a247-bc7f-632efbe1b28d%=
40gmail.com" rel=3D"noreferrer" target=3D"_blank">https://groups.google.com=
/a/isocpp.org/d/msgid/std-proposals/42fc876e-a4c7-a247-bc7f-632efbe1b28d%40=
gmail.com</a>.<br>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
 class=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><font col=
or=3D"#c0c0c0"><i>Brian Bi</i></font><br><div></div><div></div><div></div><=
/div></div></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAMmfjbNEN_eeXk8n%3DR12uCHV3ZM9TQfgMt=
BdGAYqX%2B9n051g3g%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAMmfjbNEN_ee=
Xk8n%3DR12uCHV3ZM9TQfgMtBdGAYqX%2B9n051g3g%40mail.gmail.com</a>.<br />

--000000000000f8764e0585b7cc88--

.


Author: Jared Grubb <jared.grubb@gmail.com>
Date: Thu, 4 Apr 2019 10:38:26 -0700 (PDT)
Raw View
------=_Part_1650_1785416900.1554399506254
Content-Type: multipart/alternative;
 boundary="----=_Part_1651_2132215750.1554399506254"

------=_Part_1651_2132215750.1554399506254
Content-Type: text/plain; charset="UTF-8"

I think he wants a *concrete* class that, when used as a base class, has
methods that must be overridden.

Jared

On Thursday, April 4, 2019 at 10:35:51 AM UTC-7, Brian Bi wrote:
>
> How is this different from a pure virtual method?
>
> Since foo() is not overridden in Derived, Derived is an abstract class and
> cannot be instantiated.
>
> By "must *always* be overridden" I had thought you meant that the
> definition of Derived would be ill-formed, or something like that. And was
> going to ask why you would ever want that.
>
> On Thu, Apr 4, 2019 at 12:18 PM Matthew Woehlke <mwoehl...@gmail.com
> <javascript:>> wrote:
>
>> While adding a `virtual Self* clone() = 0` to a class yesterday, I
>> realized something... why does C++ not have a way to mark a method that
>> must *always* be overridden? I'm talking about something *more* than a
>> pure virtual, i.e.:
>>
>>   struct Root
>>   {
>>     virtual Root* foo() bikeshed;
>>   };
>>
>>   struct Derived : Root
>>   {
>>   };
>>
>>   struct MoreDerived : Derived
>>   {
>>     virtual Root* foo();
>>   };
>>
>>   Root x; // okay
>>   Derived y; // error: 'foo' was not overridden
>>   MoreDerived z; // okay
>>
>> Would this be useful?
>>
>> --
>> Matthew
>>
>> --
>> 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-pr...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/42fc876e-a4c7-a247-bc7f-632efbe1b28d%40gmail.com
>> .
>>
>
>
> --
> *Brian Bi*
>

--
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/074e9f91-f741-40dd-84dd-1fd61c78d7ee%40isocpp.org.

------=_Part_1651_2132215750.1554399506254
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I think he wants a *concrete* class that, when used as a b=
ase class, has methods that must be overridden.<br><div><br>Jared<br></div>=
<br>On Thursday, April 4, 2019 at 10:35:51 AM UTC-7, Brian Bi wrote:<blockq=
uote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-lef=
t: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">How is this differen=
t from a pure virtual method?<div><br></div><div>Since foo() is not overrid=
den in Derived, Derived is an abstract class and cannot be instantiated.</d=
iv><div><br></div><div>By &quot;must *always* be overridden&quot; I had tho=
ught you meant that the definition of Derived would be ill-formed, or somet=
hing like that. And was going to ask why you would ever want that.</div></d=
iv><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Thu, Apr 4, 2019 at 1=
2:18 PM Matthew Woehlke &lt;<a href=3D"javascript:" target=3D"_blank" gdf-o=
bfuscated-mailto=3D"dWDI-DGcBwAJ" rel=3D"nofollow" onmousedown=3D"this.href=
=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascri=
pt:&#39;;return true;">mwoehl...@gmail.com</a>&gt; wrote:<br></div><blockqu=
ote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px=
 solid rgb(204,204,204);padding-left:1ex">While adding a `virtual Self* clo=
ne() =3D 0` to a class yesterday, I<br>
realized something... why does C++ not have a way to mark a method that<br>
must *always* be overridden? I&#39;m talking about something *more* than a<=
br>
pure virtual, i.e.:<br>
<br>
=C2=A0 struct Root<br>
=C2=A0 {<br>
=C2=A0 =C2=A0 virtual Root* foo() bikeshed;<br>
=C2=A0 };<br>
<br>
=C2=A0 struct Derived : Root<br>
=C2=A0 {<br>
=C2=A0 };<br>
<br>
=C2=A0 struct MoreDerived : Derived<br>
=C2=A0 {<br>
=C2=A0 =C2=A0 virtual Root* foo();<br>
=C2=A0 };<br>
<br>
=C2=A0 Root x; // okay<br>
=C2=A0 Derived y; // error: &#39;foo&#39; was not overridden<br>
=C2=A0 MoreDerived z; // okay<br>
<br>
Would this be useful?<br>
<br>
-- <br>
Matthew<br>
<br>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
dWDI-DGcBwAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;">std-pr...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"dWDI-DGcBwAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39=
;javascript:&#39;;return true;">std-pr...@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/42fc876e-a4c7-a247-bc7f-632efbe1b28d%=
40gmail.com" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D=
&#39;https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/42fc876e-=
a4c7-a247-bc7f-632efbe1b28d%40gmail.com&#39;;return true;" onclick=3D"this.=
href=3D&#39;https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/42=
fc876e-a4c7-a247-bc7f-632efbe1b28d%40gmail.com&#39;;return true;">https://g=
roups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/42fc876e-a4c7=
-a247-<wbr>bc7f-632efbe1b28d%40gmail.com</a>.<br>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
><div dir=3D"ltr"><div><div dir=3D"ltr"><font color=3D"#c0c0c0"><i>Brian Bi=
</i></font><br><div></div><div></div><div></div></div></div></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&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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/074e9f91-f741-40dd-84dd-1fd61c78d7ee%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/074e9f91-f741-40dd-84dd-1fd61c78d7ee=
%40isocpp.org</a>.<br />

------=_Part_1651_2132215750.1554399506254--

------=_Part_1650_1785416900.1554399506254--

.


Author: Brian Bi <bbi5291@gmail.com>
Date: Thu, 4 Apr 2019 12:39:36 -0500
Raw View
--000000000000418f700585b7db43
Content-Type: text/plain; charset="UTF-8"

Oh I see, I didn't notice that `Root x;` was supposed to compile.

On Thu, Apr 4, 2019 at 12:38 PM Jared Grubb <jared.grubb@gmail.com> wrote:

> I think he wants a *concrete* class that, when used as a base class, has
> methods that must be overridden.
>
> Jared
>
> On Thursday, April 4, 2019 at 10:35:51 AM UTC-7, Brian Bi wrote:
>>
>> How is this different from a pure virtual method?
>>
>> Since foo() is not overridden in Derived, Derived is an abstract class
>> and cannot be instantiated.
>>
>> By "must *always* be overridden" I had thought you meant that the
>> definition of Derived would be ill-formed, or something like that. And was
>> going to ask why you would ever want that.
>>
>> On Thu, Apr 4, 2019 at 12:18 PM Matthew Woehlke <mwoehl...@gmail.com>
>> wrote:
>>
>>> While adding a `virtual Self* clone() = 0` to a class yesterday, I
>>> realized something... why does C++ not have a way to mark a method that
>>> must *always* be overridden? I'm talking about something *more* than a
>>> pure virtual, i.e.:
>>>
>>>   struct Root
>>>   {
>>>     virtual Root* foo() bikeshed;
>>>   };
>>>
>>>   struct Derived : Root
>>>   {
>>>   };
>>>
>>>   struct MoreDerived : Derived
>>>   {
>>>     virtual Root* foo();
>>>   };
>>>
>>>   Root x; // okay
>>>   Derived y; // error: 'foo' was not overridden
>>>   MoreDerived z; // okay
>>>
>>> Would this be useful?
>>>
>>> --
>>> Matthew
>>>
>>> --
>>> 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-pr...@isocpp.org.
>>> To post to this group, send email to std-pr...@isocpp.org.
>>> To view this discussion on the web visit
>>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/42fc876e-a4c7-a247-bc7f-632efbe1b28d%40gmail.com
>>> .
>>>
>>
>>
>> --
>> *Brian Bi*
>>
> --
> 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/074e9f91-f741-40dd-84dd-1fd61c78d7ee%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/074e9f91-f741-40dd-84dd-1fd61c78d7ee%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>


--
*Brian Bi*

--
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/CAMmfjbPwtz-hGxGdcH6fotkpaFDFJ7Y1h-U3PJNWtyknxYfZWQ%40mail.gmail.com.

--000000000000418f700585b7db43
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Oh I see, I didn&#39;t notice that `Root x;` was supposed =
to compile.</div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"g=
mail_attr">On Thu, Apr 4, 2019 at 12:38 PM Jared Grubb &lt;<a href=3D"mailt=
o:jared.grubb@gmail.com">jared.grubb@gmail.com</a>&gt; wrote:<br></div><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left=
:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">I think he w=
ants a *concrete* class that, when used as a base class, has methods that m=
ust be overridden.<br><div><br>Jared<br></div><br>On Thursday, April 4, 201=
9 at 10:35:51 AM UTC-7, Brian Bi wrote:<blockquote class=3D"gmail_quote" st=
yle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padd=
ing-left:1ex"><div dir=3D"ltr">How is this different from a pure virtual me=
thod?<div><br></div><div>Since foo() is not overridden in Derived, Derived =
is an abstract class and cannot be instantiated.</div><div><br></div><div>B=
y &quot;must *always* be overridden&quot; I had thought you meant that the =
definition of Derived would be ill-formed, or something like that. And was =
going to ask why you would ever want that.</div></div><br><div class=3D"gma=
il_quote"><div dir=3D"ltr">On Thu, Apr 4, 2019 at 12:18 PM Matthew Woehlke =
&lt;<a rel=3D"nofollow">mwoehl...@gmail.com</a>&gt; wrote:<br></div><blockq=
uote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1p=
x solid rgb(204,204,204);padding-left:1ex">While adding a `virtual Self* cl=
one() =3D 0` to a class yesterday, I<br>
realized something... why does C++ not have a way to mark a method that<br>
must *always* be overridden? I&#39;m talking about something *more* than a<=
br>
pure virtual, i.e.:<br>
<br>
=C2=A0 struct Root<br>
=C2=A0 {<br>
=C2=A0 =C2=A0 virtual Root* foo() bikeshed;<br>
=C2=A0 };<br>
<br>
=C2=A0 struct Derived : Root<br>
=C2=A0 {<br>
=C2=A0 };<br>
<br>
=C2=A0 struct MoreDerived : Derived<br>
=C2=A0 {<br>
=C2=A0 =C2=A0 virtual Root* foo();<br>
=C2=A0 };<br>
<br>
=C2=A0 Root x; // okay<br>
=C2=A0 Derived y; // error: &#39;foo&#39; was not overridden<br>
=C2=A0 MoreDerived z; // okay<br>
<br>
Would this be useful?<br>
<br>
-- <br>
Matthew<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 rel=3D"nofollow">std-pr...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</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/42fc876e-a4c7-a247-bc7f-632efbe1b28d%=
40gmail.com" rel=3D"nofollow" target=3D"_blank">https://groups.google.com/a=
/isocpp.org/d/msgid/std-proposals/42fc876e-a4c7-a247-bc7f-632efbe1b28d%40gm=
ail.com</a>.<br>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
><div dir=3D"ltr"><div><div dir=3D"ltr"><font color=3D"#c0c0c0"><i>Brian Bi=
</i></font><br><div></div><div></div><div></div></div></div></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&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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/074e9f91-f741-40dd-84dd-1fd61c78d7ee%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/074e9f91-f741-=
40dd-84dd-1fd61c78d7ee%40isocpp.org</a>.<br>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
 class=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><font col=
or=3D"#c0c0c0"><i>Brian Bi</i></font><br><div></div><div></div><div></div><=
/div></div></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAMmfjbPwtz-hGxGdcH6fotkpaFDFJ7Y1h-U3=
PJNWtyknxYfZWQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAMmfjbPwtz-hGxGd=
cH6fotkpaFDFJ7Y1h-U3PJNWtyknxYfZWQ%40mail.gmail.com</a>.<br />

--000000000000418f700585b7db43--

.


Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Fri, 5 Apr 2019 16:13:22 -0400
Raw View
(Re-send; Google is being obnoxious again...)

On 04/04/2019 13.35, Brian Bi wrote:
> How is this different from a pure virtual method?

....because once *any* class overrides it, that suffices for the whole
hierarchy. What I want is for (use of) *any* derived class to be IFDR if
the method is not overridden.

Consider:

  struct A     { virtual foo() = 0; };
  struct B : A { virtual foo() override; };
  struct C : B {};

Right now, I can instantiate a `C`, even though `C` did not override
`foo`. I want something that will let me make that IFDR.

(The motivation, as alluded in the original post, is to prevent mistakes
where not overriding a method is likely an error. For example, if I have
a `clone` method and forget to override it, I unexpectedly have slicing.)

> By "must *always* be overridden" I had thought you meant that the
> definition of Derived would be ill-formed, or something like that.

I specifically *don't* want the definition to be ill-formed. I think
it's plausible that an intermediary might not want to override such a
method. Such an intermediary (as shown in my original example) would be
considered abstract. Just like any class with a pure virtual, you can
derive from it, but trying to directly instantiate it is ill-formed.

An existing pure virtual is abstract *until* it is overridden. What I'm
proposing is a method that (may or may not be initially, but) *becomes*
abstract *unless* it is overridden, and does so persistently.

--
Matthew

--
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/3e470971-9f38-e5c3-74d7-e43fdbd2e3fc%40gmail.com.

.


Author: Richard Hodges <hodges.r@gmail.com>
Date: Sat, 6 Apr 2019 04:45:33 +0100
Raw View
--0000000000001c8e160585d470e0
Content-Type: text/plain; charset="UTF-8"

On Fri, 5 Apr 2019 at 21:13, Matthew Woehlke <mwoehlke.floss@gmail.com>
wrote:

> (Re-send; Google is being obnoxious again...)
>
> On 04/04/2019 13.35, Brian Bi wrote:
> > How is this different from a pure virtual method?
>
> ...because once *any* class overrides it, that suffices for the whole
> hierarchy. What I want is for (use of) *any* derived class to be IFDR if
> the method is not overridden.
>

Is this a *common* use case? By which I mean common enough to warrant
introducing a new keyword along with the resulting increasing complication
in teaching the language?

You may have a specific use case that would benefit from such a feature,
but (for example) I have never encountered one.

Unequivocal demonstrations of benefit to the c++ community would go a long
way to persuading people to give this idea the time of day.



>
> Consider:
>
>   struct A     { virtual foo() = 0; };
>   struct B : A { virtual foo() override; };
>   struct C : B {};
>
> Right now, I can instantiate a `C`, even though `C` did not override
> `foo`. I want something that will let me make that IFDR.
>
> (The motivation, as alluded in the original post, is to prevent mistakes
> where not overriding a method is likely an error. For example, if I have
> a `clone` method and forget to override it, I unexpectedly have slicing.)
>
> > By "must *always* be overridden" I had thought you meant that the
> > definition of Derived would be ill-formed, or something like that.
>
> I specifically *don't* want the definition to be ill-formed. I think
> it's plausible that an intermediary might not want to override such a
> method. Such an intermediary (as shown in my original example) would be
> considered abstract. Just like any class with a pure virtual, you can
> derive from it, but trying to directly instantiate it is ill-formed.
>
> An existing pure virtual is abstract *until* it is overridden. What I'm
> proposing is a method that (may or may not be initially, but) *becomes*
> abstract *unless* it is overridden, and does so persistently.
>
> --
> Matthew
>
> --
> 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/3e470971-9f38-e5c3-74d7-e43fdbd2e3fc%40gmail.com
> .
>


--
Richard Hodges
hodges.r@gmail.com
office: +442032898513
home: +376841522
mobile: +376380212

--
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/CALvx3hauuc21veSbYaDrj_bmsdU7qbd16V9_f-UOGKXUXNeRZg%40mail.gmail.com.

--0000000000001c8e160585d470e0
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Fri, 5 Apr 2019 at 21:13, Matthew =
Woehlke &lt;<a href=3D"mailto:mwoehlke.floss@gmail.com">mwoehlke.floss@gmai=
l.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:=
1ex">(Re-send; Google is being obnoxious again...)<br>
<br>
On 04/04/2019 13.35, Brian Bi wrote:<br>
&gt; How is this different from a pure virtual method?<br>
<br>
....because once *any* class overrides it, that suffices for the whole<br>
hierarchy. What I want is for (use of) *any* derived class to be IFDR if<br=
>
the method is not overridden.<br></blockquote><div><br></div><div>Is this a=
 <i>common</i> use case? By which I mean common enough to warrant introduci=
ng a new keyword along with the resulting increasing complication in teachi=
ng the language?</div><div><br></div><div>You may have a specific use case =
that would benefit from such a feature, but (for example) I have never enco=
untered one.=C2=A0<br><br>Unequivocal demonstrations of benefit to the c++ =
community would go a long way to persuading people to give this idea the ti=
me of day.</div><div><br></div><div>=C2=A0</div><blockquote class=3D"gmail_=
quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,=
204);padding-left:1ex">
<br>
Consider:<br>
<br>
=C2=A0 struct A=C2=A0 =C2=A0 =C2=A0{ virtual foo() =3D 0; };<br>
=C2=A0 struct B : A { virtual foo() override; };<br>
=C2=A0 struct C : B {};<br>
<br>
Right now, I can instantiate a `C`, even though `C` did not override<br>
`foo`. I want something that will let me make that IFDR.<br>
<br>
(The motivation, as alluded in the original post, is to prevent mistakes<br=
>
where not overriding a method is likely an error. For example, if I have<br=
>
a `clone` method and forget to override it, I unexpectedly have slicing.)<b=
r>
<br>
&gt; By &quot;must *always* be overridden&quot; I had thought you meant tha=
t the<br>
&gt; definition of Derived would be ill-formed, or something like that.<br>
<br>
I specifically *don&#39;t* want the definition to be ill-formed. I think<br=
>
it&#39;s plausible that an intermediary might not want to override such a<b=
r>
method. Such an intermediary (as shown in my original example) would be<br>
considered abstract. Just like any class with a pure virtual, you can<br>
derive from it, but trying to directly instantiate it is ill-formed.<br>
<br>
An existing pure virtual is abstract *until* it is overridden. What I&#39;m=
<br>
proposing is a method that (may or may not be initially, but) *becomes*<br>
abstract *unless* it is overridden, and does so persistently.<br>
<br>
-- <br>
Matthew<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%2Bunsubscribe@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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/3e470971-9f38-e5c3-74d7-e43fdbd2e3fc%=
40gmail.com" rel=3D"noreferrer" target=3D"_blank">https://groups.google.com=
/a/isocpp.org/d/msgid/std-proposals/3e470971-9f38-e5c3-74d7-e43fdbd2e3fc%40=
gmail.com</a>.<br>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
 class=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr">Richard H=
odges<div><a href=3D"mailto:hodges.r@gmail.com" target=3D"_blank">hodges.r@=
gmail.com</a></div><div>office: +442032898513</div><div>home: +376841522</d=
iv><div>mobile:=C2=A0+376380212</div><div><br></div></div></div></div></div=
></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CALvx3hauuc21veSbYaDrj_bmsdU7qbd16V9_=
f-UOGKXUXNeRZg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hauuc21veSb=
YaDrj_bmsdU7qbd16V9_f-UOGKXUXNeRZg%40mail.gmail.com</a>.<br />

--0000000000001c8e160585d470e0--

.


Author: Alberto Barbati <albertobarbati@gmail.com>
Date: Mon, 8 Apr 2019 01:54:39 -0700 (PDT)
Raw View
------=_Part_933_1485858973.1554713679389
Content-Type: multipart/alternative;
 boundary="----=_Part_934_1745775023.1554713679389"

------=_Part_934_1745775023.1554713679389
Content-Type: text/plain; charset="UTF-8"

Il giorno sabato 6 aprile 2019 05:45:47 UTC+2, Richard Hodges ha scritto:
>
>
>
> On Fri, 5 Apr 2019 at 21:13, Matthew Woehlke <mwoehl...@gmail.com
> <javascript:>> wrote:
>
>> (Re-send; Google is being obnoxious again...)
>>
>> On 04/04/2019 13.35, Brian Bi wrote:
>> > How is this different from a pure virtual method?
>>
>> ...because once *any* class overrides it, that suffices for the whole
>> hierarchy. What I want is for (use of) *any* derived class to be IFDR if
>> the method is not overridden.
>>
>
> Is this a *common* use case? By which I mean common enough to warrant
> introducing a new keyword along with the resulting increasing complication
> in teaching the language?
>

Unfortunately Google rejected the OP's answer about a use case that is
actually very common and IMHO compelling: the clone() function.

However, I agree that it's still not important enough for a language
feature. But... what about an attribute?

struct BikeShed
{
    [[concrete_classes_must_override]] virtual void f() = 0;
};

Just my two eurocent,

--
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/c856e6c4-a4d1-405d-b0dd-916378f57ecc%40isocpp.org.

------=_Part_934_1745775023.1554713679389
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Il giorno sabato 6 aprile 2019 05:45:47 UTC+2, Richard Hod=
ges ha scritto:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-=
left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr=
"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote"><div dir=3D"ltr=
">On Fri, 5 Apr 2019 at 21:13, Matthew Woehlke &lt;<a href=3D"javascript:" =
target=3D"_blank" gdf-obfuscated-mailto=3D"tq9kKQ8MCAAJ" rel=3D"nofollow" o=
nmousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"th=
is.href=3D&#39;javascript:&#39;;return true;">mwoehl...@gmail.com</a>&gt; w=
rote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p=
x 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">(Re-send; =
Google is being obnoxious again...)<br>
<br>
On 04/04/2019 13.35, Brian Bi wrote:<br>
&gt; How is this different from a pure virtual method?<br>
<br>
....because once *any* class overrides it, that suffices for the whole<br>
hierarchy. What I want is for (use of) *any* derived class to be IFDR if<br=
>
the method is not overridden.<br></blockquote><div><br></div><div>Is this a=
 <i>common</i> use case? By which I mean common enough to warrant introduci=
ng a new keyword along with the resulting increasing complication in teachi=
ng the language?</div></div></div></blockquote><div><br></div><div>Unfortun=
ately Google rejected the OP&#39;s answer about a use case that is actually=
 very common and IMHO compelling: the clone() function.</div><div><br></div=
><div>However, I agree that it&#39;s still not important enough for a langu=
age feature. But... what about an attribute?</div><div><br></div><div>struc=
t BikeShed</div><div>{</div><div>=C2=A0=C2=A0=C2=A0 [[concrete_classes_must=
_override]] virtual void f() =3D 0;</div><div>};<br></div><div><br> </div><=
div>Just my two eurocent,<br></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/c856e6c4-a4d1-405d-b0dd-916378f57ecc%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/c856e6c4-a4d1-405d-b0dd-916378f57ecc=
%40isocpp.org</a>.<br />

------=_Part_934_1745775023.1554713679389--

------=_Part_933_1485858973.1554713679389--

.