32
Concurrency support library
[thread]
32.5
Atomic operations
[atomics]
32.5.8
Class template
atomic
[atomics.types.generic]
32.5.8.1
General
[atomics.types.generic.general]
🔗
namespace
std
{
template
<
class
T
>
struct
atomic
{
using
value_type
=
T;
static
constexpr
bool
is_always_lock_free
=
implementation-defined
;
bool
is_lock_free
(
)
const
volatile
noexcept
;
bool
is_lock_free
(
)
const
noexcept
;
//
[atomics.
types.
operations]
, operations on atomic types
constexpr
atomic
(
)
noexcept
(
is_nothrow_default_constructible_v
<
T
>
)
;
constexpr
atomic
(
T
)
noexcept
; atomic
(
const
atomic
&
)
=
delete
; atomic
&
operator
=
(
const
atomic
&
)
=
delete
; atomic
&
operator
=
(
const
atomic
&
)
volatile
=
delete
; T load
(
memory_order
=
memory_order
::
seq_cst
)
const
volatile
noexcept
;
constexpr
T load
(
memory_order
=
memory_order
::
seq_cst
)
const
noexcept
;
operator
T
(
)
const
volatile
noexcept
;
constexpr
operator
T
(
)
const
noexcept
;
void
store
(
T, memory_order
=
memory_order
::
seq_cst
)
volatile
noexcept
;
constexpr
void
store
(
T, memory_order
=
memory_order
::
seq_cst
)
noexcept
; T
operator
=
(
T
)
volatile
noexcept
;
constexpr
T
operator
=
(
T
)
noexcept
; T exchange
(
T, memory_order
=
memory_order
::
seq_cst
)
volatile
noexcept
;
constexpr
T exchange
(
T, memory_order
=
memory_order
::
seq_cst
)
noexcept
;
bool
compare_exchange_weak
(
T
&
, T, memory_order, memory_order
)
volatile
noexcept
;
constexpr
bool
compare_exchange_weak
(
T
&
, T, memory_order, memory_order
)
noexcept
;
bool
compare_exchange_strong
(
T
&
, T, memory_order, memory_order
)
volatile
noexcept
;
constexpr
bool
compare_exchange_strong
(
T
&
, T, memory_order, memory_order
)
noexcept
;
bool
compare_exchange_weak
(
T
&
, T, memory_order
=
memory_order
::
seq_cst
)
volatile
noexcept
;
constexpr
bool
compare_exchange_weak
(
T
&
, T, memory_order
=
memory_order
::
seq_cst
)
noexcept
;
bool
compare_exchange_strong
(
T
&
, T, memory_order
=
memory_order
::
seq_cst
)
volatile
noexcept
;
constexpr
bool
compare_exchange_strong
(
T
&
, T, memory_order
=
memory_order
::
seq_cst
)
noexcept
;
void
wait
(
T, memory_order
=
memory_order
::
seq_cst
)
const
volatile
noexcept
;
constexpr
void
wait
(
T, memory_order
=
memory_order
::
seq_cst
)
const
noexcept
;
void
notify_one
(
)
volatile
noexcept
;
constexpr
void
notify_one
(
)
noexcept
;
void
notify_all
(
)
volatile
noexcept
;
constexpr
void
notify_all
(
)
noexcept
;
}
;
}
1
#
The template argument for
T
shall meet the
Cpp17CopyConstructible
and
Cpp17CopyAssignable
requirements
.
The program is ill-formed if any of
(1.1)
is_
trivially_
copyable_
v
<
T
>
,
(1.2)
is_
copy_
constructible_
v
<
T
>
,
(1.3)
is_
move_
constructible_
v
<
T
>
,
(1.4)
is_
copy_
assignable_
v
<
T
>
,
(1.5)
is_
move_
assignable_
v
<
T
>
, or
(1.6)
same_
as
<
T, remove_
cv_
t
<
T
>
>
,
is
false
.
[
Note
1
:
Type arguments that are not also statically initializable can be difficult to use
.
—
end note
]
2
#
The specialization
atomic
<
bool
>
is a standard-layout struct
.
It has a trivial destructor
.
3
#
[
Note
2
:
The representation of an atomic specialization need not have the same size and alignment requirement as its corresponding argument type
.
—
end note
]