/*============================================================================= Copyright (c) 2015 Paul Fultz II callable_base.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_CALLABLE_BASE_H #define BOOST_HOF_GUARD_CALLABLE_BASE_H #include #include #include #ifndef BOOST_HOF_CALLABLE_BASE_USE_TEMPLATE_ALIAS #if (defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7) #define BOOST_HOF_CALLABLE_BASE_USE_TEMPLATE_ALIAS 0 #else #define BOOST_HOF_CALLABLE_BASE_USE_TEMPLATE_ALIAS 1 #endif #endif namespace boost { namespace hof { namespace detail { template struct non_class_function { F f; BOOST_HOF_DELEGATE_CONSTRUCTOR(non_class_function, F, f) template constexpr BOOST_HOF_SFINAE_RESULT(apply_f, id_, id_...) operator()(Ts&&... xs) const BOOST_HOF_SFINAE_RETURNS ( boost::hof::apply(f, BOOST_HOF_FORWARD(Ts)(xs)...) ); }; template struct callable_base_type : std::conditional<(BOOST_HOF_IS_CLASS(F) && !BOOST_HOF_IS_FINAL(F) && !BOOST_HOF_IS_POLYMORPHIC(F)), F, non_class_function> {}; #if BOOST_HOF_CALLABLE_BASE_USE_TEMPLATE_ALIAS template using callable_base = typename callable_base_type::type; #else template struct callable_base : callable_base_type::type { typedef typename callable_base_type::type base; BOOST_HOF_INHERIT_CONSTRUCTOR(callable_base, base) }; template struct callable_base_type> : callable_base_type {}; #endif }}} // namespace boost::hof #endif