Boost logo

Boost :

From: John Hunter (jdhunter_at_[hidden])
Date: 2001-08-16 17:26:10

>>>>> "Ralf" == Ralf W Grosse-Kunstleve <rwgk_at_[hidden]> writes:

    Ralf> with optional arguments. However, the default arguments are
    Ralf> lost at the Python level. Therefore I usually define *free*
    Ralf> C++ functions, e.g.:

That works perfectly for me. Do you have a similarly clever trick for
classes with several constructors, each of which takes (the same)
optional argument as the last arg?

class SomeClass {
  SomeClass( int i = 5) { ... }
  SomeClass( const string& s, int i = 5) { ... }
  SomeClass( const string& s1, const string& s2, int i = 5) { ... }

I have though about making functions like

  return SomeClass();

py_SomeClass_string_construct(const string& s)
  return SomeClass(s);

py_SomeClass_two_string_construct(const string& s1, const string& s2)
  return SomeClass(s1,s2);

But am not sure how I would use these....

John Hunter

Boost list run by bdawes at, gregod at, cpdaniel at, john at