Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

template error: nontype ".. [with T=T] is not a type name"

Trying to typedef my memory alignment I came out with the following construct (which still is a bit of work in progress because I need to correct the GNU version):

#if defined(__GNUG__)
template <typename T>
struct sfo_type {
    typedef T* restrict __attribute__((aligned(32))) aptr32;
};

#elif defined(__INTEL_COMPILER)
template <typename T>
struct sfo_type {
    typedef T* restrict __attribute__((aligned(32))) aptr32;
};
#endif  

and then I try to use it like this:

template<typename T>
class tsfo_vector {
private:
   sfo_type<T>::aptr32  m_data;
   int                  m_size;
...

but then I get the following error message:

/Users/bravegag/code/fastcode_project/code/src/sfo_vector.h(43): error: nontype "sfo_type<T>::aptr32 [with T=T]" is not a type name
 sfo_type<T>::aptr32 m_data;
 ^

Can anyone advice what's wrong here?

like image 223
SkyWalker Avatar asked Aug 15 '12 12:08

SkyWalker


1 Answers

aptr32 is dependent on T so:

template<typename T>
    class tsfo_vector {
    private:
        typename sfo_type<T>::aptr32 m_data;
      //^^^^^^^^

For further explanation on the use of typename see Where and why do I have to put the "template" and "typename" keywords?

like image 164
hmjd Avatar answered Oct 20 '22 00:10

hmjd