Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::shared_future<T>::get

      From cppreference.com
      <cpp‎ |thread‎ |shared future
       
       
      Concurrency support library
      Threads
      (C++11)
      (C++20)
      this_thread namespace
      (C++11)
      (C++11)
      (C++11)
      Cooperative cancellation
      Mutual exclusion
      Generic lock management
      (C++11)
      (C++11)
      (C++11)
      (C++11)
      Condition variables
      (C++11)
      Semaphores
      Latches and Barriers
      (C++20)
      (C++20)
      Futures
      (C++11)
      (C++11)
      (C++11)
      Safe reclamation
      Hazard pointers
      Atomic types
      (C++11)
      (C++20)
      Initialization of atomic types
      (C++11)(deprecated in C++20)
      (C++11)(deprecated in C++20)
      Memory ordering
      (C++11)(deprecated in C++26)
      Free functions for atomic operations
      Free functions for atomic flags
       
       
      Main template
      const T& get()const;
      (1)(since C++11)
      std::shared_future<T&> specializations
      T& get()const;
      (2)(since C++11)
      std::shared_future<void> specialization
      void get()const;
      (3)(since C++11)

      Theget member function waits (by callingwait()) until the shared state is ready, then retrieves the value stored in the shared state (if any).

      Ifvalid() isfalse before the call to this function, the behavior is undefined.

      Contents

      [edit]Return value

      1) A const reference to the value stored in the shared state. The behavior of accessing the value through this reference after the shared state has been destroyed is undefined.
      2) The reference stored as value in the shared state.
      3) (none)

      [edit]Exceptions

      If an exception was stored in the shared state referenced by the future (e.g. via a call tostd::promise::set_exception()) then that exception will be thrown.

      [edit]Notes

      The C++ standard recommends the implementations to detect the case whenvalid() isfalse before the call and throw astd::future_error with an error condition ofstd::future_errc::no_state.

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      checks if the future has a shared state
      (public member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/thread/shared_future/get&oldid=169901"

      [8]ページ先頭

      ©2009-2025 Movatter.jp