1

There is a nested template type that has a template parameter, but this is used in another templated function where the type reference is a dependent name.

template <class T1>
struct s
{
    template <class T2>
    struct s2
    {

    };
};

template <template <class> class T>
void func()
{
    T<int>();
}

template <class T>
void func2()
{
    func<s<T>::s2>(); //error
}

However, this yields an error:

error: dependent-name s<T>::s2 is parsed as a non-type, but instantiation yields a type
note: say typename s<T>::s2 if a type is meant

Adding typename does not help though:

error: typename s<int>::s2 names template<class T2> struct s<int>::s2, which is not a type

Neither adding template works:

error: parse error in template argument list
func<typename s<T>::template s2>();

IS4
  • 11,945
  • 2
  • 47
  • 86
  • I read the linked answer, but it didn't talk about template arguments and wasn't helpful in this case. – IS4 Apr 07 '19 at 11:35

1 Answers1

1

The typename disambiguator cannot be used for a template because it indicates a concrete type. It is possible to use the template disambiguator but without typename, because then it doesn't need the argument list:

func<s<T>::template s2>();
IS4
  • 11,945
  • 2
  • 47
  • 86