Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:45

0001 /*
0002 
0003 @Copyright Barrett Adair 2015-2017
0004 Distributed under the Boost Software License, Version 1.0.
0005 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
0006 
0007 */
0008 
0009 #ifndef BOOST_CLBL_TRTS_IS_INVOCABLE_HPP
0010 #define BOOST_CLBL_TRTS_IS_INVOCABLE_HPP
0011 
0012 #include <boost/callable_traits/detail/core.hpp>
0013 #include <boost/callable_traits/detail/is_invocable_impl.hpp>
0014 
0015 namespace boost { namespace callable_traits {
0016 
0017 //[ is_invocable_hpp
0018 /*`[section:ref_is_invocable is_invocable]
0019 [heading Header]
0020 ``#include <boost/callable_traits/is_invocable.hpp>``
0021 [heading Definition]
0022 */
0023 
0024 // inherits from either std::true_type or std::false_type
0025 template<typename T, typename... Args>
0026 struct is_invocable;
0027 
0028 // inherits from either std::true_type or std::false_type
0029 template<typename Ret, typename T, typename... Args>
0030 struct is_invocable_r;
0031 
0032 //<-
0033 template<typename T, typename... Args>
0034 struct is_invocable : detail::is_invocable_impl<T, Args...>::type {
0035     using type = typename detail::is_invocable_impl<T, Args...>::type;
0036 };
0037 
0038 template<typename Ret, typename T, typename... Args>
0039 struct is_invocable_r
0040   : detail::is_invocable_r_impl<
0041         typename detail::is_invocable_impl<T, Args...>::type, Ret, T, Args...>::type
0042 {
0043     using type = typename detail::is_invocable_r_impl<
0044         typename detail::is_invocable_impl<T, Args...>::type, Ret, T, Args...>::type;
0045 };
0046 
0047 #ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES
0048 
0049 template<typename T, typename... Args>
0050 struct is_invocable_v {
0051     static_assert(std::is_same<T, detail::dummy>::value,
0052         "Variable templates not supported on this compiler.");
0053 };
0054 
0055 template<typename Ret, typename T, typename... Args>
0056 struct is_invocable_r_v {
0057     static_assert(std::is_same<T, detail::dummy>::value,
0058         "Variable templates not supported on this compiler.");
0059 };
0060 
0061 #else
0062 //->
0063 // only available when variable templates are supported
0064 template<typename T, typename... Args>
0065 //<-
0066 BOOST_CLBL_TRAITS_INLINE_VAR
0067 //->
0068 constexpr bool is_invocable_v = //see below
0069 //<-
0070     detail::is_invocable_impl<T, Args...>::type::value;
0071 //->
0072 
0073 // only available when variable templates are supported
0074 template<typename Ret, typename T, typename... Args>
0075 //<-
0076 BOOST_CLBL_TRAITS_INLINE_VAR
0077 //->
0078 constexpr bool is_invocable_r_v = //see below
0079 //<-
0080     detail::is_invocable_r_impl<
0081         typename detail::is_invocable_impl<T, Args...>::type,
0082         Ret, T, Args...>::type::value;
0083 #endif
0084 
0085 }} // namespace boost::callable_traits
0086 //->
0087 
0088 /*`
0089 [heading Constraints]
0090 * none
0091 
0092 [heading Behavior]
0093 * standalone c++11 implementation of c++17 `std::is_invocable`, `std::is_invocable_r`
0094 [note ref-qualified overloads of `operator()` with different signatures are not handled correctly yet.]
0095 
0096 [heading Example Program]
0097 [import ../example/is_invocable.cpp]
0098 [is_invocable]
0099 [endsect]
0100 */
0101 //]
0102 
0103 #endif // #ifndef BOOST_CLBL_TRTS_IS_INVOCABLE_HPP