[C++-sig] How to use make_default with keyword expression

Johan Råde johan.rade at gmail.com
Sun Feb 19 09:46:05 CET 2012


The following code works fine:

     using namespace boost::python;

     class X {};

     X* make_X(int n, float f) { return new X; }

     BOOST_PYTHON_MODULE(Test)
     {
         class_<X>("X")
         .def(
             "__init__",
             make_constructor(&make_X)
             //,(arg("n"), arg("f") = 1.0f)
         );
     }

But if I uncomment the commented line, then the code does not compile.
How do I fix that?



More information about the Cplusplus-sig mailing list