June 2018
Intermediate to advanced
348 pages
8h 45m
English
Along with the usual set of operations such as load(), store(), exchange(), compare_exchange_weak(), and compare_exchange_strong(), the atomic pointer type is loaded with the pointer arithmetic operations. The member functions fetch_add() and fetch_sub() provide operation support for the type to do atomic addition and subtraction on the stored address, and the operators += and -=, and both pre- and post-increment/decrement, use the ++ and -- operators.
The operators work in the same way as standard non-atomic pointer arithmetic works. If obj is an std::atomic<some_class*>, an object points to the first entry of an array of some_class objects. The obj+=2 changes it to point to the third element in the array ...
Read now
Unlock full access