diff --git a/test/python/Jamfile b/test/python/Jamfile index 38220c0..f93436c 100755 --- a/test/python/Jamfile +++ b/test/python/Jamfile @@ -8,3 +8,8 @@ extension parameter ../../../python/build/boost_python ; +extension general + : general.cpp + ../../../python/build/boost_python + ; + diff --git a/test/python/general.cpp b/test/python/general.cpp new file mode 100755 index 0000000..bf8e84c --- /dev/null +++ b/test/python/general.cpp @@ -0,0 +1,100 @@ +// Copyright Daniel Wallin 2005. 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 + +namespace mpl = boost::mpl; + +BOOST_PARAMETER_KEYWORD(tag, x) +BOOST_PARAMETER_KEYWORD(tag, y) +BOOST_PARAMETER_KEYWORD(tag, z) + +struct tag::x +{ + static char const* keyword() + { + return "x"; + } +}; + + +struct tag::y +{ + static char const* keyword() + { + return "y"; + } +}; + +struct tag::z +{ + static char const* keyword() + { + return "z"; + } +}; + +typedef boost::parameter::parameters< + tag::x + , tag::y +> f_parameters; + +template +float f_impl(Args const& args) +{ + return args[x | 1] / args[y | 1]; +} + +template +float f(A0 const& a0) +{ + return f_impl(f_parameters()(a0)); +} + +template +float f(A0 const& a0, A1 const& a1) +{ + return f_impl(f_parameters()(a0,a1)); +} + +template +float f(A0 const& a0, A1 const& a1, A2 const& a2) +{ + return f_impl(f_parameters()(a0,a1,a2)); +} + +struct meta +{ + typedef mpl::vector3< + mpl::pair + , mpl::pair + , mpl::pair + > keywords; + + template + R operator()(boost::type, A0 const& a0) + { + return f(a0); + } + + template + R operator()(boost::type, A0 const& a0, A1 const& a1) + { + return f(a0,a1); + } + + template + R operator()(boost::type, A0 const& a0, A1 const& a1, A2 const& a2) + { + return f(a0,a1,a2); + } +}; + +BOOST_PYTHON_MODULE(general) +{ + boost::parameter::python::def("f", mpl::vector4()); +} +