Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::indirect<T, Allocator>::indirect

      From cppreference.com
      <cpp‎ |memory‎ |indirect
       
       
      Memory management library
      (exposition only*)
      Allocators
      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)
       
       
      constexprexplicit indirect();
      (1)(since C++26)
      constexprexplicit indirect(std::allocator_arg_t,const Allocator& a);
      (2)(since C++26)
      template<class U= T>
      constexprexplicit indirect( U&& v);
      (3)(since C++26)
      template<class U= T>

      constexprexplicit indirect(std::allocator_arg_t,const Allocator& a,

                                   U&& v);
      (4)(since C++26)
      template<class...Args>
      constexprexplicit indirect(std::in_place_t, Args&&...args);
      (5)(since C++26)
      template<class...Args>

      constexprexplicit indirect(std::allocator_arg_t,const Allocator& a,

                                   std::in_place_t, Args&&...args);
      (6)(since C++26)
      template<class I,class...Args>

      constexprexplicit indirect(std::in_place_t,std::initializer_list<I> ilist,

                                   Args&&...args);
      (7)(since C++26)
      template<class I,class...Args>

      constexprexplicit indirect(std::allocator_arg_t,const Allocator& a,
                                   std::in_place_t,std::initializer_list<I> ilist,

                                   Args&&...args);
      (8)(since C++26)
      constexpr indirect(const indirect& other);
      (9)(since C++26)
      constexpr indirect(std::allocator_arg_t,const Allocator& a,
                         const indirect& other);
      (10)(since C++26)
      constexpr indirect( indirect&& other)noexcept;
      (11)(since C++26)
      constexpr indirect(std::allocator_arg_t,const Allocator& a,
                          indirect&& other)noexcept(/* see below */);
      (12)(since C++26)

      Constructs a newindirect object.

      Contents

      [edit]Parameters

      a - the allocator to be associated
      v - value with which to initialize the owned value
      args - arguments with which to initialize the owned value
      il - initializer list with which to initialize the owned value
      other - anotherindirect object whose owned value (if exists) is copied

      [edit]Effects

      The construction of a newindirect object consists of the following steps:

      1) Constructs the associated allocatoralloc :
      2) Constructs the owned object:
      • For overloads(1-8), initializep with the result of callingstd::allocator_traits<Allocator>::allocate, then callsstd::allocator_traits<Allocator>::construct(alloc , p , args...), whereargs... is an expression pack containing the initializer arguments.
      • For overloads(9-12):
        • Ifother is valueless, no owned object is constructed, and*this is also valueless after construction.
        • Otherwise, ifother is an rvalue reference andalloc equalsother.alloc,*this takes ownership of the owned object ofother.
        • Otherwise, the owned object is constructed usingalloc as described above.
       Overload Initializer for...valueless_after_move()
      after construction
      allocthe owned object
      (1)(empty)(empty)false
      (2)a
      (3)(empty)std::forward<U>(v)
      (4)a
      (5)(empty)std::forward<Args>(args)
      (6)a
      (7)(empty)ilist,std::forward<Args>(args)
      (8)a
      (9) see below *other
      (only ifother owns a value)
      true only ifother is valueless
      (10)a
      (11)std::move(other.alloc )takes ownership
      (only ifother owns a value)
      (12)asee below
      9)alloc is direct-non-list-initialized withstd::allocator_traits<Allocator>::
          select_on_container_copy_construction(other.alloc )
      .
      12) The owned object is constructed as follows:
      • Ifother is valueless,*this is also valueless.
      • Otherwise, ifalloc== other.alloc istrue,*this takes ownership of the owned object ofother.
      • Otherwise, constructs an owned object with*std::move(other) usingalloc .

      [edit]Constraints and supplement information

      1,2) Ifstd::is_default_constructible_v<T> isfalse, the program is ill-formed.

      1) This overload participates in overload resolution only ifstd::is_default_constructible_v<Allocator> istrue.

      3-8) These overloads participate in overload resolution only ifstd::is_constructible_v<T,/* argument types */> istrue, where/* argument types */ are:
      3,4)U
      5,6)Args...
      7,8)std::initializer_list<I>&, Args...

      3,5,7) These overloads participate in overload resolution only ifstd::is_default_constructible_v<Allocator> istrue.
      3,4) These overloads participate in overload resolution only if the following values are allfalse:

      9,10) Ifstd::is_copy_constructible_v<T> isfalse, the program is ill-formed.
      11,12) When the construction completes,other is valueless.
      12) Ifstd::allocator_traits<Allocator>::is_always_equal::value isfalse andT is anincomplete type, the program is ill-formed.

      [edit]Exceptions

      Throws nothing unlessstd::allocator_traits<Allocator>::allocate orstd::allocator_traits<Allocator>::construct throws.

      12)
      noexcept specification:  
      noexcept(std::allocator_traits<Allocator>::is_always_equal::value)

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      tag type used to select allocator-aware constructor overloads
      (class)[edit]
      in-place construction tag
      (tag)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/memory/indirect/indirect&oldid=182597"

      [8]ページ先頭

      ©2009-2025 Movatter.jp