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