]>
Commit | Line | Data |
---|---|---|
8d9254fc | 1 | // Copyright (C) 2016-2020 Free Software Foundation, Inc. |
5f303216 JW |
2 | // |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
6 | // Free Software Foundation; either version 3, or (at your option) | |
7 | // any later version. | |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
15 | // with this library; see the file COPYING3. If not see | |
16 | // <http://www.gnu.org/licenses/>. | |
17 | ||
18 | // { dg-options "-std=gnu++17" } | |
19 | // { dg-do compile { target c++17 } } | |
20 | ||
21 | #include <functional> | |
22 | ||
23 | struct abstract { | |
24 | virtual ~abstract() = 0; | |
25 | void operator()() noexcept; | |
26 | }; | |
27 | ||
28 | static_assert( noexcept(std::__invoke(std::declval<abstract>())), | |
29 | "It should be possible to use abstract types with INVOKE" ); | |
30 | static_assert( noexcept(std::invoke(std::declval<abstract>())), | |
31 | "It should be possible to use abstract types with INVOKE" ); | |
32 | ||
33 | // The std::__invoke_r extension only has a noexcept-specifier for >= C++17. | |
34 | static_assert( noexcept(std::__invoke_r<void>(std::declval<abstract>())), | |
35 | "It should be possible to use abstract types with INVOKE<R>" ); | |
36 | ||
37 | struct F { | |
38 | void operator()() &; | |
39 | void operator()() && noexcept; | |
40 | int operator()(int); | |
41 | double* operator()(int, int) noexcept; | |
42 | }; | |
43 | struct D { D(void*); }; | |
44 | ||
45 | static_assert( !noexcept(std::__invoke(std::declval<F&>())), "" ); | |
46 | static_assert( noexcept(std::__invoke(std::declval<F>())), "" ); | |
47 | static_assert( !noexcept(std::__invoke(std::declval<F>(), 1)), "" ); | |
48 | static_assert( noexcept(std::__invoke(std::declval<F>(), 1, 2)), "" ); | |
49 | ||
50 | static_assert( !noexcept(std::invoke(std::declval<F&>())), "" ); | |
51 | static_assert( noexcept(std::invoke(std::declval<F>())), "" ); | |
52 | static_assert( !noexcept(std::invoke(std::declval<F>(), 1)), "" ); | |
53 | static_assert( noexcept(std::invoke(std::declval<F>(), 1, 2)), "" ); | |
54 | ||
55 | static_assert( !noexcept(std::__invoke_r<void>(std::declval<F&>())), "" ); | |
56 | static_assert( noexcept(std::__invoke_r<void>(std::declval<F>())), "" ); | |
57 | static_assert( !noexcept(std::__invoke_r<int>(std::declval<F>(), 1)), "" ); | |
58 | static_assert( !noexcept(std::__invoke_r<void>(std::declval<F>(), 1)), "" ); | |
59 | static_assert( !noexcept(std::__invoke_r<long>(std::declval<F>(), 1)), "" ); | |
60 | static_assert( noexcept(std::__invoke_r<void>(std::declval<F>(), 1, 2)), "" ); | |
61 | static_assert( noexcept(std::__invoke_r<void*>(std::declval<F>(), 1, 2)), "" ); | |
62 | static_assert( !noexcept(std::__invoke_r<D>(std::declval<F>(), 1, 2)), "" ); |