GotW #6a Solution: Const-Correctness, Part 1 -- Herb Sutter
The solution to GotW #6a is now available:
GotW #6a Solution: Const-Correctness, Part 1 (updated for C ++11/14)
by Herb Sutter
From the article:
Starting with C++11,
const
on a variable that is possibly shared means read-only, safe to read concurrently without external synchronization.If you perform any operation on a
const
shared variablex
, or call a const member function onx
, you can assume that operation does not change the observable value ofx
-- or even modify the bits ofx
in an observable way even in the presence of concurrency. ...Guideline: Remember the “M&M rule”: For a member variable,
mutable
andmutex
(oratomic
) go together. ...