]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/is_nothrow_invocable/value_ext.cc
1 // Copyright (C) 2016-2022 Free Software Foundation, Inc.
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)
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.
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/>.
18 // { dg-do compile { target c++11 } }
20 #include <type_traits>
22 template<typename
... T
>
23 constexpr bool is_nt_invocable()
24 { return std::__is_nothrow_invocable
<T
...>::value
; }
26 template<typename R
, typename
... T
>
29 using result_type
= typename
std::__invoke_result
<T
...>::type
;
30 static void test(std::true_type
, R
) noexcept
;
31 static void test(std::false_type
, const result_type
&);
32 static constexpr bool value
33 = noexcept(test(std::is_convertible
<result_type
, R
>(),
34 std::declval
<result_type
>()));
37 template<typename
... T
>
38 struct ConvIsNothrow
<void, T
...> : std::true_type
41 template<typename R
, typename
... T
>
42 constexpr bool is_nt_invocable_conv(std::true_type
)
44 return ConvIsNothrow
<R
, T
...>::value
;
47 template<typename R
, typename
... T
>
48 constexpr bool is_nt_invocable_conv(std::false_type
) { return false; }
50 template<typename R
, typename
... T
>
51 constexpr bool is_nt_invocable_r()
53 return is_nt_invocable_conv
<R
, T
...>(std::__is_nothrow_invocable
<T
...>{});
56 #define IS_NT_INVOCABLE_DEFINED