| 1 | /* |
| 2 | * Distributed under the Boost Software License, Version 1.0. |
| 3 | * (See accompanying file LICENSE_1_0.txt or copy at |
| 4 | * https://www.boost.org/LICENSE_1_0.txt) |
| 5 | * |
| 6 | * Copyright (c) 2023 Andrey Semashev |
| 7 | */ |
| 8 | /*! |
| 9 | * \file scope/detail/type_traits/is_nothrow_invocable.hpp |
| 10 | * |
| 11 | * This header contains definition of \c is_nothrow_invocable type trait. |
| 12 | */ |
| 13 | |
| 14 | #ifndef BOOST_SCOPE_DETAIL_TYPE_TRAITS_IS_NOTHROW_INVOCABLE_HPP_INCLUDED_ |
| 15 | #define BOOST_SCOPE_DETAIL_TYPE_TRAITS_IS_NOTHROW_INVOCABLE_HPP_INCLUDED_ |
| 16 | |
| 17 | #include <type_traits> |
| 18 | #include <boost/scope/detail/config.hpp> |
| 19 | |
| 20 | #ifdef BOOST_HAS_PRAGMA_ONCE |
| 21 | #pragma once |
| 22 | #endif |
| 23 | |
| 24 | #if (defined(__cpp_lib_is_invocable) && (__cpp_lib_is_invocable >= 201703l)) || \ |
| 25 | (defined(BOOST_MSSTL_VERSION) && (BOOST_MSSTL_VERSION >= 140) && (BOOST_CXX_VERSION >= 201703l)) |
| 26 | |
| 27 | namespace boost { |
| 28 | namespace scope { |
| 29 | namespace detail { |
| 30 | |
| 31 | using std::is_nothrow_invocable; |
| 32 | |
| 33 | } // namespace detail |
| 34 | } // namespace scope |
| 35 | } // namespace boost |
| 36 | |
| 37 | #else |
| 38 | |
| 39 | #include <boost/scope/detail/type_traits/is_invocable.hpp> |
| 40 | |
| 41 | namespace boost { |
| 42 | namespace scope { |
| 43 | namespace detail { |
| 44 | |
| 45 | template< bool, typename Func, typename... Args > |
| 46 | struct is_nothrow_invocable_impl |
| 47 | { |
| 48 | using type = std::false_type; |
| 49 | }; |
| 50 | |
| 51 | template< typename Func, typename... Args > |
| 52 | struct is_nothrow_invocable_impl< true, Func, Args... > |
| 53 | { |
| 54 | using type = std::integral_constant< bool, noexcept(std::declval< Func >()(std::declval< Args >()...)) >; |
| 55 | }; |
| 56 | |
| 57 | template< typename Func, typename... Args > |
| 58 | struct is_nothrow_invocable : |
| 59 | public is_nothrow_invocable_impl< detail::is_invocable< Func, Args... >::value, Func, Args... >::type |
| 60 | { |
| 61 | }; |
| 62 | |
| 63 | } // namespace detail |
| 64 | } // namespace scope |
| 65 | } // namespace boost |
| 66 | |
| 67 | #endif |
| 68 | |
| 69 | #endif // BOOST_SCOPE_DETAIL_TYPE_TRAITS_IS_NOTHROW_INVOCABLE_HPP_INCLUDED_ |
| 70 | |