std::experimental::promise<R>::promise (library fundamentals TS)
From cppreference.com
< cpp | experimental | lib extensions | promise
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)
Experimental
Filesystem library (filesystem TS)
Library fundamentals (library fundamentals TS)
Library fundamentals 2 (library fundamentals TS v2)
Library fundamentals 3 (library fundamentals TS v3)
Extensions for parallelism (parallelism TS)
Extensions for parallelism 2 (parallelism TS v2)
Extensions for concurrency (concurrency TS)
Extensions for concurrency 2 (concurrency TS v2)
Concepts (concepts TS)
Ranges (ranges TS)
Reflection (reflection TS)
Mathematical special functions (special functions TR)
Polymorphic allocator library
Memory resource classes
Global memory resources
Type-erased allocator support for existing classes
promise();
(1)
(library fundamentals TS)
template< class Alloc >
promise( std::allocator_arg_t, const Alloc& alloc );
(2)
(library fundamentals TS)
promise( std::allocator_arg_t, const Alloc& alloc );
promise( promise&& other ) noexcept;
(3)
(library fundamentals TS)
promise( const promise& other ) = delete;
(4)
(library fundamentals TS)
Constructs a std::experimental::promise
object.
1) Default constructor. Constructs the promise with an empty shared state.
2) Constructs the promise with an empty shared state. The shared state is allocated using alloc, which is treated as a type-erased allocator (see below).
3) Move constructor. Constructs the promise with the shared state of other using move semantics. After construction, other has no shared state.
4)
std::experimental::promise
is not copyable.[edit] Type-erased allocator
The constructors of promise
taking an allocator argument alloc
treats that argument as a type-erased allocator. The memory resource pointer used by promise
to allocate memory is determined using the allocator argument (if specified) as follows:
Type of
alloc
Value of the memory resource pointer
Non-existent (no allocator specified at time of construction)
The value of std::experimental::pmr::get_default_resource () at time of construction.
std::nullptr_t
The value of std::experimental::pmr::get_default_resource () at time of construction.
A pointer type convertible to
std::experimental::pmr::memory_resource * static_cast<std::experimental::pmr::memory_resource *>(alloc)
std::experimental::pmr::memory_resource * static_cast<std::experimental::pmr::memory_resource *>(alloc)
Any other type meeting the Allocator requirements
A pointer to a value of type std::experimental::pmr::resource_adaptor <A>(alloc), where
A
is the type of alloc
. The pointer remains valid only for the lifetime of the promise
object.
None of the above
The program is ill-formed.
[edit] Parameters
alloc
-
allocator to use to allocate the shared state
other
-
another
std::experimental::promise
to acquire the state from
[edit] Exceptions
1,2) (none)