31
Atomic operations library
[atomics]
31.8
Class template
atomic
[atomics.types.generic]
31.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
; T load
(
memory_order
=
memory_order
::
seq_cst
)
const
noexcept
;
operator
T
(
)
const
volatile
noexcept
;
operator
T
(
)
const
noexcept
;
void
store
(
T, memory_order
=
memory_order
::
seq_cst
)
volatile
noexcept
;
void
store
(
T, memory_order
=
memory_order
::
seq_cst
)
noexcept
; T
operator
=
(
T
)
volatile
noexcept
; T
operator
=
(
T
)
noexcept
; T exchange
(
T, memory_order
=
memory_order
::
seq_cst
)
volatile
noexcept
; T exchange
(
T, memory_order
=
memory_order
::
seq_cst
)
noexcept
;
bool
compare_exchange_weak
(
T
&
, T, memory_order, memory_order
)
volatile
noexcept
;
bool
compare_exchange_weak
(
T
&
, T, memory_order, memory_order
)
noexcept
;
bool
compare_exchange_strong
(
T
&
, T, memory_order, memory_order
)
volatile
noexcept
;
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
;
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
;
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
;
void
wait
(
T, memory_order
=
memory_order
::
seq_cst
)
const
noexcept
;
void
notify_one
(
)
volatile
noexcept
;
void
notify_one
(
)
noexcept
;
void
notify_all
(
)
volatile
noexcept
;
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
>
, or
(1.5)
is_move_assignable_v
<
T
>
is
false
.
[
Note
1
:
Type arguments that are not also statically initializable might be difficult to use
.
—
end note
]
2
#
The specialization
atomic
<
bool
>
is a standard-layout struct
.
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
]