Difference between revisions of "cpp/memory/allocator traits/select on container copy construction"
From cppreference.com
< cpp | memory | allocator traits
m (r2.7.3) (Robot: Adding de, es, fr, it, ja, pt, ru, zh) |
m (constexpr=) |
||
(8 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
{{cpp/memory/allocator_traits/title|select_on_container_copy_construction}} | {{cpp/memory/allocator_traits/title|select_on_container_copy_construction}} | ||
{{cpp/memory/allocator_traits/navbar}} | {{cpp/memory/allocator_traits/navbar}} | ||
− | {{ | + | {{dcl begin}} |
− | {{ | + | {{dcl header|memory}} |
− | {{ | + | {{dcla|since=c++11|constexpr=c++20| |
− | static Alloc select_on_container_copy_construction( const Alloc& a ) | + | static Alloc select_on_container_copy_construction( const Alloc& a ); |
}} | }} | ||
− | {{ | + | {{dcl end}} |
− | If possible, obtains the copy-constructed version of the allocator {{ | + | If possible, obtains the copy-constructed version of the allocator {{c|a}}, by calling {{c|a.select_on_container_copy_construction()}}. If the above is not possible (e.g. {{tt|Alloc}} does not have the member function {{tt|select_on_container_copy_construction()}}), then returns {{c|a}}, unmodified. |
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. | 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. | ||
===Parameters=== | ===Parameters=== | ||
− | {{ | + | {{par begin}} |
− | {{ | + | {{par|a|allocator used by a standard container passed as an argument to a container copy constructor}} |
− | {{ | + | {{par end}} |
− | + | ||
===Return value=== | ===Return value=== | ||
− | The allocator to use by | + | The allocator to use by the copy-constructed standard containers. |
===See also=== | ===See also=== | ||
− | {{ | + | {{dsc begin}} |
− | {{ | + | {{dsc inc|cpp/memory/scoped_allocator_adaptor/dsc select_on_container_copy_construction}} |
− | {{ | + | {{dsc end}} |
− | + | {{langlinks|de|es|fr|it|ja|pt|ru|zh}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
Latest revision as of 06:35, 1 July 2024
Defined in header <memory>
|
||
static Alloc select_on_container_copy_construction( const Alloc& a ); |
(since C++11) (constexpr since C++20) |
|
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.
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.
[edit] Parameters
a | - | allocator used by a standard container passed as an argument to a container copy constructor |
[edit] Return value
The allocator to use by the copy-constructed standard containers.
[edit] See also
copies the state of scoped_allocator_adaptor and all its allocators (public member function of std::scoped_allocator_adaptor<OuterAlloc,InnerAlloc...> )
|