Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/memory/allocator traits/select on container copy construction"

From cppreference.com
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}}
{{ddcl list begin}}
+
{{dcl begin}}
{{ddcl list header|memory}}
+
{{dcl header|memory}}
{{ddcl list item | notes={{mark since c++11}} |  
+
{{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 );
 
}}
 
}}
{{ddcl list end}}
+
{{dcl end}}
  
If possible, obtains the copy-constructed version of the allocator {{tt|a}}, by calling {{c|a.select_on_container_copy_construction() }}. If the above is not possible (e.g. {{tt|a}} does not have the member function {{tt|select_on_container_copy_construction()}}, then returns {{c|a}}, unmodified.
+
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===
{{param list begin}}
+
{{par begin}}
{{param list item | a | allocator used by a standard container passed as an argument to a container copy constructor }}
+
{{par|a|allocator used by a standard container passed as an argument to a container copy constructor}}
{{param list end}}
+
{{par end}}
 
+
  
 
===Return value===
 
===Return value===
The allocator to use by the the copy-constructed standard containers.
+
The allocator to use by the copy-constructed standard containers.
  
 
===See also===
 
===See also===
{{dcl list begin}}
+
{{dsc begin}}
{{dcl list template | cpp/memory/scoped_allocator_adaptor/dcl list select_on_container_copy_construction}}
+
{{dsc inc|cpp/memory/scoped_allocator_adaptor/dsc select_on_container_copy_construction}}
{{dcl list end}}
+
{{dsc end}}
  
[[de:cpp/memory/allocator traits/select on container copy construction]]
+
{{langlinks|de|es|fr|it|ja|pt|ru|zh}}
[[es:cpp/memory/allocator traits/select on container copy construction]]
+
[[fr:cpp/memory/allocator traits/select on container copy construction]]
+
[[it:cpp/memory/allocator traits/select on container copy construction]]
+
[[ja:cpp/memory/allocator traits/select on container copy construction]]
+
[[pt:cpp/memory/allocator traits/select on container copy construction]]
+
[[ru:cpp/memory/allocator traits/select on container copy construction]]
+
[[zh:cpp/memory/allocator traits/select on container copy construction]]
+

Latest revision as of 06:35, 1 July 2024

 
 
Dynamic memory management
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Allocators
Garbage collection support
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)



 
 
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...>) [edit]