[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
> 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
> 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
> better since many (most) overloads will have such dissimilarities. In such
> 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
just need another BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS
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;
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(X_foo_2_stubs, foo, 1, 2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(X_foo_3_stubs, foo, 2, 3)
> I think the page should have a link to the additional information in the
> reference manual.
> 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
> BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS I
> 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