std::alloca...onstruction(3)

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

🌸 NAME 🌸

std::allocator_traits::select_on_container_copy_construction - std::allocator_traits::select_on_container_copy_construction. Yep, the page says the same name on both sides of the dash, and honestly? iconic πŸ’…. This is the (3) page, straight outta the C++ Standard Libary manual (that's the manual name, spelling included, periodt). It's all about the allocator-traits moment where a container copy asks, "bestie, which allocator should I use?" ✨

✨ Synopsis ✨

Defined in header <memory> πŸŽ€

static Alloc select_on_container_copy_construction( const Alloc& a );

(since C++11) (until C++20)

static constexpr Alloc select_on_container_copy_construction( const Alloc& a );

(since C++20)

Okay so if possible, obtains the copy-constructed version of the allocator a, by calling a.select_on_container_copy_construction(). 🫢 If the above is not possible (e.g. Alloc does not have the member function select_on_container_copy_construction()), then returns a, unmodified. No cap 😭.

This function is called by the copy constructors of all standard library containers. It allows the allocator used by the constructor's argument to become aware that the container is being copied and modify state if necessary. Main character allocator energy, fr fr 🌈.

πŸŽ€ Parameters πŸŽ€

  • a β€” allocator used by a standard container passed as an argument to a container copy constructor πŸ“

πŸ’– Return value πŸ’–

The allocator to use by the copy-constructed standard containers. That's the whole vibe check βœ….

πŸ¦‹ See also πŸ¦‹

  • select_on_container_copy_construction (public member function of std::scoped_allocator_adaptor<OuterAlloc,InnerAlloc...>) β€” copies the state of scoped_allocator_adaptor and all its allocators 🧚

Source/version/date sign-off: this page is from http://cppreference.com, with the 2024.06.10 date stamp. Stay allocator-aware and hydrated, bestie πŸ’œπŸŽ€

πŸ“¦ where this page comes from