[C++-sig] wrapping constructor

Neal D. Becker ndbecker2 at verizon.net
Thu Apr 8 13:35:29 CEST 2004


Using boost-python I have a class with non-default constructor.  I don't
want to expose this constructor to python, but want to wrap it in a new
interface.  Is this OK?  (No ownership issues...)  I'm assuming copying the
object is not terribly expensive, or won't happen that often.

class X {
  X (something something)
};

X MakeX (some args more suitable for python) {
  return X (use above constructor);
}

BOOST_PYTHON_MODULE(X_wrap) {
  class_<X> ("X", no_init);

  def ("MakeX", MakeX);
}






More information about the Cplusplus-sig mailing list