Milo & Cuch: that code won't compile with Clang or GCC either (tested with development revisions, Clang 3.4 and GCC 4.9), since it's wrong.Recall that std::vector class template has *two* template parameters -- T and Allocator:
http://en.cppreference.com/w/cpp/container/vectorSo, we have to take that into account: template <template <typename, typename> class Container, typename T>T statistic(Container<T, std::allocator<T>> const & container)//
http://ideone.com/uCntM9Alternatively, we may use variadic TTP (clearly, non-variadic TTP is not templatey enough ;]) and stick the unused parameter(s) into a parameter pack ("Ts" in the following) as such:template< template <typename, typename...> class Container, typename T, typename... Ts>T statistic(Container<T, Ts...> const& container)//
http://ideone.com/uFRlaXIs this generic? NO!Consider a container with (one or more) non-type template parameter(s), like, say, std::array.Here's what happens if you (incorrectly) attempt to treat this non-type template parameter as if it were a type template parameter:[0] TTP:
http://ideone.com/9X9yZE[1] VTTP:
http://ideone.com/jaQ4ohMy proposed solution would be to KISS:template <typename Container>typename Container::value_type statistic(Container const & container)//
http://ideone.com/85poIGUpsides? It works and it's (relatively) generic.Downsides? Compile-type duck typing, so perhaps a little too generic for some (depends on taste) (but this is solvable via type template constraints - with traits & static_assert today and with concepts tomorrow); a bit on the verbose side all with having to type "typename Container::value_type" (that will go away with return-type deduction in C++14; note, however, that it's already shorter than any of the TTP alternatives).Exercise for the TTP-for-the-sake-of-TTP enthusiasts: fix [0] & [1] :>