Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::uses_allocator_construction_args

      From cppreference.com
      <cpp‎ |memory
       
       
      Memory management library
      (exposition only*)
      Allocators
      uses_allocator_construction_args
      (C++20)
      Uninitialized memory algorithms
      Constrained uninitialized memory algorithms
      Memory resources
      Uninitialized storage(until C++20)
      (until C++20*)
      (until C++20*)
      Garbage collector support(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)
      (C++11)(until C++23)
       
      Defined in header<memory>
      T is not a specialization ofstd::pair
      template<class T,class Alloc,class...Args>

      constexprauto uses_allocator_construction_args(const Alloc& alloc,

          Args&&...args)noexcept;
      (1)(since C++20)
      T is a specialization ofstd::pair
      template<class T,class Alloc,class Tuple1,class Tuple2>

      constexprauto uses_allocator_construction_args(const Alloc& alloc,

         std::piecewise_construct_t, Tuple1&& x, Tuple2&& y)noexcept;
      (2)(since C++20)
      template<class T,class Alloc>
      constexprauto uses_allocator_construction_args(const Alloc& alloc)noexcept;
      (3)(since C++20)
      template<class T,class Alloc,class U,class V>

      constexprauto uses_allocator_construction_args(const Alloc& alloc,

          U&& u, V&& v)noexcept;
      (4)(since C++20)
      template<class T,class Alloc,class U,class V>

      constexprauto uses_allocator_construction_args(const Alloc& alloc,

         std::pair<U, V>& pr)noexcept;
      (5)(since C++23)
      template<class T,class Alloc,class U,class V>

      constexprauto uses_allocator_construction_args(const Alloc& alloc,

         conststd::pair<U, V>& pr)noexcept;
      (6)(since C++20)
      template<class T,class Alloc,class U,class V>

      constexprauto uses_allocator_construction_args(const Alloc& alloc,

         std::pair<U, V>&& pr)noexcept;
      (7)(since C++20)
      template<class T,class Alloc,class U,class V>

      constexprauto uses_allocator_construction_args(const Alloc& alloc,

         conststd::pair<U, V>&& pr)noexcept;
      (8)(since C++23)
      template<class T,class Alloc,class NonPair>

      constexprauto uses_allocator_construction_args(const Alloc& alloc,

          NonPair&& non_pair)noexcept;
      (9)(since C++20)

      Prepares the argument list needed to create an object of the given typeT by means ofuses-allocator construction.

      1) This overload participates in overload resolution only ifT is not a specialization ofstd::pair. Returnsstd::tuple determined as follows:
      2) This overload participates in overload resolution only ifT is a specialization ofstd::pair. ForT that isstd::pair<T1, T2>, equivalent to
      returnstd::make_tuple(std::piecewise_construct,std::apply([&alloc](auto&&...args1){return std::uses_allocator_construction_args<T1>(alloc,std::forward<decltype(args1)>(args1)...);},std::forward<Tuple1>(x)),std::apply([&alloc](auto&&...args2){return std::uses_allocator_construction_args<T2>(alloc,std::forward<decltype(args2)>(args2)...);},std::forward<Tuple2>(y)));
      3) This overload participates in overload resolution only ifT is a specialization ofstd::pair. Equivalent to
      return std::uses_allocator_construction_args<T>(alloc,std::piecewise_construct,std::tuple<>{},std::tuple<>{});
      4) This overload participates in overload resolution only ifT is a specialization ofstd::pair. Equivalent to
      return std::uses_allocator_construction_args<T>(alloc,std::piecewise_construct,std::forward_as_tuple(std::forward<U>(u)),std::forward_as_tuple(std::forward<V>(v)));
      5,6) This overload participates in overload resolution only ifT is a specialization ofstd::pair. Equivalent to
      return std::uses_allocator_construction_args<T>(alloc,std::piecewise_construct,std::forward_as_tuple(pr.first),std::forward_as_tuple(pr.second));
      7,8) This overload participates in overload resolution only ifT is a specialization ofstd::pair. Equivalent to
      return std::uses_allocator_construction_args<T>(alloc,std::piecewise_construct,std::forward_as_tuple(std::get<0>(std::move(pr))),std::forward_as_tuple(std::get<1>(std::move(pr))));
      9) This overload participates in overload resolution only ifT is a specialization ofstd::pair, and given the exposition-only function template
      template<class A,class B>void/*deduce-as-pair*/(conststd::pair<A, B>&);

      ,/*deduce-as-pair*/(non_pair) is ill-formed when considered as an unevaluated operand.
      Let the exposition-only classpair-constructor be defined as

      class/*pair-constructor*/{const Alloc& alloc_;// exposition only    NonPair&     u_;// exposition only constexpr reconstruct(conststd::remove_cv<T>& p)const// exposition only{returnstd::make_obj_using_allocator<std::remove_cv<T>>(alloc_, p);} constexpr reconstruct(std::remove_cv<T>&& p)const// exposition only{returnstd::make_obj_using_allocator<std::remove_cv<T>>(alloc_, std::move(p));} public:constexpr operatorstd::remove_cv<T>()const{return reconstruct(std::forward<NonPair>(u_));}};
      This overload is equivalent toreturnstd::make_tuple(pair_construction);, wherepair_construction is a value of typepair-constructor whosealloc_ andu_ members arealloc andnon_pair respectively.

      Contents

      [edit]Parameters

      alloc - the allocator to use
      args - the arguments to pass toT's constructor
      x - tuple of arguments to pass to the constructors ofT'sfirst data member
      y - tuple of arguments to pass to the constructors ofT'ssecond data member
      u - single argument to pass to the constructor ofT'sfirst data member
      v - single argument to pass to the constructor ofT'ssecond data member
      pr - a pair whosefirst data member will be passed to the constructor ofT'sfirst data member andsecond data member will be passed to the constructor ofT'ssecond data member
      non_pair - single argument to convert to astd::pair for further construction

      [edit]Return value

      std::tuple of arguments suitable for passing to the constructor ofT.

      [edit]Notes

      The overloads(2-9) provide allocator propagation intostd::pair, which supports neither leading-allocator nor trailing-allocator calling conventions (unlike, e.g.std::tuple, which uses leading-allocator convention).

      When used in uses-allocator construction, the conversion function ofpair-constructor converts the provided argument tostd::pair at first, and then constructs the result from thatstd::pair by uses-allocator construction.

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]Defect reports

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

      DRApplied toBehavior as publishedCorrect behavior
      LWG 3525C++20no overload could handle non-pair types convertible topairreconstructing overload added

      [edit]See also

      checks if the specified type supports uses-allocator construction
      (class template)[edit]
      creates an object of the given type by means of uses-allocator construction
      (function template)[edit]
      creates an object of the given type at specified memory location by means of uses-allocator construction
      (function template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/memory/uses_allocator_construction_args&oldid=160321"

      [8]ページ先頭

      ©2009-2025 Movatter.jp