| 1 | // Copyright (C) 2016-2025 Free Software Foundation, Inc. |
| 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-do compile { target c++11 } } |
| 19 | |
| 20 | #include <type_traits> |
| 21 | |
| 22 | template<typename... T> |
| 23 | constexpr bool is_nt_invocable() |
| 24 | { return std::__is_nothrow_invocable<T...>::value; } |
| 25 | |
| 26 | template<typename R, typename... T> |
| 27 | struct ConvIsNothrow |
| 28 | { |
| 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>())); |
| 35 | }; |
| 36 | |
| 37 | template<typename... T> |
| 38 | struct ConvIsNothrow<void, T...> : std::true_type |
| 39 | { }; |
| 40 | |
| 41 | template<typename R, typename... T> |
| 42 | constexpr bool is_nt_invocable_conv(std::true_type) |
| 43 | { |
| 44 | return ConvIsNothrow<R, T...>::value; |
| 45 | } |
| 46 | |
| 47 | template<typename R, typename... T> |
| 48 | constexpr bool is_nt_invocable_conv(std::false_type) { return false; } |
| 49 | |
| 50 | template<typename R, typename... T> |
| 51 | constexpr bool is_nt_invocable_r() |
| 52 | { |
| 53 | return is_nt_invocable_conv<R, T...>(std::__is_nothrow_invocable<T...>{}); |
| 54 | } |
| 55 | |
| 56 | #define IS_NT_INVOCABLE_DEFINED |
| 57 | #include "value.cc" |