Namespaces
Variants

std::future<T>:: share

From cppreference.net
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
Generic lock management
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 ;

* this 의 공유 상태가 존재하는 경우, 이를 std::shared_future 객체로 전송합니다. 여러 개의 std::shared_future 객체가 동일한 공유 상태를 참조할 수 있으며, 이는 std::future 로는 불가능합니다.

share std::future 에서 호출한 후에는 valid ( ) == false 입니다.

목차

매개변수

(없음)

반환값

이전에 * this 가 보유하고 있던 공유 상태(있는 경우)를 포함하는 std::shared_future 객체를, 마치 std:: shared_future < T > ( std :: move ( * this ) ) 와 같이 생성하여 반환합니다.

예제

결함 보고서

다음의 동작 변경 결함 보고서들은 이전에 발표된 C++ 표준에 소급 적용되었습니다.

DR 적용 대상 게시된 동작 올바른 동작
LWG 2556 C++11 share() 함수가 valid() true 일 것을 요구함 요구사항 제거되고 noexcept 로 지정됨

참고 항목

비동기적으로 설정된 값(다른 future들이 참조할 수 있는)을 대기합니다
(클래스 템플릿)