cpp/atomic/atomic flag test and set

Atomically changes the state of a std pointed to by to set  and returns the value it held before.

Return value
The value previously held by the flag pointed to by