I'm trying to write some stuff to wrap simd intrinsics, and I figured that it would be nice to do something like
using vec<float, 4> = __m128;
so that I could use templates in some code I write later on. This isn't really relevant to the question, but __m128 is a type that represents 4 floats. This doesn't work, and g++ says expected nested-name-specifier before 'vec'
. I know I can just write classes to wrap them, or I can do something like:
template <typename T, int N> struct vec;
template<> struct vec<float, 4>
{
typedef __m128 type;
};
and then I can use vec<float,4>::type
, but the first way is far more convenient. I think it might be possible using something like C++ template typedef, but I'm not sure, and I wouldn't know the syntax. Is there any way to make the first statement work or to do something similar?
Aucun commentaire:
Enregistrer un commentaire