mercredi 4 octobre 2017

Defining a static data member of a templated class within a templated class

I have a class template inside of another class template. The inner class has a static data member. I am struggling to provide a definition for it. The below example works in clang 3.8 but not in gcc-7.1

template <typename T>
struct Out {
  template <typename U>
  struct In {
    static int var;
  };
};

template <typename T>
template <typename U>
int Out<T>::template In<U>::var;

gcc gives the error:

error: template definition of non-template ‘int Out<T>::In<U>::var’
 int Out<T>::template In<U>::var;
                             ^~~

What do I gotta do to make gcc happy?

Aucun commentaire:

Enregistrer un commentaire