C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Attribute to require call to overridden base class function

From: Magnus Fromreide <magfr_at_[hidden]>
Date: Sun, 18 Aug 2024 23:08:50 +0200
On Sat, Aug 17, 2024 at 05:18:54PM -0400, Billy via Std-Proposals wrote:
> Could C++ use an attribute to require derived classes to call the base
> class version of a function?
>
> struct A {
> virtual void f() [[required]] { }
> };
>
> struct B : A {
> void f() override {
> A::f(); // compiler warning if omitted
> }
> };
> Much like Objective-C's __attribute__((objc_requires_super))

Should the following generate a warning or not?

struct C : B {
  void f() override {
  }
};

> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2024-08-18 21:08:56