On Monday, January 2, 2023, Simon Scatton via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
So that for instance if I want a thread safe Output, I use this:
Output<std::mutex> A;
And if I want a non-thread safe Output I use this:
Output<NullMutex> B;
What if you were to pass around an 'std::optional<std::mutex>'?
Then the likes of 'lock_guard' and 'unique_lock' could be given a new overloaded constructor:
template<class MutexType>
class lock_guard {
public:
lock_guard(std::optional<MutexType> &arg)
{
if ( arg.has_value() ) p_mtx = &arg.value();
}
};