Date: Sun, 18 Aug 2024 07:42:11 +0000
It's not about unit test, it's about communicating behavior.
I can see it being a thing, but I'm not sure that really requiring it in all circumstances is a symptom of a design problem.
Even the most pedantic of libraries I've worked with allows skipping the call to parent in some circumstances.
I agree that it requires some user experience to get a better understanding of this.
________________________________
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of Bo Persson via Std-Proposals <std-proposals_at_[hidden]>
Sent: Sunday, August 18, 2024 9:30:18 AM
To: std-proposals_at_[hidden] <std-proposals_at_[hidden]>
Cc: Bo Persson <bo_at_[hidden]>
Subject: Re: [std-proposals] Attribute to require call to overridden base class function
On 2024-08-17 at 23:18, 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))
>
>
Does this have to be a compile time errror?
In my experience, missing the call happens very rarely, and will be
caught early in the unit tests.
I can see it being a thing, but I'm not sure that really requiring it in all circumstances is a symptom of a design problem.
Even the most pedantic of libraries I've worked with allows skipping the call to parent in some circumstances.
I agree that it requires some user experience to get a better understanding of this.
________________________________
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of Bo Persson via Std-Proposals <std-proposals_at_[hidden]>
Sent: Sunday, August 18, 2024 9:30:18 AM
To: std-proposals_at_[hidden] <std-proposals_at_[hidden]>
Cc: Bo Persson <bo_at_[hidden]>
Subject: Re: [std-proposals] Attribute to require call to overridden base class function
On 2024-08-17 at 23:18, 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))
>
>
Does this have to be a compile time errror?
In my experience, missing the call happens very rarely, and will be
caught early in the unit tests.
-- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2024-08-18 07:42:14