C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Allow downcasting at compile time if Derived has no extra member objects

From: Thiago Macieira <thiago_at_[hidden]>
Date: Wed, 22 Feb 2023 22:22:58 -0800
On Wednesday, 22 February 2023 16:52:17 PST Frederick Virchanza Gotham via
Std-Proposals wrote:
> struct Adaptor : binary_semaphore {
> void lock (void) noexcept(false) { this->acquire(); }
> void unlock(void) noexcept(false) { this->release(); }
> };
>
> std::binary_semaphore some_global_object;

Simpler solution: make your variable of the Adaptor type.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-02-23 06:22:59