Documentation Home >> Headers >> <atomic> Header >> std::atomic_flag >> std::atomic_flag::test_and_set member function

Atomically set the flag and check whether or not it was set.

bool test_and_set(
    memory_order order = memory_order_seq_cst)
    volatile;

Effects:

Atomically sets the flag.

Returns:

true if the flag was set at the point of the call, false if the flag was clear.

Throws:

Nothing.

Note:

This is an atomic read-modify-write operation for the memory location comprising *this.

Header

#include <atomic>

See Also