]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/30_threads/shared_future/members/45133.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 30_threads / shared_future / members / 45133.cc
1 // { dg-do run }
2 // { dg-additional-options "-pthread" { target pthread } }
3 // { dg-require-effective-target c++11 }
4 // { dg-require-gthreads "" }
5
6 // Copyright (C) 2010-2024 Free Software Foundation, Inc.
7 //
8 // This file is part of the GNU ISO C++ Library. This library is free
9 // software; you can redistribute it and/or modify it under the
10 // terms of the GNU General Public License as published by the
11 // Free Software Foundation; either version 3, or (at your option)
12 // any later version.
13
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18
19 // You should have received a copy of the GNU General Public License along
20 // with this library; see the file COPYING3. If not see
21 // <http://www.gnu.org/licenses/>.
22
23 // 30.6.7 Class template shared_future [futures.shared_future]
24
25 #include <future>
26 #include <testsuite_hooks.h>
27
28 // This test verifies behaviour which is encouraged by a non-normative note,
29 // but not required.
30
31 void
32 test01()
33 {
34 std::shared_future<int> f;
35 try
36 {
37 f.get();
38 VERIFY( false );
39 }
40 catch (std::future_error& e)
41 {
42 VERIFY( e.code() == std::future_errc::no_state );
43 }
44 }
45
46 void
47 test02()
48 {
49 std::shared_future<int&> f;
50 try
51 {
52 f.get();
53 VERIFY( false );
54 }
55 catch (std::future_error& e)
56 {
57 VERIFY( e.code() == std::future_errc::no_state );
58 }
59 }
60
61 void
62 test03()
63 {
64 std::shared_future<void> f;
65 try
66 {
67 f.get();
68 VERIFY( false );
69 }
70 catch (std::future_error& e)
71 {
72 VERIFY( e.code() == std::future_errc::no_state );
73 }
74 }
75
76 int main()
77 {
78 test01();
79 test02();
80 test03();
81
82 return 0;
83 }
84