/*============================================================================= Copyright (c) 2015 Paul Fultz II can_be_called.h Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #ifndef BOOST_HOF_GUARD_CAN_BE_CALLED_H #define BOOST_HOF_GUARD_CAN_BE_CALLED_H #include #include #include #include namespace boost { namespace hof { namespace detail { #if BOOST_HOF_NO_EXPRESSION_SFINAE struct dont_care { dont_care(...); }; template struct never_care { typedef dont_care type; }; struct cant_be_called_type {}; struct no_type {}; template struct is_callable_wrapper_fallback { template auto operator()(Ts&&...) const -> decltype(std::declval()(std::declval()...)); }; template::type>::type> struct is_callable_wrapper_base : std::conditional> {}; template struct is_callable_wrapper : is_callable_wrapper_base::type { is_callable_wrapper(); typedef cant_be_called_type const &(*pointer_to_function)(typename never_care::type...); operator pointer_to_function() const; }; template struct not_ : std::integral_constant {}; template struct can_be_called : not_()(std::declval()...) )>::type>> {}; template struct check_args; template struct check_args : and_...> {}; template struct can_be_called : std::conditional, std::false_type >::type {}; template struct can_be_called : std::conditional, std::false_type >::type {}; #else template T&& called_val() noexcept; template struct callable_args {}; template struct can_be_called_impl : std::false_type {}; template struct can_be_called_impl, typename detail::holder< decltype( boost::hof::detail::called_val()(boost::hof::detail::called_val()...) ) >::type> : std::true_type {}; template BOOST_HOF_USING(can_be_called, can_be_called_impl>); #endif }}} // namespace boost::hof #endif