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 variable x, or call a const member function on x, you can assume that operation does not change the observable value of x -- or even modify the bits of x in an observable way even in the presence of concurrency. ...

Guideline: Remember the “M&M rule”: For a member variable, mutable and mutex (or atomic) go together. ...

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.