just::thread Complete C++ Standard Thread Library by Just Software Solutions

Documentation Home >> Headers >> <future> Header >> std::future class template

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

Instances of std::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 const&) = delete;
    future& operator=(future const&) = delete;

    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>
    bool wait_for(std::chrono::duration<Rep,Period> const& relative_time);

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

Header

#include <future>

See Also