On Saturday, July 1, 2023, Sebastian Wittmeier via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
Changing a mutable counts as read-only access from the view from outside the class.
You think of non-mutable const accesses to be implicitly thread-safe?
You could possibly reintroduce volatile member functions as thread-safe interface?
C++: Been there, tried that?
I don't understand what you wrote there.
But anyway, let's say I have two base classes:
Reservable_CanBeReadOnly
Reservable_CannotBeReadOnly
The former has two methods, 'Reserve' and 'ReserveReadOnly', while the latter only has 'Reserve'.
So next I would have:
template<class T>
class Reservable : public std::conditional_t< std::contains_mutable_v<T>, Reservable_CannotBeReadOnly, Reservable_CanBeReadOnly >
{
};
So if T is a class that has mutable members, then you won't be able to call the 'ReserveReadOnly' method.