Namespaces
Variants

std::shared_future<T>:: get

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
기본 템플릿
const T & get ( ) const ;
(1) (C++11부터)
std:: shared_future < T & > 특수화
T & get ( ) const ;
(2) (C++11부터)
std:: shared_future < void > 특수화
void get ( ) const ;
(3) (C++11부터)

get 멤버 함수는 공유 상태가 준비될 때까지 ( wait() 을 호출하여) 대기한 후, 공유 상태에 저장된 값(있는 경우)을 검색합니다.

만약 valid() 함수 호출 전에 false 인 경우, 이 함수의 동작은 정의되지 않습니다.

목차

반환값

1) 공유 상태에 저장된 값에 대한 const 참조. 공유 상태가 소멸된 후 이 참조를 통해 값에 접근하는 동작은 정의되지 않습니다.
2) 공유 상태에 값으로 저장된 참조.
3) (없음)

예외

만약 예외가 future가 참조하는 공유 상태에 저장되었다면 (예: std::promise::set_exception() 호출을 통해) 해당 예외가 throw될 것입니다.

참고 사항

C++ 표준은 구현체가 호출 전에 valid() false 인 경우를 감지하고 std::future_error std::future_errc::no_state 오류 조건으로 던지도록 권장합니다.

예제

참고 항목

future가 공유 상태를 가지고 있는지 확인합니다
(public member function)