I was actually surprised that both gcc and clang accept this code:
#include <iostream>
#include <vector>
#include <type_traits>
template <class T, template <class, class = T> class TT, class Y>
T foo(TT<Y>) {
}
int main() {
static_assert(std::is_same<decltype(foo(std::vector<int>{})), std::allocator<int>>::value);
}
Are gcc and clang right that the values of the default template template parameters are deduced context or is it compilers extension?
When you write
template <class T, template <class, class = T> class TT, class Y>
T foo(TT<Y>);
it is equivalent to
template <class T, template <class, class = T> class TT, class Y>
T foo(TT<Y, T>);
So T
can be deduced.