##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::promise

From cppreference.com
< cpp‎ | thread

Defined in header `<future>` |  |
template< class T > class promise; | (1) | (since C++11)
template< class T > class promise<T&>; | (2) | (since C++11)
template<> class promise<void>; | (3) | (since C++11)

The class template `std::promise` provides a facility to store a value that is later acquired asynchronously via a std::future object, that the `std::promise` can supply.

| This section is incomplete

### [edit] Member functions

(constructor) | constructs the promise object (public member function) [edit]
(destructor) | destructs the promise object (public member function) [edit]
operator= | assigns the shared state (public member function) [edit]
swap | swaps two promise objects (public member function) [edit]
##### Getting the result
get_future | returns a `future` associated with the promised result (public member function) [edit]
##### Setting the result
set_value | sets the result to specific value (public member function) [edit]
set_value_at_thread_exit | sets the result to specific value while delivering the notification only at thread exit (public member function) [edit]
set_exception | sets the result to indicate an exception (public member function) [edit]
set_exception_at_thread_exit | sets the result to indicate an exception while delivering the notification only at thread exit (public member function) [edit]

### [edit] Non-member functions

std::swap(std::promise) (C++11) | specializes the std::swap algorithm (function template) [edit]

### [edit] Helper classes

std::uses_allocator<std::promise> (C++11) | specializes the std::uses_allocator type trait (class template specialization) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/thread/promise&oldid=62976"
Category:

- Todo without reason