A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../memory/polymorphic_allocator/construct.html below:

std::pmr::polymorphic_allocator<T>::construct - cppreference.com

template< class U, class... Args >
void construct( U* p, Args&&... args );

(1) (since C++17) (2) (since C++17)
(until C++20) template< class T1, class T2 >
void construct( std::pair<T1, T2>* p );
(3) (since C++17)
(until C++20) template< class T1, class T2, class U, class V >
void construct( std::pair<T1, T2>* p, U&& x, V&& y );
(4) (since C++17)
(until C++20) template< class T1, class T2, class U, class V >
void construct( std::pair<T1, T2>* p, const std::pair<U, V>& xy );
(5) (since C++17)
(until C++20) template< class T1, class T2, class U, class V >
void construct( std::pair<T1, T2>* p, std::pair<U, V>&& xy );
(6) (since C++17)
(until C++20) template< class T1, class T2, class NonPair >
void construct( std::pair<T1, T2>* p, NonPair&& non_pair );
(7) (since C++17)
(until C++20)

Constructs an object in allocated, but not initialized storage pointed to by p the provided constructor arguments. If the object is of type that itself uses allocators, or if it is std::pair, passes *this down to the constructed object.

1)

Creates an object of the given type

U

by means of

uses-allocator construction

at the uninitialized memory location indicated by

p

, using

*this

as the allocator.

This overload participates in overload resolution only if U is not a specialization of std::pair.(until C++20)

2) First, if either T1 or T2 is allocator-aware, modifies the tuples x and y to include this->resource(), resulting in the two new tuples xprime and yprime, according to the following three rules:

2d) Otherwise, the program is ill-formed.

Same rules apply to T2 and the replacement of y with yprime.

Once

xprime

and

yprime

are constructed, constructs the pair

p

in allocated storage as if by

::new((void *) p) pair<T1, T2>(std::piecewise_construct, std::move(xprime), std::move(yprime));

.

7)

This overload participates in overload resolution only if given the exposition-only function template

template< class A, class B >
void /*deduce-as-pair*/( const std::pair<A, B>& );

, /*deduce-as-pair*/(non_pair) is ill-formed when considered as an unevaluated operand. Equivalent to

construct<T1, T2, T1, T2>(p, std::forward<NonPair>(non_pair));
(until C++20) [edit] Parameters p - pointer to allocated, but not initialized storage args... - the constructor arguments to pass to the constructor of T x - the constructor arguments to pass to the constructor of T1 y - the constructor arguments to pass to the constructor of T2 xy - the pair whose two members are the constructor arguments for T1 and T2 non_pair - non-pair argument to convert to pair for further construction [edit] Return value

(none)

[edit] Notes

This function is called (through std::allocator_traits) by any allocator-aware object, such as std::pmr::vector (or another std::vector that was given a std::pmr::polymorphic_allocator as the allocator to use).

[edit] Defect reports

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

DR Applied to Behavior as published Correct behavior LWG 2969 C++17 uses-allocator construction passed resource() passes *this LWG 2975 C++17 first overload is mistakenly used for pair construction in some cases constrained to not accept pairs LWG 3525 C++17 no overload could handle non-pair types convertible to pair reconstructing overload added [edit] See also constructs an object in the allocated storage
(function template) [edit] constructs an object in allocated storage
(public member function of std::allocator<T>) [edit]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4