Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*=============================================================================
0002     Copyright (c) 2015 Paul Fultz II
0003     callable_base.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_CALLABLE_BASE_H
0009 #define BOOST_HOF_GUARD_CALLABLE_BASE_H
0010 
0011 #include <boost/hof/detail/delegate.hpp>
0012 #include <boost/hof/detail/result_of.hpp>
0013 #include <boost/hof/apply.hpp>
0014 
0015 #ifndef BOOST_HOF_CALLABLE_BASE_USE_TEMPLATE_ALIAS
0016 #if (defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7)
0017 #define BOOST_HOF_CALLABLE_BASE_USE_TEMPLATE_ALIAS 0
0018 #else
0019 #define BOOST_HOF_CALLABLE_BASE_USE_TEMPLATE_ALIAS 1
0020 #endif
0021 #endif
0022 
0023 namespace boost { namespace hof { namespace detail {
0024 
0025 template<class F>
0026 struct non_class_function
0027 {
0028     F f;
0029     BOOST_HOF_DELEGATE_CONSTRUCTOR(non_class_function, F, f)
0030 
0031     template<class... Ts>
0032     constexpr BOOST_HOF_SFINAE_RESULT(apply_f, id_<F>, id_<Ts>...) 
0033     operator()(Ts&&... xs) const BOOST_HOF_SFINAE_RETURNS
0034     (
0035         boost::hof::apply(f, BOOST_HOF_FORWARD(Ts)(xs)...)
0036     );
0037 };
0038 
0039 template<class F>
0040 struct callable_base_type
0041 : std::conditional<(BOOST_HOF_IS_CLASS(F) && !BOOST_HOF_IS_FINAL(F) && !BOOST_HOF_IS_POLYMORPHIC(F)), F, non_class_function<F>>
0042 {};
0043 
0044 #if BOOST_HOF_CALLABLE_BASE_USE_TEMPLATE_ALIAS
0045 template<class F>
0046 using callable_base = typename callable_base_type<F>::type;
0047 #else
0048 template<class F>
0049 struct callable_base
0050 : callable_base_type<F>::type
0051 {
0052     typedef typename callable_base_type<F>::type base;
0053     BOOST_HOF_INHERIT_CONSTRUCTOR(callable_base, base)
0054 };
0055 
0056 template<class F>
0057 struct callable_base_type<callable_base<F>>
0058 : callable_base_type<F>
0059 {};
0060 
0061 #endif
0062 
0063 }}} // namespace boost::hof
0064 
0065 #endif