In the following setup, how can I do this so that I can refer to the name Bar
inside the Derived<T>
derived class?
template <typename T> struct Foo { template <typename U> struct Bar { }; }; template <typename T> struct Derived : Foo<T> {
I tried using Foo<T>::Bar;
but it doesn’t help. Is there any using
declaration that can make the name of the nested base template known to the derived class so that I can keep simple de & shy; cla & shy; ration Bar<int> x
?
I know I can say typename Foo<T>::template Bar<int> x;
, but I have many such cases, and I do not want to burden the code unnecessary with such verbosity. I also have many different " int
s", so a typedef
for each instance of the nested template is also impossible.
In addition, I cannot use GCC 4.7 at this stage, not C ++ 11, and thus you will like the “traditional” solution without template aliases.
source share