[C++-sig] A couple of simple BP V2 questions

Joel de Guzman djowel at gmx.co.uk
Wed Nov 13 18:53:27 CET 2002

----- Original Message ----- 
From: "Scott A. Smith" <ssmith at magnet.fsu.edu>

> Just a few things as I go through the tutorial.
> On this page
> http://www.boost.org/libs/python/doc/tutorial/doc/default_arguments.html
> there is a nice discussion as to how one deals with functions that have
> default arguments. As for overloaded functions, things are a litte more
> cryptic.
> Where it says to use the described methods when the functions
> "are overloaded with a common sequence of initial arguments"
> I guess that indicates that
> 1.) The function return types are the same?
> 2.) The ordering of the arguments are very much the same
>     i.e. (int), (int, string), (int, string, double)
>     but then NOT (string,double,int)?
> 3.) If any overload is significantly dissimilar do not use this method?

> If that is true, then I think the text should discuss overloaded functions a
> little
> better since many (most) overloads will have such dissimilarities. In such
> cases
> then I assume one must still use thin wrappers?

No, not really. You can still use the overloads mechanism without
using thin wrappers for overloads with different signatures. You'll
call for each set of overload signature.

See boost/libs/python/defaults.cpp for examples. There you'll
see a class X with:

    object foo(std::string a, bool b=false) const;
    object foo(list a, list b, bool c=false) const;



> I think the page should have a link to the additional information in the
> reference manual.
> http://www.boost.org/libs/python/doc/v2/overloads.html#BOOST_PYTHON_FUNCTION


> While the above reference page does show how to do overloads of the function
> "f", but these
> are quite different than dealing with say two different class Y member
> functions named f that
> have different argument types.  This is what I am trying to do at the moment
> and, after quite a bit
> of time trying to figure how out to use
> have now decided that I must use thin wrappers?

I hope not. The overloads facility is there precisely to
help us in these situations...

Again, see above.


More information about the Cplusplus-sig mailing list