#include <boost/static_assert.hpp> #include <boost/mpl/list_c.hpp> #include <boost/mpl/fold.hpp> #include <boost/mpl/plus.hpp> using namespace boost::mpl; template <class Seq> struct length { static const int value = fold<Seq, int_<0>, plus<_1, int_<1> > >::type::value; }; int main() { typedef list_c<int, 1, 2, 3, 4, 5> ls; BOOST_STATIC_ASSERT(length<ls>::value == 5); }