1/*============================================================================= 2 Copyright (c) 2014 Paul Fultz II 3 is_invocable.h 4 Distributed under the Boost Software License, Version 1.0. (See accompanying 5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6==============================================================================*/ 7 8#ifndef BOOST_HOF_GUARD_IS_CALLABLE_H 9#define BOOST_HOF_GUARD_IS_CALLABLE_H 10 11/// is_invocable 12/// =========== 13/// 14/// Description 15/// ----------- 16/// 17/// The `is_invocable` metafunction checks if the function is callable with 18/// certain parameters. 19/// 20/// Requirements 21/// ------------ 22/// 23/// F must be: 24/// 25/// * [Invocable](Invocable) 26/// 27/// Synopsis 28/// -------- 29/// 30/// template<class F, class... Ts> 31/// struct is_invocable; 32/// 33/// Example 34/// ------- 35/// 36/// #include <boost/hof.hpp> 37/// using namespace boost::hof; 38/// 39/// struct is_invocable_class 40/// { 41/// void operator()(int) const 42/// { 43/// } 44/// }; 45/// static_assert(is_invocable<is_invocable_class, int>(), "Not callable"); 46/// 47/// int main() {} 48/// 49 50 51#include <boost/hof/detail/can_be_called.hpp> 52#include <boost/hof/apply.hpp> 53 54namespace boost { namespace hof { 55 56template<class F, class... Ts> 57struct is_invocable 58: detail::can_be_called<detail::apply_f, F, Ts...> 59{}; 60 61template<class F, class... Ts, class... Us> 62struct is_invocable<F(Ts...), Us...> 63{ 64 static_assert(!std::is_same<F, F>::value, 65 "The is_invocable<F(Args...)> form is not supported because it is problematic." 66 "Please use is_invocable<F, Args...> instead." 67 ); 68}; 69 70}} // namespace boost::hof 71 72#endif 73