[cfe-dev] type traits for vector types

Jochen Wilhelmy j.wilhelmy at arcor.de
Tue May 11 15:42:57 PDT 2010


Hi!

I'd like to find out info about vectors at compile time.

For example I have these vector traits:
template <typename T>
struct VectorTraits {
    enum {
        VECTOR = 0
    };
};

template <>
struct VectorTraits<float __attribute__((ext_vector_type(2)))> {
    enum {
        VECTOR = 2
    };
};

template <>
struct VectorTraits<float> {
    enum {
        VECTOR = 1
    };
};


This fails with the following error:
error: redefinition of
      'VectorTraits<float>'
 struct VectorTraits<float>
        ^~~~~~~~~~~~~~~~~~~

It seems clang can not specialize by vector type. But when I omit the 
vector specialization
the result for a vector type (i.e. VectorTraits<float2>::VECTOR) is 0.
The vector type does not count as its basic type at instantiation time.
Therefore this is a bug.

-Jochen




More information about the cfe-dev mailing list