C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Public inheritance with banned conversion to base

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Thu, 23 Jan 2025 14:22:14 +0100
On 23/01/2025 09:16, Filip via Std-Proposals wrote:
> Maybe a stupid question but why wouldn’t the STL containers be marked
> with final if it is not encouraged to inherit from them?

Discourage doesn't mean prohibit. No classes in the Standard Library are
marked as `final`, and an implementation can't add it of its own initiative:

https://cplusplus.github.io/LWG/issue2514
https://eel.is/c++draft/derivation#4

(I'm unsure if this extends to things like std::bind's return type,
since by specification, it's unspecified.)

My 2 c,
--
Giuseppe D'Angelo

Received on 2025-01-23 13:22:17