|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
atomic::atomic | ||||
(C++20) | ||||
(C++20) | ||||
(C++20) | ||||
| Constants | ||||
(C++17) | ||||
| Specialized member functions | ||||
| Specialized for integral, floating-point(C++20) and pointer types | ||||
| Specialized for integral and pointer types only | ||||
(C++26) | ||||
(C++26) | ||||
| Specialized for integral types only | ||||
| (1) | ||
atomic()noexcept=default; | (since C++11) (until C++20) | |
constexpr atomic()noexcept(std::is_nothrow_default_constructible_v<T>); | (since C++20) | |
constexpr atomic( T desired)noexcept; | (2) | (since C++11) |
atomic(const atomic&)= delete; | (3) | (since C++11) |
Constructs a new atomic variable.
1) The default constructor is trivial: no initialization takes place other thanzero initialization of static and thread-local objects. std::atomic_init may be used to complete initialization. | (until C++20) |
1) Value-initializes the underlying object (i.e. withT()). The initialization is not atomic. This overload participates in overload resolution only ifstd::is_default_constructible_v<T> istrue. | (since C++20) |
| desired | - | value to initialize with |
The default-initializedstd::atomic<T> does not contain a | (until C++20) |
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 4169 | C++20 | std::is_default_constructible_v could report false positive | the default constructor is constrained |