[C++-sig] Type conversion problem

Randall Hopper viznut at charter.net
Fri Nov 3 16:46:19 CET 2006


Left out a useful piece:

Randall Hopper:
 |and here's a piece of the referenced template:
 |
 |  using namespace boost::python;
 |
 |  template <typename T, typename BT>
 |  class TemplateCompArray
 |  {
 |    public :
 |      TemplateCompArray(const char * name) : _array(name, boost::python::no_init) {
 |          _array
 |              .def(init<>())
 |              .def(init<int>())
 |              .def("__init__", make_constructor(&create_from_tuple))
 |              .def("getNumElements", &T::getNumElements)
 |              .def("__getitem__", &getitem, return_internal_reference<>())
 |              .def("__setitem__", &setitem, return_internal_reference<>())
 |              .def("resize", &resize)
 |              .def("__str__", &str)
 |              ...
 |      static std::string str(T * self)
 |      {
 |        ...
 |      }

    private:
      class_<T, osg::ref_ptr<T>, bases<osg::Array>, boost::noncopyable> _array;

 |  }

I guess I've been perplexed a bit by the boost syntax and not knowing how
the boost templates expand and what that does to the type structure.

But I'm starting to suspect that some sort of type redirection is required
since the actual boost-wrapped array is a private member of the registered
class.

I'm I even close?

Thanks,

Randall



More information about the Cplusplus-sig mailing list