Many of the C++11 CAS operations (e.g., atomic_compare_exchange_weak
, atomic_compare_exchange_strong
) take two pointers and a value, i.e., like this:
bool atomic_compare_exchange(T* pointer, T* expected, // pseudodeclaration!
T desired);
In contrast, the CAS operations from Microsoft, gcc, and Intel all take one pointer and two values:
long InterlockedCompareExchange(long* pointer, long desired, // Microsoft
long expected);
int __sync_bool_compare_and_swap (T* pointer, T expected, // gcc and
T desired); // Intel
Why do the C++11 CAS functions take two pointers and a value instead of what appears to be a more conventional one pointer and two values?