[pygccxml-development] Default template parameters
Brought to you by:
mbaas,
roman_yakovenko
From: Berserker <ber...@ho...> - 2010-02-17 11:49:25
|
Hi, I found a problem in the wrapper code generated by Py++ on functions with default template parameters (with more than one template parameter) Example: class Foo { public: void test( const std::map<std::string, std::string> & p = std::map<std::string, std::string>() ); }; Py++ actually generates: struct Foo_wrapper : public ... { static void test( ::Foo & inst, std::map< std::string, std::string > const & p = std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >() ) { // My pre_call_code inst.test(p); // My post_call_code } } and typedef void ( *test_function_type )( ::Foo &,std::map<std::string, std::string> const & ); Foo_exposer.def( "test" , test_function_type( &Foo_wrapper::test ) , ( ::boost::python::arg("inst"), ::boost::python::arg("p")=std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >() ) ); On VC8 this code compiles fine, but on GCC ( due to a bug reported here http://stackoverflow.com/questions/851584/default-template-class-argument-confuses-g ) it doesn't. On the last GCC version this problem seems fixed but on GCC 4.2 (tested on MAC) I can reproduce it. Is there a quick fix to "protect" default arguments with ( )? An alternative solution would be to define an "alias" for the template, something like this: struct Foo_wrapper : public ... { static void test( ::Foo & inst, std_map_string_string const & p= std_map_string_string() ) { // My pre_call_code inst.test(p); // My post_call_code } } and typedef void ( *test_function_type )( ::Foo &,std_map_string_string const & ); Foo_exposer.def( "test" , test_function_type( &Foo_wrapper::test ) , ( ::boost::python::arg("inst"), ::boost::python::arg("p")=std_map_string_string() ) ); is it already possible? Bye _________________________________________________________________ Personalizza la tua vita digitale, scarica i nuovi gadget! http://www.pimpit.it/ |