std::scoped...ator_adaptor(3)

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

hey bestie 🫢 you're on the std::scoped...ator_adaptor(3) page from the C++ Standard Libary (that's the manual name, typed exactly like that here πŸ’…), and we're about to make these constructors make sense. no cap. ✨

🌸 NAME 🌸

std::scoped_allocator_adaptor::scoped_allocator_adaptor β€” the constructor for std::scoped_allocator_adaptor, and yes its name is literally std::scoped_allocator_adaptor::scoped_allocator_adaptor again. iconic echo behavior πŸ˜­πŸ’–

✨ Synopsis ✨

Defined in header <scoped_allocator>.

scoped_allocator_adaptor(); // (1) (since C++11)

template< class OuterA2 >
scoped_allocator_adaptor(
    OuterA2&& outerAlloc, const InnerAllocs&... innerAllocs
) noexcept; // (2) (since C++11)

scoped_allocator_adaptor(
    const scoped_allocator_adaptor& other
) noexcept; // (3) (since C++11)

scoped_allocator_adaptor(
    scoped_allocator_adaptor&& other
) noexcept; // (4) (since C++11)

template< class OuterA2 >
scoped_allocator_adaptor(
    const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& other
) noexcept; // (5) (since C++11)

template< class OuterA2 >
scoped_allocator_adaptor(
    scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other
) noexcept; // (6) (since C++11)

Now the six overloads, in order, no skipping, bestie:

  1. Default constructor: value-initializes the OuterAlloc base class and the inner allocator member object, if used by the implementation. (since C++11)
  2. Constructs the base class OuterAlloc from std::forward<OuterA2>(outerAlloc), and the inner allocators with innerAllocs.... This overload participates in overload resolution only if std::is_constructible<OuterAlloc, OuterA2>::value is true. (since C++11)
  3. Copy-constructor: initializes each allocator from the corresponding allocator of other. (since C++11)
  4. Move-constructor: moves each allocator from the corresponding allocator of other into *this. (since C++11)
  5. Initializes each allocator from the corresponding allocator of other. This overload participates in overload resolution only if std::is_constructible<OuterAlloc, const OuterA2&>::value is true. (since C++11)
  6. Initializes each allocator from the corresponding allocator of other, using move semantics. This overload participates in overload resolution only if std::is_constructible<OuterAlloc, OuterA2>::value is true. (since C++11)

πŸ’… Parameters πŸ’…

  • outerAlloc β€” constructor argument for the outer allocator. 🫢
  • innerAllocs... β€” constructor arguments for the inner allocators. ✨
  • other β€” another std::scoped_allocator_adaptor. πŸ’–

🩹 Defect reports 🩹

The following behavior-changing defect reports were applied retroactively to previously published C++ standards. lowkey important to know 🧚

  • DR: LWG 2782 β€” Applied to: C++11 β€” Behavior as published: constructors taking OuterA2 weren't constrained, interfering with metaprogramming β€” Correct behavior: constraint added. πŸ’€βœ¨

πŸ‘€ See also πŸ‘€

  • allocate β€” allocates uninitialized storage using the outer allocator (public member function).
  • construct β€” constructs an object in allocated storage, passing the inner allocator to construct its constructor if appropriate (public member function).

mwah πŸ’‹ that's the whole page, bestie. sourced from http://cppreference.com, version/date 2024.06.10, and the page is std::scoped...ator_adaptor(3). slay πŸŽ€

πŸ“¦ where this page comes from