C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Specific Override Specifier
From: Tony V E (tvaneerd_at_[hidden])
Date: 2020-03-18 08:29:25


On Tue, Mar 17, 2020 at 2:12 PM Ryan Nicholl via Std-Proposals <
std-proposals_at_[hidden]> wrote:

>
> Consider:
>
> class A : public B, public C
> {
> virtual int lock();
> };
>
> what happens if both B::lock and C::lock exist as virtual functions? we
> can override them both with one function... but what if they are interfaces
> that do different things and happen to use the same name?
>
> Suggestion, specific override specifier:
>
> virtual int lock_mutex() override(int B::lock());
> virtual int lock_device() override(int C::lock());
>
>
>
I'd suggest a different syntax:

class A : public B, public C
{
   virtual int B::lock() override;
   virtual int C::lock() override;
};

but I've only needed this rarely; I suspect it probably isn't worth the
trouble.

-- 
Be seeing you,
Tony


STD-PROPOSALS list run by herb.sutter at gmail.com

Standard Proposals Archives on Google Groups