Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::experimental::future<T>::then

      From cppreference.com
      <cpp‎ |experimental‎ |future

      [edit template]
       
       
       
       
       
      template<class F>
      future</* see below */> then( F&& func);

      Attach the continuationfunc to*this. The behavior is undefined if*this has no associated shared state (i.e.,valid()==false).

      Creates a shared state associated with thefuture object to be returned, and a copyfd offunc constructed as if byDECAY_COPY(std::forward<F>(func)) evaluated in the thread callingthen, whereDECAY_COPY is defined as

      template<class T>std::decay_t<T> DECAY_COPY(T&& v){returnstd::forward<T>(v);}

      When the shared state currently associated with*this is ready, thecontinuationINVOKE(std::move(fd), std::move(*this)) is called on an unspecified thread of execution, whereINVOKE is the operation defined inCallable. If that expression is invalid, the behavior is undefined.

      Any value returned from the continuation is stored as the result in the shared state of the returnedfuture object. Any exception propagated from the execution of the continuation is stored as the exceptional result in the shared state of the returnedfuture object.

      LetU be the return type of the continuation (i.e.std::result_of_t<std::decay_t<F>(std::experimental::future<T>)>). IfU isstd::experimental::future<T2> for some typeT2, then the return type ofthen isstd::experimental::future<T2>, otherwise it isstd::experimental::future<U>. This is known asimplicit unwrapping.

      If implicit unwrapping takes place and the continuation returns an invalidfuture, then the shared state is made ready with an exception of typestd::future_error with an error condition ofstd::future_errc::broken_promise.

      After this function returns,valid() isfalse.

      [edit]Parameters

      func - a continuation to be attached

      [edit]Return value

      Astd::experimental::future object associated with the shared state created by this object.valid()==true for the returned object.

      [edit]Example

      This section is incomplete
      Reason: no example
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/experimental/future/then&oldid=98647"

      [8]ページ先頭

      ©2009-2025 Movatter.jp