|
56 | 56 | // \ref{atomics.types.pointer}, partial specialization for pointers
|
57 | 57 | template<class T> struct atomic<T*>;
|
58 | 58 |
|
59 |
| - // \ref{atomics.types.operations}, initialization |
60 |
| - #define ATOMIC_VAR_INIT(value) @\seebelow@ |
61 |
| - |
62 | 59 | // \ref{atomics.nonmembers}, non-member functions
|
63 | 60 | template<class T>
|
64 | 61 | bool atomic_is_lock_free(const volatile atomic<T>*) noexcept;
|
65 | 62 | template<class T>
|
66 | 63 | bool atomic_is_lock_free(const atomic<T>*) noexcept;
|
67 |
| - template<class T> |
68 |
| - void atomic_init(volatile atomic<T>*, typename atomic<T>::value_type) noexcept; |
69 |
| - template<class T> |
70 |
| - void atomic_init(atomic<T>*, typename atomic<T>::value_type) noexcept; |
71 | 64 | template<class T>
|
72 | 65 | void atomic_store(volatile atomic<T>*, typename atomic<T>::value_type) noexcept;
|
73 | 66 | template<class T>
|
|
261 | 254 | // \ref{atomics.flag}, flag type and operations
|
262 | 255 | struct atomic_flag;
|
263 | 256 |
|
264 |
| - #define ATOMIC_FLAG_INIT @\seebelow@ |
265 |
| - |
266 | 257 | bool atomic_flag_test(const volatile atomic_flag*) noexcept;
|
267 | 258 | bool atomic_flag_test(const atomic_flag*) noexcept;
|
268 | 259 | bool atomic_flag_test_explicit(const volatile atomic_flag*, memory_order) noexcept;
|
|
1551 | 1542 | bool is_lock_free() const volatile noexcept;
|
1552 | 1543 | bool is_lock_free() const noexcept;
|
1553 | 1544 |
|
1554 |
| - atomic() noexcept = default; |
| 1545 | + constexpr atomic() noexcept(is_nothrow_default_constructible_v<T>); |
1555 | 1546 | constexpr atomic(T) noexcept;
|
1556 | 1547 | atomic(const atomic&) = delete;
|
1557 | 1548 | atomic& operator=(const atomic&) = delete;
|
|
1625 | 1616 | operations on non-volatile objects become volatile.
|
1626 | 1617 | \end{note}
|
1627 | 1618 |
|
1628 |
| -\indexlibraryglobal{ATOMIC_VAR_INIT}% |
1629 |
| -\begin{itemdecl} |
1630 |
| -#define ATOMIC_VAR_INIT(value) @\seebelow@ |
1631 |
| -\end{itemdecl} |
1632 |
| - |
1633 |
| -\begin{itemdescr} |
1634 |
| -\pnum |
1635 |
| -The macro expands to a token sequence suitable for |
1636 |
| -constant initialization of |
1637 |
| -an atomic variable of static storage duration of a type that is |
1638 |
| -initialization-compatible with \tcode{value}. |
1639 |
| -\begin{note} |
1640 |
| -This operation may need to initialize locks. |
1641 |
| -\end{note} |
1642 |
| -Concurrent access to the variable being initialized, even via an atomic operation, |
1643 |
| -constitutes a data race. |
1644 |
| -\begin{example} |
1645 |
| -\begin{codeblock} |
1646 |
| -atomic<int> v = ATOMIC_VAR_INIT(5); |
1647 |
| -\end{codeblock} |
1648 |
| -\end{example} |
1649 |
| -\end{itemdescr} |
1650 |
| - |
1651 | 1619 | \indexlibraryctor{atomic}%
|
1652 | 1620 | \indexlibraryctor{atomic<T*>}%
|
1653 | 1621 | \indexlibrary{\idxcode{atomic<\placeholder{integral}>}!constructor}%
|
1654 | 1622 | \indexlibrary{\idxcode{atomic<\placeholder{floating-point}>}!constructor}%
|
1655 | 1623 | \begin{itemdecl}
|
1656 |
| -atomic() noexcept = default; |
| 1624 | +constexpr atomic() noexcept(is_nothrow_default_constructible_v<T>); |
1657 | 1625 | \end{itemdecl}
|
1658 | 1626 |
|
1659 | 1627 | \begin{itemdescr}
|
| 1628 | +\pnum |
| 1629 | +\mandates |
| 1630 | +\tcode{is_default_constructible_v<T>} is \tcode{true}. |
| 1631 | + |
1660 | 1632 | \pnum
|
1661 | 1633 | \effects
|
1662 |
| -Leaves the atomic object in an uninitialized state. |
1663 |
| -\begin{note} |
1664 |
| -These semantics ensure compatibility with C. |
1665 |
| -\end{note} |
| 1634 | +Initializes the atomic object with the value of \tcode{T()}. |
| 1635 | +Initialization is not an atomic operation\iref{intro.multithread}. |
1666 | 1636 | \end{itemdescr}
|
1667 | 1637 |
|
1668 | 1638 | \indexlibraryctor{atomic}%
|
|
2118 | 2088 | bool is_lock_free() const volatile noexcept;
|
2119 | 2089 | bool is_lock_free() const noexcept;
|
2120 | 2090 |
|
2121 |
| - atomic() noexcept = default; |
| 2091 | + constexpr atomic() noexcept; |
2122 | 2092 | constexpr atomic(@\placeholdernc{integral}@) noexcept;
|
2123 | 2093 | atomic(const atomic&) = delete;
|
2124 | 2094 | atomic& operator=(const atomic&) = delete;
|
|
2195 | 2165 | \pnum
|
2196 | 2166 | The atomic integral specializations
|
2197 | 2167 | are standard-layout structs.
|
2198 |
| -They each have a trivial default constructor |
2199 |
| -and a trivial destructor. |
| 2168 | +They each have |
| 2169 | +a trivial destructor. |
2200 | 2170 |
|
2201 | 2171 | \pnum
|
2202 | 2172 | Descriptions are provided below only for members that differ from the primary template.
|
|
2318 | 2288 | bool is_lock_free() const volatile noexcept;
|
2319 | 2289 | bool is_lock_free() const noexcept;
|
2320 | 2290 |
|
2321 |
| - atomic() noexcept = default; |
| 2291 | + constexpr atomic() noexcept; |
2322 | 2292 | constexpr atomic(@\placeholder{floating-point}@) noexcept;
|
2323 | 2293 | atomic(const atomic&) = delete;
|
2324 | 2294 | atomic& operator=(const atomic&) = delete;
|
|
2381 | 2351 | \pnum
|
2382 | 2352 | The atomic floating-point specializations
|
2383 | 2353 | are standard-layout structs.
|
2384 |
| -They each have a trivial default constructor |
2385 |
| -and a trivial destructor. |
| 2354 | +They each have |
| 2355 | +a trivial destructor. |
2386 | 2356 |
|
2387 | 2357 | \pnum
|
2388 | 2358 | Descriptions are provided below only for members that differ from the primary template.
|
|
2467 | 2437 | bool is_lock_free() const volatile noexcept;
|
2468 | 2438 | bool is_lock_free() const noexcept;
|
2469 | 2439 |
|
2470 |
| - atomic() noexcept = default; |
| 2440 | + constexpr atomic() noexcept; |
2471 | 2441 | constexpr atomic(T*) noexcept;
|
2472 | 2442 | atomic(const atomic&) = delete;
|
2473 | 2443 | atomic& operator=(const atomic&) = delete;
|
|
2529 | 2499 | \pnum
|
2530 | 2500 | There is a partial specialization of the \tcode{atomic} class template for pointers.
|
2531 | 2501 | Specializations of this partial specialization are standard-layout structs.
|
2532 |
| -They each have a trivial default constructor and a trivial destructor. |
| 2502 | +They each have a trivial destructor. |
2533 | 2503 |
|
2534 | 2504 | \pnum
|
2535 | 2505 | Descriptions are provided below only for members that differ from the primary template.
|
|
2717 | 2687 | void notify_one() noexcept;
|
2718 | 2688 | void notify_all() noexcept;
|
2719 | 2689 |
|
2720 |
| - constexpr atomic() noexcept = default; |
| 2690 | + constexpr atomic() noexcept; |
2721 | 2691 | atomic(shared_ptr<T> desired) noexcept;
|
2722 | 2692 | atomic(const atomic&) = delete;
|
2723 | 2693 | void operator=(const atomic&) = delete;
|
|
2731 | 2701 |
|
2732 | 2702 | \indexlibraryctor{atomic<shared_ptr<T>>}%
|
2733 | 2703 | \begin{itemdecl}
|
2734 |
| -constexpr atomic() noexcept = default; |
| 2704 | +constexpr atomic() noexcept; |
2735 | 2705 | \end{itemdecl}
|
2736 | 2706 |
|
2737 | 2707 | \begin{itemdescr}
|
|
3025 | 2995 | void notify_one() noexcept;
|
3026 | 2996 | void notify_all() noexcept;
|
3027 | 2997 |
|
3028 |
| - constexpr atomic() noexcept = default; |
| 2998 | + constexpr atomic() noexcept; |
3029 | 2999 | atomic(weak_ptr<T> desired) noexcept;
|
3030 | 3000 | atomic(const atomic&) = delete;
|
3031 | 3001 | void operator=(const atomic&) = delete;
|
|
3039 | 3009 |
|
3040 | 3010 | \indexlibraryctor{atomic<weak_ptr<T>>}%
|
3041 | 3011 | \begin{itemdecl}
|
3042 |
| -constexpr atomic() noexcept = default; |
| 3012 | +constexpr atomic() noexcept; |
3043 | 3013 | \end{itemdecl}
|
3044 | 3014 |
|
3045 | 3015 | \begin{itemdescr}
|
|
3316 | 3286 | passed to the member function call.
|
3317 | 3287 | If no such member function exists, the program is ill-formed.
|
3318 | 3288 |
|
3319 |
| -\indexlibraryglobal{atomic_init}% |
3320 |
| -\begin{itemdecl} |
3321 |
| -template<class T> |
3322 |
| - void atomic_init(volatile atomic<T>* object, typename atomic<T>::value_type desired) noexcept; |
3323 |
| -template<class T> |
3324 |
| - void atomic_init(atomic<T>* object, typename atomic<T>::value_type desired) noexcept; |
3325 |
| -\end{itemdecl} |
3326 |
| - |
3327 |
| -\begin{itemdescr} |
3328 |
| -\pnum |
3329 |
| -\effects |
3330 |
| -Non-atomically |
3331 |
| -initializes \tcode{*object} with value \tcode{desired}. This function shall only be applied |
3332 |
| -to objects that have been default constructed, and then only once. |
3333 |
| -\begin{note} |
3334 |
| -These semantics ensure compatibility with C. |
3335 |
| -\end{note} |
3336 |
| -\begin{note} |
3337 |
| -Concurrent access from another thread, even via an atomic operation, constitutes |
3338 |
| -a data race. |
3339 |
| -\end{note} |
3340 |
| -\end{itemdescr} |
3341 |
| - |
3342 | 3289 | \pnum
|
3343 | 3290 | \begin{note}
|
3344 | 3291 | The non-member functions enable programmers to write code that can be
|
|
3350 | 3297 | \begin{codeblock}
|
3351 | 3298 | namespace std {
|
3352 | 3299 | struct atomic_flag {
|
3353 |
| - atomic_flag() noexcept = default; |
| 3300 | + constexpr atomic_flag() noexcept; |
3354 | 3301 | atomic_flag(const atomic_flag&) = delete;
|
3355 | 3302 | atomic_flag& operator=(const atomic_flag&) = delete;
|
3356 | 3303 | atomic_flag& operator=(const atomic_flag&) volatile = delete;
|
|
3384 | 3331 |
|
3385 | 3332 | \pnum
|
3386 | 3333 | The \tcode{atomic_flag} type is a standard-layout struct.
|
3387 |
| -It has a trivial default constructor and a trivial destructor. |
| 3334 | +It has a trivial destructor. |
3388 | 3335 |
|
3389 |
| -\indexlibraryglobal{ATOMIC_FLAG_INIT}% |
| 3336 | +\indexlibraryctor{atomic_flag}% |
3390 | 3337 | \begin{itemdecl}
|
3391 |
| -#define ATOMIC_FLAG_INIT @\seebelow@ |
| 3338 | +constexpr atomic_flag::atomic_flag() noexcept; |
3392 | 3339 | \end{itemdecl}
|
3393 | 3340 |
|
3394 | 3341 | \begin{itemdescr}
|
3395 | 3342 | \pnum
|
3396 |
| -\remarks |
3397 |
| -The macro \tcode{ATOMIC_FLAG_INIT} shall be defined in such a way that it can be used to initialize an object of type \tcode{atomic_flag} to the |
3398 |
| -clear state. The macro can be used in the form: |
3399 |
| -\begin{codeblock} |
3400 |
| -atomic_flag guard = ATOMIC_FLAG_INIT; |
3401 |
| -\end{codeblock} |
3402 |
| -It is unspecified whether the macro can be used in other initialization contexts. |
3403 |
| -For a complete static-duration object, that initialization shall be static. |
3404 |
| -Unless initialized with \tcode{ATOMIC_FLAG_INIT}, it is unspecified whether an |
3405 |
| -\tcode{atomic_flag} object has an initial state of set or clear. |
| 3343 | +\effects |
| 3344 | +Initializes \tcode{*this} to the clear state. |
3406 | 3345 | \end{itemdescr}
|
3407 | 3346 |
|
3408 | 3347 | \indexlibraryglobal{atomic_flag_test}%
|
|
0 commit comments