Skip to content

Commit

Permalink
add comment to clarify the state more
Browse files Browse the repository at this point in the history
  • Loading branch information
wx257osn2 committed Jan 4, 2025
1 parent 7bd2d3d commit 3bd8c4f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions reference/future/future/valid.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ int main()
std::promise<int> p;
std::future<int> f = p.get_future();

p.set_value(1);

// 共有状態を持っている
std::cout << std::boolalpha << f.valid() << std::endl;

p.set_value(1);

// この時点でもまだ共有状態を持っている

f.get(); // 一度値を取り出すと共有状態が破棄される

std::cout << std::boolalpha << f.valid() << std::endl;
Expand Down

0 comments on commit 3bd8c4f

Please sign in to comment.