I was writing code with plenty of templated classes and have encountered a problem when in a class I needed to use a templated alias from another templated class. I wrote the code and everything was fine until this code was attempted to be compiled on Ubuntu 20.04 which is packed with G++9. Without going too much in-detail here is the short snippet that reproduces the problem perfectly:
#include <vector>
template <typename A> struct S1 {
template <typename D> using VT = std::vector<D>;
};
template <typename A> struct S2 {
template <typename D> using VT = typename S1<A>::VT<D>;
};
int main() {
S2<int> s;
return 0;
}
Compiling this on my own Arch machine with G++ 11.2.0 is completely fine, but when I try to do the same with G++ 9.4.0, it fails with:
test.cpp:8:53: error: expected ‘;’ before ‘<’ token
8 | template <typename D> using VT = typename S1<A>::VT<D>;
| ^
| ;
Is there any particular change made to G++ that's causing that? Why was it implemented, is it a part of C++17 standard? And, most importantly, is there any sensible way to provide functionally the same code that will work with G++9?