Template Template C++ Function
问题 How do I write a template function that operates on a arbitrary container of a arbitrary type? For example how do I generalize this dummy function template <typename Element> void print_size(const std::vector<Element> & a) { cout << a.size() << endl; } to template <template<typename> class Container, typename Element> void print_size(const Container<Element> & a) { cout << a.size() << endl; } Here is a typical usage std::vector<std::string> f; print_size(f) This give error tests/t_distances