GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::shared_future::valid(3) C++ Standard Libary std::shared_future::valid(3)

std::shared_future::valid - std::shared_future::valid


bool valid() const noexcept; (since C++11)


Checks if the future refers to a shared state.


This is the case only for futures that were not default-constructed or moved from.
Unlike std::future, std::shared_future's shared state is not invalidated when get()
is called.


The behavior is undefined if any member function other than the destructor, the
copy-assignment operator, the move-assignment operator, or valid is called on a
shared_future that does not refer to shared state (although implementations are
encouraged to throw std::future_error indicating no_state in this case). It is valid
to move or copy from a shared_future object for which valid() is false.


(none)


true if *this refers to a shared state, otherwise false.

// Run this code


#include <future>
#include <iostream>


int main() {
std::promise<void> p;
std::shared_future<void> f = p.get_future();


std::cout << std::boolalpha;


std::cout << f.valid() << '\n';
p.set_value();
std::cout << f.valid() << '\n';
f.get();
std::cout << f.valid() << '\n';
}


true
true
true


wait waits for the result to become available
(public member function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.