How to get a type relative to a runtime index?
Let's say I have a boost::mpl::list< A, B, C ...>
.
How do I access one of those typ开发者_运维技巧es given an index value at runtime? Is it even possible?
http://www.boost.org/doc/libs/release/libs/mpl/doc/refmanual/for-each.html
you basically have to iterate over the entire list and introduce some sort of conditional: eg:
struct F {
void operator(T &t) {
if (i_ == index) ...
++i;
}
int index = ...;
int i_ = 0;
};
for_each< L >( F(index) );
精彩评论