Add support for fully qualifying a template argument that is itself a template.

This is the case for example with gcc's

  __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool,true>

where __pool is actually a class template.

Also reduce (a little bit) code duplication.