[C++-sig] Problems with overloading

Roman Yakovenko roman.yakovenko at gmail.com
Wed Mar 29 08:06:53 CEST 2006


On 3/29/06, Arrakis Muadib <marrakis at gmail.com> wrote:
> Hi,
>
> I have some problems dealing with overleading utilities. I'm supposed
> to use the macro BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS. But it's not
> working:
>
> for:
>
> void insert(position pos, const std::string& text, const user* author);
>
> and
>
> void insert(position pos, const line& text)
>
> I wrote:
>
> BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(insert_member_overloads, insert, 2, 3);

This macro can not handle such case. Search for "Providing a default
value for a pointer argument" post in order to get some ideas why.
Also it is very simple to solve your problem:

#include <string>
struct user{};
struct document{
    void
    insert(int pos, const std::string& text, const user* author);
    void
    insert(int pos, const int& text);
};

next code has been created by pyplusplus gui wizard:

    bp::class_< document >( "document" )
        .def( "insert"
                , (void ( ::document::* )( int,::std::string const
&,::user const * ) )(&document::insert)
                , ( bp::arg("pos"), bp::arg("text"), bp::arg("author") )
                , bp::default_call_policies() )
        .def( "insert"
                , (void ( ::document::* )( int,int const & )
)(&document::insert)
                , ( bp::arg("pos"), bp::arg("text") )
                , bp::default_call_policies() );

( If you are going to try it, please take cvs version )

--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list