Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Copyright David Abrahams 2003.
0002 // Distributed under the Boost Software License, Version 1.0. (See
0003 // accompanying file LICENSE_1_0.txt or copy at
0004 // http://www.boost.org/LICENSE_1_0.txt)
0005 #ifndef NULLARY_FUNCTION_ADAPTOR_DWA2003824_HPP
0006 # define NULLARY_FUNCTION_ADAPTOR_DWA2003824_HPP
0007 
0008 # include <boost/python/detail/prefix.hpp>
0009 # include <boost/preprocessor/iteration/local.hpp>
0010 # include <boost/preprocessor/facilities/intercept.hpp>
0011 # include <boost/preprocessor/repetition/enum_params.hpp>
0012 # include <boost/preprocessor/repetition/enum_binary_params.hpp>
0013 
0014 namespace boost { namespace python { namespace detail { 
0015 
0016 // nullary_function_adaptor -- a class template which ignores its
0017 // arguments and calls a nullary function instead.  Used for building
0018 // error-reporting functions, c.f. pure_virtual
0019 template <class NullaryFunction>
0020 struct nullary_function_adaptor
0021 {
0022     nullary_function_adaptor(NullaryFunction fn)
0023       : m_fn(fn)
0024     {}
0025 
0026     void operator()() const { m_fn(); }
0027 
0028 # define BOOST_PP_LOCAL_MACRO(i)                                            \
0029     template <BOOST_PP_ENUM_PARAMS_Z(1, i, class A)>                        \
0030     void operator()(                                                        \
0031         BOOST_PP_ENUM_BINARY_PARAMS_Z(1, i, A, const& BOOST_PP_INTERCEPT)   \
0032     ) const                                                                 \
0033     {                                                                       \
0034         m_fn();                                                             \
0035     }
0036 
0037 # define BOOST_PP_LOCAL_LIMITS (1, BOOST_PYTHON_MAX_ARITY)
0038 # include BOOST_PP_LOCAL_ITERATE()
0039     
0040  private:
0041     NullaryFunction m_fn;
0042 };
0043 
0044 }}} // namespace boost::python::detail
0045 
0046 #endif // NULLARY_FUNCTION_ADAPTOR_DWA2003824_HPP