// Copyright (C) 2009-2012 Lorenzo Caminiti // Distributed under the Boost Software License, Version 1.0 // (see accompanying file LICENSE_1_0.txt or a copy at // http://www.boost.org/LICENSE_1_0.txt) // Home at http://www.boost.org/libs/functional/overloaded_function #if !ACTIV_BOOST_PP_IS_ITERATING # ifndef ACTIV_BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_DETAIL_BASE_HPP_ # define ACTIV_BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_DETAIL_BASE_HPP_ # include # include # include # include # include # include #define ACTIV_BOOST_FUNCTIONAL_DETAIL_arg_type(z, n, unused) \ ACTIV_BOOST_PP_CAT(A, n) #define ACTIV_BOOST_FUNCTIONAL_DETAIL_arg_name(z, n, unused) \ ACTIV_BOOST_PP_CAT(a, n) #define ACTIV_BOOST_FUNCTIONAL_DETAIL_arg_tparam(z, n, unused) \ typename ACTIV_BOOST_FUNCTIONAL_DETAIL_arg_type(z, n, unused) #define ACTIV_BOOST_FUNCTIONAL_DETAIL_arg(z, n, unused) \ ACTIV_BOOST_FUNCTIONAL_DETAIL_arg_type(z, n, unused) \ ACTIV_BOOST_FUNCTIONAL_DETAIL_arg_name(z, n, unused) #define ACTIV_BOOST_FUNCTIONAL_DETAIL_f \ R (ACTIV_BOOST_PP_ENUM(ACTIV_BOOST_FUNCTIONAL_DETAIL_arity, \ ACTIV_BOOST_FUNCTIONAL_DETAIL_arg_type, ~)) // Do not use namespace ::detail because overloaded_function is already a class. namespace Boost { namespace overloaded_function_detail { template class base {}; // Empty template cannot be used directly (only its spec). # define ACTIV_BOOST_PP_ITERATION_PARAMS_1 \ (3, (0, ACTIV_BOOST_FUNCTIONAL_OVERLOADED_FUNCTION_CONFIG_ARITY_MAX, \ "ActivBoost/functional/overloaded_function/detail/base.hpp")) # include ACTIV_BOOST_PP_ITERATE() // Iterate over funciton arity. } } // namespace #undef ACTIV_BOOST_FUNCTIONAL_DETAIL_arg_type #undef ACTIV_BOOST_FUNCTIONAL_DETAIL_arg_name #undef ACTIV_BOOST_FUNCTIONAL_DETAIL_arg_tparam #undef ACTIV_BOOST_FUNCTIONAL_DETAIL_arg #undef ACTIV_BOOST_FUNCTIONAL_DETAIL_f # endif // #include guard #elif ACTIV_BOOST_PP_ITERATION_DEPTH() == 1 # define ACTIV_BOOST_FUNCTIONAL_DETAIL_arity ACTIV_BOOST_PP_FRAME_ITERATION(1) template< typename R ACTIV_BOOST_PP_COMMA_IF(ACTIV_BOOST_FUNCTIONAL_DETAIL_arity) ACTIV_BOOST_PP_ENUM(ACTIV_BOOST_FUNCTIONAL_DETAIL_arity, ACTIV_BOOST_FUNCTIONAL_DETAIL_arg_tparam, ~) > class base< ACTIV_BOOST_FUNCTIONAL_DETAIL_f > { public: /* implicit */ inline base( // This requires specified type to be implicitly convertible to // a Boost::function<> functor. Boost::function< ACTIV_BOOST_FUNCTIONAL_DETAIL_f > const& f): f_(f) {} inline R operator()(ACTIV_BOOST_PP_ENUM(ACTIV_BOOST_FUNCTIONAL_DETAIL_arity, ACTIV_BOOST_FUNCTIONAL_DETAIL_arg, ~)) const { return f_(ACTIV_BOOST_PP_ENUM(ACTIV_BOOST_FUNCTIONAL_DETAIL_arity, ACTIV_BOOST_FUNCTIONAL_DETAIL_arg_name, ~)); } private: Boost::function< ACTIV_BOOST_FUNCTIONAL_DETAIL_f > const f_; }; # undef ACTIV_BOOST_FUNCTIONAL_DETAIL_arity #endif // iteration