[C++-sig] Iterators for heterogeneous container
Thomas Daniel
thomasd57 at yahoo.com
Fri Nov 6 08:09:34 CET 2009
I am having trouble wrapping a container that can hold multiple object
types and therefore has multiple iterator types.
My C++ library has these classes:
class Tomato;
class Potato;
class Garden {
Iter<Tomato> get_tomatoes();
Iter<Potato> get_potatoes();
};
template<class T>
class Iter {
T get_next();
};
which allows to write:
Iter<Potato> potatoes = garden.get_potatoes();
while (Potato potato = potatoes.get_next()) {
cout << potato.name();
}
I am trying to use boost to wrap it so that I can write in python:
for potato in garden.get_potatoes():
print potato.name()
Any pointers how to achieve this with boost?
More information about the Cplusplus-sig
mailing list