Listing 1: Querying a vector of vectors for the maximal size
max_size<std::vector<Something> > the_max = std::for_each( vect_of_vects.begin(), vect_of_vects.end(), max_size<std::vector<Something> >() ); size_t m = the_max.get_max(); template<typename T> class max_size { public: max_size() : m_max_size(0) {} size_t get_max() const { return m_max_size; } void operator()(const T& cont) { m_max_size = std::_cpp_max(cont.size(), m_max_size); } private: size_t m_max_size; }; End of Listing