Why can't I declare a type with both template container and template contained value?

Viewed 99

Why isn't this valid C++?

template <typename Container, typename T>
bool
foo (const Container <T> &);

g++ gives me Container is not a template which is clearly not what it really means.

Trying template <typename Container> template <typename T> doesn't work either, neither does const typename Container <T> &

It seems reasonable to me that one would want to define an interface which is generic over both the container and the contained type.

So,

  • in terms of standards, why isn't this allowed?
  • in terms of designing standards, why wouldn't this be allowed, would it cause problems?
  • is there a workaround in C++14, other than basing the interface on iterators?
1 Answers
Related