// Copyright Daniel Wallin 2006. Use, modification and distribution is // subject to 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) #include #include #include #include namespace test { BOOST_PARAMETER_KEYWORD(tag, x) BOOST_PARAMETER_KEYWORD(tag, y) BOOST_PARAMETER_KEYWORD(tag, z) struct X { BOOST_PARAMETER_MEMBER_FUNCTION((int), f, tag, (required (x, *) (y, *) ) (optional (z, *) ) ) { return args[x] + args[y] + args[z | 0]; } BOOST_PARAMETER_MEMBER_FUNCTION((std::string), g, tag, (optional (x, *) (y, *) ) ) { return std::string(args[x | "foo"]) + args[y | "bar"]; } }; } // namespace test struct f_fwd { template R operator()(boost::type, T& self, A0 const& a0, A1 const& a1, A2 const& a2) { return self.f(a0,a1,a2); } }; struct g_fwd { template R operator()(boost::type, T& self, A0 const& a0, A1 const& a1) { return self.g(a0,a1); } }; BOOST_PYTHON_MODULE(python_parameter) { namespace mpl = boost::mpl; using namespace test; using namespace boost::python; class_("X") .def( "f" , boost::parameter::python::function< f_fwd , mpl::vector3 , mpl::vector4 >() ) .def( "g" , boost::parameter::python::function< g_fwd , mpl::vector2 , mpl::vector3 >() ); }