std::atomic::atomic(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸŽ€ std::atomic::atomic(3) πŸŽ€

Okay bestie, this is the std::atomic::atomic(3) page from the C++ Standard Libary β€” yes, that's how the header spells it, and we are not fixing it, we are simply reading it. πŸ’… No cap, this is literally the constructor page for std::atomic, and it's giving "tiny page, big lifetime decisions." Slay. 🌈

πŸŽ€ NAME πŸŽ€

std::atomic::atomic β€” and that is exactly std::atomic::atomic. No mysterious alias, no extra name, just the constructor showing up with main character energy. πŸ‘‘

✨ Synopsis ✨

Here are the signatures, bestie β€” keep these exactly as written:

atomic() noexcept = default;
  • since C++11
  • until C++20
constexpr atomic() noexcept(std::is_nothrow_default_constructible_v<T>);
  • (1) 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. (until C++20) The default constructor is trivial: no initialization takes place other than zero initialization of static and thread-local objects. std::atomic_init may be used to complete initialization. (since C++20) Value-initializes the underlying object (i.e. with T()). The initialization is not atomic. The program is ill-formed if std::is_default_constructible_v<T> is false.
  2. Initializes the underlying object with desired. The initialization is not atomic.
  3. Atomic variables are not CopyConstructible.

πŸ’– Parameters πŸ’–

  • desired β€” value to initialize with

πŸ¦‹ Notes πŸ¦‹

Until C++20, the default-initialized std::atomic<T> does not contain a T object, and its only valid uses are destruction and initialization by std::atomic_init, see LWG issue 2334.


And that's the whole vibe check, bestie. This page came from http://cppreference.com, dated 2024.06.10, and it's the std::atomic::atomic(3) page β€” so now you know, and honestly? iconic. πŸ’œπŸŽ€

πŸ“¦ where this page comes from