Documentation Home >> Headers >> <jss/experimental_future.hpp> Header >> std::experimental::promise class template

The std::experimental::promise class template provides a means of setting an asynchronous result, which may be retrieved from another thread through an instance of std::experimental::future.

The ResultType template parameter is the type of the value that can be stored in the asynchronous result.

A std::experimental::future associated with the asynchronous result of a particular std::experimental::promise instance can be obtained by calling the get_future() member function. The asynchronous result is either set to a value of type ResultType with the set_value() member function, or to an exception with the set_exception() member function.

Instances of std::experimental::promise are MoveConstructible and MoveAssignable, but not CopyConstructible or CopyAssignable.

template<typename ResultType>
class promise
{
public:
    promise();
    promise(promise&&);
    ~promise();
    promise& operator=(promise&&);

    template<typename Allocator>
    promise(std::allocator_arg_t, Allocator const&);

    promise(promise const&) = delete;
    promise& operator=(promise const&) = delete;

    void swap(promise& );

    std::experimental::future<ResultType> get_future();

    void set_value(see description);
    void set_exception(std::exception_ptr p);
};
Header

#include <experimental/future>

See Also