std::indirect
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Memory management library
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
Garbage collector support (until C++23)
(exposition only*)
(C++11)
(C++23)
(C++11)
(C++17)
(C++11)
(C++11)
(C++20)
(C++20)
(C++17)
(C++11)
(C++17)
(C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(until C++20*)
(until C++20*)
(until C++20*)
(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)
(C++11)
(C++11)
(C++17)
(C++20)
(C++17)
(C++11)
(C++11)
(C++11)
(until C++17*)
(C++11)
(C++17)
(C++26)
(C++26)
(C++11)
(C++11)
(C++11)
(C++23)
(C++23)
(C++11)
(C++20)
(C++11)
(C++11)
(C++20)
(C++26)
std::indirect
Defined in header
<memory>
template< class T, class Allocator = std::allocator <T> >
class indirect;
(1)
(since C++26)
class indirect;
namespace pmr {
(2)
(since C++26)
template< class T >
using indirect = std::indirect<T, std::pmr::polymorphic_allocator <T>>;
1)
std::indirect
is a wrapper containing dynamically-allocated object with value-like semantics.An std::indirect
object manages the lifetime of an owned object. An std::indirect
object can only have no owned object after it has been moved from, in this case it is valueless .
Every object of type std::indirect<T, Allocator>
uses an object of type Allocator
to allocate and free storage for the owned object as needed.
If a program declares an explicit or partial specialization of std::indirect
, the behavior is undefined.
Contents
[edit] Template parameters
T
-
the type of the owned object
Allocator
-
the type of the associated allocator
Type requirements
-
T
may be an incomplete type.
-If
T
is one of the following types, the program is ill-formed:
- a non-object type
- an array type
- std::in_place_t
- a specialization of std::in_place_type_t
- a cv-qualified type
-If
Allocator
does not satisfy the requirements of Allocator, the program is ill-formed.
-If std::allocator_traits <Allocator>::value_type is not the same type as
T
, the program is ill-formed.
[edit] Nested types
Type
Definition
value_type
T
allocator_type
Allocator
pointer
typename std::allocator_traits <Allocator>::pointer
const_pointer
typename std::allocator_traits <Allocator>::const_pointer
[edit] Data members
Member
Description
pointer
p
a pointer to the owned value(exposition-only member object*)
Allocator
alloc
the asociated allocator(exposition-only member object*)
[edit] Member functions
Observers
Modifiers
[edit] Non-member functions
[edit] Helper classes
[edit] Deduction guides
[edit] Notes
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_indirect |
202502L |
(C++26) | std::indirect
|
[edit] Example
This section is incomplete
Reason: no example
Reason: no example
[edit] See also
(C++26)
(class template) [edit]