Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::future<T>::share

      From cppreference.com
      <cpp‎ |thread‎ |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
       
       
      std::shared_future<T> share()noexcept;

      Transfers the shared state of*this, if any, to astd::shared_future object. Multiplestd::shared_future objects may reference the same shared state, which is not possible withstd::future.

      After callingshare on astd::future,valid()==false.

      Contents

      [edit]Parameters

      (none)

      [edit]Return value

      Astd::shared_future object containing the shared state previously held by*this, if any, constructed as if bystd::shared_future<T>(std::move(*this)).

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 2556C++11share() requiresvalid() to betruerequirement removed and madenoexcept

      [edit]See also

      waits for a value (possibly referenced by other futures) that is set asynchronously
      (class template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/thread/future/share&oldid=161135"

      [8]ページ先頭

      ©2009-2025 Movatter.jp