FreeBSD Manual Pages
std::pmr::p...::construct(3) C++ Standard Libary std::pmr::p...::construct(3) NAME std::pmr::polymorphic_allocator::construct - std::pmr::polymorphic_al- locator::construct Synopsis template < class U, class... Args > (1) (since C++17) void construct( U* p, Args&&... args ); template< class T1, class T2, class... Args1, class... Args2 > void construct( std::pair<T1, T2>* p, (since C++17) std::piecewise_construct_t, (2) (until C++20) std::tuple<Args1...> x, std::tuple<Args2...> y ); template< class T1, class T2 > (3) (since C++17) void construct( std::pair<T1, T2>* p ); (until C++20) template< class T1, class T2, class U, class V > (4) (since C++17) void construct( std::pair<T1, T2>* p, U&& x, V&& y ); (until C++20) template< class T1, class T2, class U, class V > (5) (since C++17) void construct( std::pair<T1, T2>* p, const std::pair<U, V>& xy ); (until C++20) template< class T1, class T2, class U, class V > (6) (since C++17) void construct( std::pair<T1, T2>* p, std::pair<U, V>&& xy ); (until C++20) template< class T1, class T2, class NonPair > (7) (since C++17) void construct( std::pair<T1, T2>* p, NonPair&& non_pair ); (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->resource() 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: 2a) if T1 is not allocator-aware (std::uses_allocator<T1, polymorphic_alloca- tor>::value==false) and std::is_constructible<T1, Args1...>::value==true, then xprime is x, unmodified. 2b) if T1 is al- locator-aware (std::uses_allocator<T1, polymorphic_alloca- tor>::value==true), and its constructor takes an allocator tag (std::is_constructible<T1, std::allocator_arg_t, polymorphic_allocator, Args1...>::value==true, then xprime is std::tuple_cat(std::make_tu- ple(std::allocator_arg, *this), std::move(x)) 2c) if T1 is allocator- aware (std::uses_allocator<T1, polymorphic_allocator>::value==true), and its constructor takes the allocator as the last argument (std::is_constructible<T1, Args1..., polymorphic_alloca- tor>::value==true), then xprime is std::tuple_cat(std::move(x), std::make_tuple(*this)). 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_con- struct, std::move(xprime), std::move(yprime)); 3) Equivalent to con- struct(p, std::piecewise_construct, std::tuple<>(), std::tuple<>()), that is, passes the memory resource on to the pair's member types if they accept them. 4) Equivalent to (until C++20) construct(p, std::piecewise_construct, std::forward_as_tuple(std::for- ward<U>(x)), std::forward_as_tuple(std::for- ward<V>(y))) 5) Equivalent to construct(p, std::piecewise_construct, std::forward_as_tuple(xy.first), std::forward_as_tuple(xy.sec- ond)) 6) Equivalent to construct(p, std::piecewise_construct, std::forward_as_tuple(std::for- ward<U>(xy.first)), std::forward_as_tuple(std::for- ward<V>(xy.second))) 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 un- evaluated operand. Equivalent to construct<T1, T2, T1, T2>(p, std::forward<NonPair>(non_pair)); 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 con- struction Return value (none) Notes This function is called (through std::allocator_traits) by any allo- cator-aware object, such as std::pmr::vector (or another std::vector that was given a std::pmr::polymorphic_allocator as the allocator to use). Defect reports The following behavior-changing defect reports were applied retroac- tively to previously published C++ standards. DR Applied to Behavior as published Cor- rect behavior LWG 2969 C++17 uses-allocator construction passed passes *this resource() LWG 2975 C++17 first overload is mistakenly used for con- strained to not accept pair construction in some cases pairs LWG 3525 C++17 no overload could handle non-pair recon- structing overload types convertible to pair added See also construct constructs an object in the allocated storage [static] (function template) construct constructs an object in allocated storage (until C++20) (public member function of std::allocator<T>) http://cppreference.com 2022.07.31 std::pmr::p...::construct(3)
NAME | Synopsis | Parameters | Return value | Notes | See also
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::pmr::polymorphic_allocator::construct&sektion=3&manpath=FreeBSD+Ports+15.0>
