Given a type T, i need the type of the elements of T if T is an STL container, otherwise the result should just be the type T.
I'm no good with templates, but here is what i've tried using the hit-and-miss methodology:
The idea is that element_type<int>::type would just be int, and element_type<std::vector<int>>::type would also be int. Unfortunately this code just gives me a bunch of template errors, any hints as to what the problem is?Code:template <typename T> struct element_type { typedef T type; }; template <template <typename...> class Container, typename T, typename Ts...> struct element_type<Container<T, Ts...>> { typedef T type; };