[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-cpp-sig
Subject:    [C++-sig] Virtual Methods + default arguments
From:       c++-sig () python ! org (Nicodemus)
Date:       2003-02-26 4:58:48
Message-ID: 3E5C4988.5010501 () globalite ! com ! br
[Download RAW message or body]

David Abrahams wrote:

>Bruno da Silva de Oliveira <bso@inf.ufsc.br> writes:
>  
>
>>Hi!
>>
>>Is it possible to indicate default arguments for virtual methods,
>>using the BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS macro?
>>
>>    
>>
>
><snip>
>
>  
>
>>I also tried to change the second .def to:
>>
>>   .def("f", &XWrap::f, f_overloads())
>>
>>and:
>>
>>   .def("f", &XWrap::default_f, f_overloads())
>>
>>But with the same results.
>>    
>>
>
>This one is on the right track, but you need a separate version of
>f_overloads for the second one.  The 2nd argument to def in this case
>just carries type information; it could be a null function pointer
>for all Boost.Python cares.  It's the 3rd arg which carries all the
>info about what functions to call.
>

Nice. The solution is define the overloads as:

    BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_overloads, default_f, 0, 2)

generate the module as:

    class_< X, XWrap >("X")       
        .def("f", &X::f, &XWrap::default_f )
        .def("f", &XWrap::default_f, f_overloads())
    ;

Thanks a lot Dave! (Don't you sleep? 8P)

Farewell,
Nicodemus.




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic