Putting together boost::any, mpl::vector, iterator::filter_iterator

I've put together a class called 'AnyVector' for doing type-based iteration
on a vector. The basic idea is that AnyVector wraps a
std::vectorboost::any. The AnyVector lets you iterate across a subset of
the underlying vector by using filter_iterators. The filter iterators, in
turn, dereference to the requested type for ease of use. For instance, you
can do the following:
=== CODE ===
AnyVector<> a;
a.push_back(1);
a.push_back(std::string("hello"));
a.push_back(2);
a.push_back(std::string("goodbye"));
for(AnyVector<>::Iterator<int> i = a.begin<int>(); i != a.end<int>(); ++i)
std::cout << (*i + 5);
for(AnyVector<>::Iteratorstd::string i = a.beginstd::string(); i !=
a.endstd::string(); ++i) std::cout << i->length();
============
Furthermore, you can restrict (at compile-time) which objects are allowed to
be inserted into the AnyVector. This is done by listing those types when you
create your AnyVector:
=== CODE ====
AnyVector
participants (1)
-
Stephen Gross