220 41588 <CAMmfjbNEN_eeXk8n=R12uCHV3ZM9TQfgMtBdGAYqX+9n051g3g@mail.gmail.com> article
Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail
From: Brian Bi <bbi5291@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: A virtual method that must *always* be overridden?
Date: Thu, 4 Apr 2019 12:35:36 -0500
Approved: news@gmane.org
Message-ID: <CAMmfjbNEN_eeXk8n=R12uCHV3ZM9TQfgMtBdGAYqX+9n051g3g@mail.gmail.com>
References: <42fc876e-a4c7-a247-bc7f-632efbe1b28d@gmail.com>
Reply-To: std-proposals@isocpp.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="000000000000f8764e0585b7cc88"
Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226";
	logging-data="130750"; mail-complaints-to="usenet@blaine.gmane.org"
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDS5ZX5VU4NBB5UATHSQKGQEQSJ6EBA@isocpp.org Thu Apr 04 19:35:52 2019
Return-path: <std-proposals+bncBDS5ZX5VU4NBB5UATHSQKGQEQSJ6EBA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ed1-f72.google.com ([209.85.208.72])
	by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
	(Exim 4.89)
	(envelope-from <std-proposals+bncBDS5ZX5VU4NBB5UATHSQKGQEQSJ6EBA@isocpp.org>)
	id 1hC6HH-000XpB-Qj
	for gclcip-std-proposals@m.gmane.org; Thu, 04 Apr 2019 19:35:51 +0200
