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

The std::experimental::future class template provides a means of waiting for an asynchronous result from another thread, in conjunction with the std::experimental::promise and std::experimental::packaged_task class templates and the std::experimental::async function template which can be used to provide that asynchronous result. Only one std::experimental::future instance references any given asynchronous result at any time.

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

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

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

    shared_future<ResultType> share();

    bool valid() const;
    bool is_ready() const;
    bool has_exception() const;
    bool has_value() const;

    see description get();

    void wait();

    template<typename Rep,typename Period>
    future_status wait_for(
        std::chrono::duration<Rep,Period> const&
        relative_time);

    template<typename Clock,typename Duration>
    future_status wait_until(
        std::chrono::time_point<Clock,Duration> const&
        absolute_time);

    template<typename Func>
    see description
    then(Func&& func);

    template<typename Func>
    see description
    then(std::launch policy,Func&& func);
};
Header

#include <experimental/future>

See Also