[C++-sig] Providing a default value for a pointer argument

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Wed Mar 22 15:24:14 CET 2006


--- Matthias Baas <baas at ira.uka.de> wrote:
> int ptrarg(Spam* s=0)
> {
>    if (s==0)
>      return 0;
>    else
>      return 1;
> }
> 
> BOOST_PYTHON_MODULE(mod)
> {
>    class_<Spam>("Spam", init<>());
> 
>    def("ptrarg", ptrarg, (arg("s")=0));
> }

You are missing BOOST_PYTHON_FUNCTION_OVERLOADS for ptrarg:

  http://www.boost.org/libs/python/doc/v2/overloads.html

I am not sure if the =0 works for pointers, but the overloads trick is
definitely required.

Cheers,
        Ralf


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Cplusplus-sig mailing list