Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:15

0001 /*=============================================================================
0002     Copyright (c) 2014 Paul Fultz II
0003     is_invocable.h
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 
0008 #ifndef BOOST_HOF_GUARD_IS_CALLABLE_H
0009 #define BOOST_HOF_GUARD_IS_CALLABLE_H
0010 
0011 /// is_invocable
0012 /// ===========
0013 /// 
0014 /// Description
0015 /// -----------
0016 /// 
0017 /// The `is_invocable` metafunction checks if the function is callable with
0018 /// certain parameters.
0019 /// 
0020 /// Requirements
0021 /// ------------
0022 /// 
0023 /// F must be:
0024 /// 
0025 /// * [Invocable](Invocable)
0026 /// 
0027 /// Synopsis
0028 /// --------
0029 /// 
0030 ///     template<class F, class... Ts>
0031 ///     struct is_invocable;
0032 /// 
0033 /// Example
0034 /// -------
0035 /// 
0036 ///     #include <boost/hof.hpp>
0037 ///     using namespace boost::hof;
0038 /// 
0039 ///     struct is_invocable_class
0040 ///     {
0041 ///         void operator()(int) const
0042 ///         {
0043 ///         }
0044 ///     };
0045 ///     static_assert(is_invocable<is_invocable_class, int>(), "Not callable");
0046 /// 
0047 ///     int main() {}
0048 /// 
0049 
0050 
0051 #include <boost/hof/detail/can_be_called.hpp>
0052 #include <boost/hof/apply.hpp>
0053 
0054 namespace boost { namespace hof {
0055 
0056 template<class F, class... Ts>
0057 struct is_invocable 
0058 : detail::can_be_called<detail::apply_f, F, Ts...>
0059 {};
0060 
0061 template<class F, class... Ts, class... Us>
0062 struct is_invocable<F(Ts...), Us...>
0063 {
0064     static_assert(!std::is_same<F, F>::value, 
0065         "The is_invocable<F(Args...)> form is not supported because it is problematic."
0066         "Please use is_invocable<F, Args...> instead."
0067     );
0068 };
0069 
0070 }} // namespace boost::hof
0071 
0072 #endif