We have a lot of C++ code using a home-grown Event<T> class template. An Event<T> is just a list of pointers to callback function objects. More precisely, an Event<T> is a std::list<unary_function<T>*>, where unary_function is a polymorphic function object class. Code that generates an event iterates through the list, dereferences each pointer and calls the corresponding function.

I'd like python code to be able to generate these C++ events. To do that Event<>s need to support Python's iterable interface, which requires random access to the container. Unfortunately, std::list<> doesn't support random access. Short of copying the contents of every std::list<> to a std::vector<> for Python's benefit I don't see how this can be accomplished.

Does anyone have any ideas for a simpler, more natural implementation?

--
Phil Bass (p...@isotek.co.uk)

    The views expressed in this e-mail/posting are those of the author
    and do not necessarily reflect those of Isotek Electronics Ltd.


_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to