diff --git a/include/boost/python/args.hpp b/include/boost/python/args.hpp index b5c27be8..c7363dbe 100644 --- a/include/boost/python/args.hpp +++ b/include/boost/python/args.hpp @@ -47,6 +47,21 @@ namespace detail } keyword elements[nkeywords]; + + keywords operator,(arg const &k) const + { + keywords const& l = *static_cast const*>(this); + python::detail::keywords res; + std::copy(l.elements, l.elements+nkeywords, res.elements); + res.elements[nkeywords] = k.elements[0]; + return res; + } + + keywords + operator,(char const *name) const + { + return this->operator,(python::arg(name)); + } }; template @@ -76,15 +91,6 @@ namespace detail } }; - template - keywords operator,(keywords const& l, const keywords<1> &k) - { - python::detail::keywords res; - std::copy(l.elements, l.elements+nkeywords, res.elements); - res.elements[nkeywords] = k.elements[0]; - return res; - } - # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template struct is_keywords @@ -136,16 +142,6 @@ namespace detail # endif } -namespace detail -{ - template - inline keywords - operator,(keywords const& l, char *name) - { - return l.operator,(arg(name)); - } -} - inline detail::keywords<1> args(char const* name) { return detail::keywords<1>(name); diff --git a/test/keywords.cpp b/test/keywords.cpp index 04e6da32..fac0433e 100755 --- a/test/keywords.cpp +++ b/test/keywords.cpp @@ -93,6 +93,8 @@ BOOST_PYTHON_MODULE(keywords) .def("set", &Foo::set, (arg("a") = 0, arg("b") = 0.0, arg("n") = std::string()) ) + .def("set2", &Foo::set, (arg("a"), "b", "n") ) + .def("a", &Foo::geta) .def("b", &Foo::getb) .def("n", &Foo::getn) diff --git a/test/keywords_test.py b/test/keywords_test.py index 79cdf148..072e3f6f 100644 --- a/test/keywords_test.py +++ b/test/keywords_test.py @@ -48,6 +48,9 @@ >>> f.set(1,n="1") >>> f.a(), f.b(), f.n() (1, 0.0, '1') +>>> f.set2(b=2.0,n="2",a=2) +>>> f.a(), f.b(), f.n() +(2, 2.0, '2') # lets see how badly we've broken the 'regular' functions >>> f = Bar()