[C++-sig] Conversion of python files to C++ ostreams

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Sun Apr 4 05:54:41 CEST 2010


> Now I am faced with wrapping a constructor that takes a

> "std::ostream&" as an argument.  I don't know how to write a wrapper
> for a constructor in boost.python.  I'm open to suggestions on this.
> For example:
> 
> // C++ API
> struct Foo {
>     Foo(ostream& os);
> };
> 
> # desired python usage
> foo = Foo(streambuf(sys.stdout))

Did you already try the usual

  def(init<ostream&>((arg("os"))))

?

I think it should just work (but I haven't actually tried it).

Ralf


More information about the Cplusplus-sig mailing list