If you do not want to rely on integer_sequence that is c++14, this is a simpler solution :
#include <iostream>
template<unsigned int N>
struct A {
void dostuff() const { std::cout << N << " "; }
};
template < int N > void run();
template <> void run<-1>() {}
template < int N > void run() {
run<N-1>();
A<N>{}.dostuff();
}
int main() {
run<10>();
}
EDIT : about your question update, you can do that if you store the objects inside a tuple, see here :
#include <iostream>
#include <tuple>
template<unsigned int N>
struct A {
unsigned int getN() const { return N; }
void dostuff() const { std::cout << N << " "; }
};
auto globals = std::make_tuple( A<3>{}, A<7>{}, A<10>{}, A<200>{} );
template <int idx> void run( int v );
template <> void run<std::tuple_size<decltype(globals)>::value>( int ) {}
template <int idx = 0> void run( int v ) {
auto & a = std::get<idx>(globals);
if ( v < a.getN() ) {
a.dostuff();
} else {
run<idx+1>(v);
}
}
int main() {
for( int i = 0; i<20; ++i)
run( i );
}