Date: Thu, 24 Jul 2025 10:15:26 +0100
On Thu, Jul 24, 2025 at 10:04 AM Frederick Virchanza Gotham wrote:
>
> template<typename TParam>
> void drop(TParam &arg)
> {
> typedef std::remove_const_t< std::remove_reference_t<TParam> > T;
> // T might be volatile
> T &obj = const_cast<T&>(arg);
> (void)T{ static_cast<T&&>(obj) };
> }
But realistically I would just do:
std::optional< std::mutex > opt_mtx;
std::mutex &m = opt_mtx.value();
...
...
opt_mtx.reset();
...
...
By the way, the method 'std::optional::value' is a good candidate to
be marked as [[lifetimebound]].
>
> template<typename TParam>
> void drop(TParam &arg)
> {
> typedef std::remove_const_t< std::remove_reference_t<TParam> > T;
> // T might be volatile
> T &obj = const_cast<T&>(arg);
> (void)T{ static_cast<T&&>(obj) };
> }
But realistically I would just do:
std::optional< std::mutex > opt_mtx;
std::mutex &m = opt_mtx.value();
...
...
opt_mtx.reset();
...
...
By the way, the method 'std::optional::value' is a good candidate to
be marked as [[lifetimebound]].
Received on 2025-07-24 09:15:38