]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/python/include/boost/python/detail/nullary_function_adaptor.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / python / include / boost / python / detail / nullary_function_adaptor.hpp
CommitLineData
7c673cae
FG
1// Copyright David Abrahams 2003.
2// Distributed under the Boost Software License, Version 1.0. (See
3// accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5#ifndef NULLARY_FUNCTION_ADAPTOR_DWA2003824_HPP
6# define NULLARY_FUNCTION_ADAPTOR_DWA2003824_HPP
7
8# include <boost/python/detail/prefix.hpp>
9# include <boost/preprocessor/iteration/local.hpp>
10# include <boost/preprocessor/facilities/intercept.hpp>
11# include <boost/preprocessor/repetition/enum_params.hpp>
12# include <boost/preprocessor/repetition/enum_binary_params.hpp>
13
14namespace boost { namespace python { namespace detail {
15
16// nullary_function_adaptor -- a class template which ignores its
17// arguments and calls a nullary function instead. Used for building
18// error-reporting functions, c.f. pure_virtual
19template <class NullaryFunction>
20struct nullary_function_adaptor
21{
22 nullary_function_adaptor(NullaryFunction fn)
23 : m_fn(fn)
24 {}
25
26 void operator()() const { m_fn(); }
27
28# define BOOST_PP_LOCAL_MACRO(i) \
29 template <BOOST_PP_ENUM_PARAMS_Z(1, i, class A)> \
30 void operator()( \
31 BOOST_PP_ENUM_BINARY_PARAMS_Z(1, i, A, const& BOOST_PP_INTERCEPT) \
32 ) const \
33 { \
34 m_fn(); \
35 }
36
37# define BOOST_PP_LOCAL_LIMITS (1, BOOST_PYTHON_MAX_ARITY)
38# include BOOST_PP_LOCAL_ITERATE()
39
40 private:
41 NullaryFunction m_fn;
42};
43
44}}} // namespace boost::python::detail
45
46#endif // NULLARY_FUNCTION_ADAPTOR_DWA2003824_HPP