Yes, you are absolutely right. You should make your objects the following recommendations, and therefore access to them will be potentially slower in C ++ 11. If and only if :
If you make sure that at least one of them is incorrect, nothing changes. The number of objects that are accessed from multiple threads should always be minimal. And the number of classes that have mutable members should be minimal. So, you are talking about a minimal set of a minimum set of objects.
And even then ... all that is required is that the data schedules will not be broken. Depending on what kind of data can be changed, it may just be atomic access.
I do not see a problem here. Few of the standard library objects will have mutable members. I offer you a reasonable implementation of basic_string , vector , map , etc., which need mutable elements.
It seems that in C ++ 11 you cannot use a class with a standard library if its member functions are not synchronized (or do not perform any write operations).
This is not true. You certainly can. What you cannot do is try to access this class from multiple threads in such a way as to "execute any records" on these mutable elements. If you never access this object through this C ++ 11 class in threads in a certain way, you're fine.
So yes, you can use them. But you only get the guarantees provided by your own class. If you use your class through a standard library class in an unreasonable way (for example, your const functions are not const or are correctly synchronized), then this is your mistake, not the library.
So, in C ++ 98 you can do without internal synchronization for mutable members, but in C ++ 11 you cannot.
It's like saying that you can get away with computer crime back in the Roman Empire. Of course you can. Then they did not have computers; therefore, they did not know what computer crime was.
In C ++ 98/03 there was no concept of "threads". Thus, the standard does not have the concept of "internal synchronization", so that you could or could not "leave with" was not defined nor undefined. It made no sense to ask a question about the standard, rather than asking what the hacking laws were during Caesir Day.
Now that C ++ 11 really defines this concept and idea of โโrace status, C ++ 11 can tell when you can "get away from internal synchronization."
Or, to put it another way, this is how the two standards answer your question: what is the result of a potential data race in the mutable element when accessed through a member function declared by const in the standard library
C ++ 11: when accessing the const function there will be no data racing on any internal elements. All standard library implementations of such functions must be implemented in such a way that data race cannot occur.
C ++ 98/03: What data race?