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?
 

-----Ursprüngliche Nachricht-----
Von: Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Sa 01.07.2023 17:23
Betreff: [std-proposals] std::contains_mutable
An: std-proposals <std-proposals@lists.isocpp.org>;
CC: Frederick Virchanza Gotham <cauldwell.thomas@gmail.com>;
 
This week I posted on here about my 'Reserved' class that works very similarly to 'boost::synchronized_value', and today I was thinking that I would change the mutex to a shared_mutex, and add a new method, 'ReserveReadOnly' to go alongside the 'Reserve'.
 
But then I thought that this could malfunction if the class contained any mutable members.
 
So I think in <type_traits>, we should have 'std::contains_mutable'.
 
-- 
 Std-Proposals mailing list
 Std-Proposals@lists.isocpp.org
 https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals