Performs either compare-and-set or compare-and-swap (or exchange).
There are two categories of overloads in this template:
The first category does a simple compare-and-set.
The comparison value (
ifThis) is treated as an rvalue.
The second category does a compare-and-swap (a.k.a. compare-and-exchange),
ifThis to be a pointer type, where the previous value
here will be written.
This operation is both lock-free and atomic.
|cas||Compare-and-set for non-shared values|
|cas||Compare-and-set for shared value type|
|cas||Compare-and-exchange for non-
|cas||Compare and exchange for mixed-
|here||The address of the destination variable.|
|writeThis||The value to store.|
|ifThis||The comparison value.|
true if the store occurred, false if not.
Sean Kelly, Alex Rønne Petersen, Manu Evans