|
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 | + // \ref{atomics.types.operations}, operations on atomic types |
| 1546 | + constexpr atomic() noexcept(is_nothrow_default_constructible_v<T>); |
1555 | 1547 | constexpr atomic(T) noexcept;
|
1556 | 1548 | atomic(const atomic&) = delete;
|
1557 | 1549 | atomic& operator=(const atomic&) = delete;
|
|
1625 | 1617 | operations on non-volatile objects become volatile.
|
1626 | 1618 | \end{note}
|
1627 | 1619 |
|
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 | 1620 | \indexlibraryctor{atomic}%
|
1652 | 1621 | \indexlibraryctor{atomic<T*>}%
|
1653 | 1622 | \indexlibrary{\idxcode{atomic<\placeholder{integral}>}!constructor}%
|
1654 | 1623 | \indexlibrary{\idxcode{atomic<\placeholder{floating-point}>}!constructor}%
|
1655 | 1624 | \begin{itemdecl}
|
1656 |
| -atomic() noexcept = default; |
| 1625 | +constexpr atomic() noexcept(is_nothrow_default_constructible_v<T>); |
1657 | 1626 | \end{itemdecl}
|
1658 | 1627 |
|
1659 | 1628 | \begin{itemdescr}
|
| 1629 | +\pnum |
| 1630 | +\mandates |
| 1631 | +\tcode{is_default_constructible_v<T>} is \tcode{true}. |
| 1632 | + |
1660 | 1633 | \pnum
|
1661 | 1634 | \effects
|
1662 |
| -Leaves the atomic object in an uninitialized state. |
1663 |
| -\begin{note} |
1664 |
| -These semantics ensure compatibility with C. |
1665 |
| -\end{note} |
| 1635 | +Initializes the atomic object with the value of \tcode{T()}. |
| 1636 | +Initialization is not an atomic operation\iref{intro.multithread}. |
1666 | 1637 | \end{itemdescr}
|
1667 | 1638 |
|
1668 | 1639 | \indexlibraryctor{atomic}%
|
|
2118 | 2089 | bool is_lock_free() const volatile noexcept;
|
2119 | 2090 | bool is_lock_free() const noexcept;
|
2120 | 2091 |
|
2121 |
| - atomic() noexcept = default; |
| 2092 | + constexpr atomic() noexcept; |
2122 | 2093 | constexpr atomic(@\placeholdernc{integral}@) noexcept;
|
2123 | 2094 | atomic(const atomic&) = delete;
|
2124 | 2095 | atomic& operator=(const atomic&) = delete;
|
|
2195 | 2166 | \pnum
|
2196 | 2167 | The atomic integral specializations
|
2197 | 2168 | are standard-layout structs.
|
2198 |
| -They each have a trivial default constructor |
2199 |
| -and a trivial destructor. |
| 2169 | +They each have |
| 2170 | +a trivial destructor. |
2200 | 2171 |
|
2201 | 2172 | \pnum
|
2202 | 2173 | Descriptions are provided below only for members that differ from the primary template.
|
|
2318 | 2289 | bool is_lock_free() const volatile noexcept;
|
2319 | 2290 | bool is_lock_free() const noexcept;
|
2320 | 2291 |
|
2321 |
| - atomic() noexcept = default; |
| 2292 | + constexpr atomic() noexcept; |
2322 | 2293 | constexpr atomic(@\placeholder{floating-point}@) noexcept;
|
2323 | 2294 | atomic(const atomic&) = delete;
|
2324 | 2295 | atomic& operator=(const atomic&) = delete;
|
|
2381 | 2352 | \pnum
|
2382 | 2353 | The atomic floating-point specializations
|
2383 | 2354 | are standard-layout structs.
|
2384 |
| -They each have a trivial default constructor |
2385 |
| -and a trivial destructor. |
| 2355 | +They each have |
| 2356 | +a trivial destructor. |
2386 | 2357 |
|
2387 | 2358 | \pnum
|
2388 | 2359 | Descriptions are provided below only for members that differ from the primary template.
|
|
2467 | 2438 | bool is_lock_free() const volatile noexcept;
|
2468 | 2439 | bool is_lock_free() const noexcept;
|
2469 | 2440 |
|
2470 |
| - atomic() noexcept = default; |
| 2441 | + constexpr atomic() noexcept; |
2471 | 2442 | constexpr atomic(T*) noexcept;
|
2472 | 2443 | atomic(const atomic&) = delete;
|
2473 | 2444 | atomic& operator=(const atomic&) = delete;
|
|
2529 | 2500 | \pnum
|
2530 | 2501 | There is a partial specialization of the \tcode{atomic} class template for pointers.
|
2531 | 2502 | Specializations of this partial specialization are standard-layout structs.
|
2532 |
| -They each have a trivial default constructor and a trivial destructor. |
| 2503 | +They each have a trivial destructor. |
2533 | 2504 |
|
2534 | 2505 | \pnum
|
2535 | 2506 | Descriptions are provided below only for members that differ from the primary template.
|
|
2717 | 2688 | void notify_one() noexcept;
|
2718 | 2689 | void notify_all() noexcept;
|
2719 | 2690 |
|
2720 |
| - constexpr atomic() noexcept = default; |
| 2691 | + constexpr atomic() noexcept; |
2721 | 2692 | atomic(shared_ptr<T> desired) noexcept;
|
2722 | 2693 | atomic(const atomic&) = delete;
|
2723 | 2694 | void operator=(const atomic&) = delete;
|
|
2731 | 2702 |
|
2732 | 2703 | \indexlibraryctor{atomic<shared_ptr<T>>}%
|
2733 | 2704 | \begin{itemdecl}
|
2734 |
| -constexpr atomic() noexcept = default; |
| 2705 | +constexpr atomic() noexcept; |
2735 | 2706 | \end{itemdecl}
|
2736 | 2707 |
|
2737 | 2708 | \begin{itemdescr}
|
|
3025 | 2996 | void notify_one() noexcept;
|
3026 | 2997 | void notify_all() noexcept;
|
3027 | 2998 |
|
3028 |
| - constexpr atomic() noexcept = default; |
| 2999 | + constexpr atomic() noexcept; |
3029 | 3000 | atomic(weak_ptr<T> desired) noexcept;
|
3030 | 3001 | atomic(const atomic&) = delete;
|
3031 | 3002 | void operator=(const atomic&) = delete;
|
|
3039 | 3010 |
|
3040 | 3011 | \indexlibraryctor{atomic<weak_ptr<T>>}%
|
3041 | 3012 | \begin{itemdecl}
|
3042 |
| -constexpr atomic() noexcept = default; |
| 3013 | +constexpr atomic() noexcept; |
3043 | 3014 | \end{itemdecl}
|
3044 | 3015 |
|
3045 | 3016 | \begin{itemdescr}
|
|
3316 | 3287 | passed to the member function call.
|
3317 | 3288 | If no such member function exists, the program is ill-formed.
|
3318 | 3289 |
|
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 | 3290 | \pnum
|
3343 | 3291 | \begin{note}
|
3344 | 3292 | The non-member functions enable programmers to write code that can be
|
|
3350 | 3298 | \begin{codeblock}
|
3351 | 3299 | namespace std {
|
3352 | 3300 | struct atomic_flag {
|
3353 |
| - atomic_flag() noexcept = default; |
| 3301 | + constexpr atomic_flag() noexcept; |
3354 | 3302 | atomic_flag(const atomic_flag&) = delete;
|
3355 | 3303 | atomic_flag& operator=(const atomic_flag&) = delete;
|
3356 | 3304 | atomic_flag& operator=(const atomic_flag&) volatile = delete;
|
|
3384 | 3332 |
|
3385 | 3333 | \pnum
|
3386 | 3334 | The \tcode{atomic_flag} type is a standard-layout struct.
|
3387 |
| -It has a trivial default constructor and a trivial destructor. |
| 3335 | +It has a trivial destructor. |
3388 | 3336 |
|
3389 |
| -\indexlibraryglobal{ATOMIC_FLAG_INIT}% |
| 3337 | +\indexlibraryctor{atomic_flag}% |
3390 | 3338 | \begin{itemdecl}
|
3391 |
| -#define ATOMIC_FLAG_INIT @\seebelow@ |
| 3339 | +constexpr atomic_flag::atomic_flag() noexcept; |
3392 | 3340 | \end{itemdecl}
|
3393 | 3341 |
|
3394 | 3342 | \begin{itemdescr}
|
3395 | 3343 | \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. |
| 3344 | +\effects |
| 3345 | +Initializes \tcode{*this} to the clear state. |
3406 | 3346 | \end{itemdescr}
|
3407 | 3347 |
|
3408 | 3348 | \indexlibraryglobal{atomic_flag_test}%
|
|
0 commit comments