Original-Received: by mail-ed1-f72.google.com with SMTP id s27sf1837785eda.16
        for <gclcip-std-proposals@m.gmane.org>; Thu, 04 Apr 2019 10:35:51 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1554399351; cv=pass;
        d=google.com; s=arc-20160816;
        b=dvuDUke6GW8nI08gkBPuEmsLT+AsyrLz9jc44BC0ZIDxdQmHyF26IvfE7HdD/BTFo7
         5ifpSoCsnWxYCQ+PKCAK0E7IYg8z9g8093kKeU2oKv+yayJ+qeaT6f6KkkRWeQblg2UY
         z7hqmhItUfIsD5I/nD+eI58fS0MEknl+5vWS6oYR/UpxkKuUu5wY9J/W6LQdEr9WNi4X
         pZulFKUpTN9tm7jF37LMpku4X82xKYvaVRDkrsz9H4DRhMBeZypu7Dd8X0AxzjCFBZiX
         67I29r6zFrUrHtG6UDWAaE0Vy/CoMxKkiC11Z1jx10T3Rq2sK8Ykjfei2CPbaTbmG7ki
         8+YA==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:in-reply-to:references:mime-version:dkim-signature;
        bh=j4j7lD6OMgwjaHrWmxrsya6Mz9/aGGhK5DxgSNQKK/I=;
        b=A8vqpvTRb+qfrFNCfodJglYwAv1swmitZwtlSPq5/iVABzRklL+zVksL2e6D5GVKHY
         5M/lOQaZFj2WEvx36iC8tx/tVGkEv2sF1GvC846N8iYxdbLG3TYlU/wEqY+3WpHaMzQ4
         86MYavy0cBZZBhBhMxXeUhBcdRFqslLWLZFWk5CrrDDeZ0yG2tavikZhTGcJaCMZAx0t
         s2f1Z5Gh1Kg2qfLJ9rPYO3x7kYpdfvaOKJNN7SN5XapJ9dVQ9JBETTE+GXi0CKtuEaO/
         yec+uRJaALUk5TpKnUE6I6NeiCbOczgoLnprshare7nUo5inDfhkewGdJaMXfgk8evFH
         PFgA==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=Xa9smtBC;
       spf=pass (google.com: domain of bbi5291@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=bbi5291@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:references:in-reply-to:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=j4j7lD6OMgwjaHrWmxrsya6Mz9/aGGhK5DxgSNQKK/I=;
        b=CjCjyF8mkOLF8wqCOiICHMaNPCe/AJqd5IwKT5zeTgOTcz6C+wJ5cljNMXOrNdOJXk
         MEcamKNSzVXo7OdUusJ0QTxbUmjBkAiEOGL9rgTYg7lk34HT897nYPOy6YQ/ZSLzmEo5
         8Yed0r78P4JxLvFiPz5hNAScE5lg+8S0HJ2OApPyF/N+N9EzKoracpzlWDA1sE5ijp42
         5caX6G3prbI2VvX48c2wUkhNBBBZfVHhWZ5o7fapaG0ofSo5S/am0y9UB/oRfr7kl2G2
         jbuDiRY17RQCW+iBB3pdWc64ck32DI/IgrzoUW+MlCtJjaiDyXmq4Wd+mS/J+MjT+C6F
         f5dg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=j4j7lD6OMgwjaHrWmxrsya6Mz9/aGGhK5DxgSNQKK/I=;
        b=qcCv0KTKRlLgFq9TqJC84mpcNozHQQrN50lKa0G0pvSfbkW7BjPVuPLcOKlk9avq4v
         g0ujsHW0751BKObKBPzkxJFKKqmzwB8pNeLJ8jfTgR01afa1Oqz1FqGQZREFvbboSvlT
         jphqDxeGdw2ljqvNEKQSuS6kq3+SFIQFAJWayAhYVicuUDDjFClY0vrpbQZMiGhIUrOU
         ubxASMBYtpiMBcRSbBmvpsaGko5m4BwRcH/PMkGCZoMWzNg5fSLw6FIDdjOeRFwpi49J
         3TIZrE7qm1hnoXkdkliBNdm+VfHCuZcDXRkh+zO7ZpuosGy2G/Xty1Xc8dlMfjX2/M9k
         s4AA==
X-Gm-Message-State: APjAAAVFjkRQUZ/CpAmqOc+To7Pa3Ct6NKQpXhihorIwIBkf5/Lr4ypG
	lTidLl3naXbIiGyCpOccX1QWow==
X-Google-Smtp-Source: APXvYqxohXBl24Q2srN8ZbIdqam6l45IZKxBhA0d5qcbJuOnTnYsS0a6uhmrUN5CwNFJD2UMeCWcpQ==
X-Received: by 2002:a17:906:ca1a:: with SMTP id jt26mr837718ejb.1.1554399350925;
        Thu, 04 Apr 2019 10:35:50 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a17:906:4f85:: with SMTP id o5ls1060831eju.3.gmail; Thu, 04
 Apr 2019 10:35:48 -0700 (PDT)
X-Received: by 2002:a17:906:7f93:: with SMTP id f19mr4367070ejr.75.1554399348570;
        Thu, 04 Apr 2019 10:35:48 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1554399348; cv=none;
        d=google.com; s=arc-20160816;
        b=M5ZtVrOywS/ibZqLfYZ2LRhtgyNjt6kSIFPlamtrtKc1DBZ5J64vt6lFB628cLwWZ/
         4xIKhEopRAQa/7dKsRP6Q3ooZ3OA2G2Dg/Mr7kdS26YSbwE8x9XrjDCunroiUDGJ6V4g
         basVg3FI21CcwNZxKXps0D8F3H7/iptAGm0WdjCgcZUN0+kQM6Qzz6LJYJGzjv9l1Vdf
         hvTASO/LwNtv6KeH1fobSeRY6VPU1V+P83nCPoQf8EA82/OIdWewGJmKbcfj1xWP2b8I
         obkEVBJ/a/B5Ey6HpFFj/LbIlL1fITw8q1vfUd22pQD7wlwmLsClJnWIFR3jZzmuE0/l
         VAyw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:in-reply-to:references:mime-version
         :dkim-signature;
        bh=yQm/an+1854eyhM0zcf1gDqekK6ZTIFVgonpIm1kvW4=;
        b=XSYKWTYKyMnXYlJDlBB1KaVJrXcczo+PLJ2b9ty2CKWxxR+Wr4n40GDpeJ61WKm4z6
         fOo97wkPdErTv26TWE3FyiMzNZWTHB3I47K6znYaFWq6Op7MoBmOSG/W6We+pHOgzKmz
         9zbJDx0lS1VIPEalGlKHKOiHqHXr57U91V4KAk4PH1jna7CS3g9PaFovcucBfutNXJuo
         BrhaXq4p0dBknFEEK/cieUfkYYBmUcWiwBXYcJHgCyPzftFU8FS/s0g9G1YNzpPFFiub
         yoNjp3dHK6GcR5ImN5/nIE0P1pC6RkL8ZZPuME6sHTzLLyUooCmrgpqqTBYxhwWE9r2L
         KeSg==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=Xa9smtBC;
       spf=pass (google.com: domain of bbi5291@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=bbi5291@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id t9sor5876940ejs.48.2019.04.04.10.35.48
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Thu, 04 Apr 2019 10:35:48 -0700 (PDT)
Received-SPF: pass (google.com: domain of bbi5291@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 2002:a17:906:4f83:: with SMTP id o3mr4473591eju.188.1554399347896;
 Thu, 04 Apr 2019 10:35:47 -0700 (PDT)
In-Reply-To: <42fc876e-a4c7-a247-bc7f-632efbe1b28d@gmail.com>
X-Original-Sender: bbi5291@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=Xa9smtBC;       spf=pass
 (google.com: domain of bbi5291@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=bbi5291@gmail.com;       dmarc=pass (p=NONE
 sp=QUARANTINE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:41588
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/41588>

--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--

.
