c++ - preserving alias template instantiation info -
i trying write c++11 library on gcc vector extensions, clang tries compatible with. started traits vector types:
template <typename t, unsigned n> struct vector_traits; template <> struct vector_traits<float, 3> { static constexpr auto size = 3; using value_type = float; using vector_type = value_type __attribute__((vector_size(16))); }; template <> struct vector_traits<float, 4> { static constexpr auto size = 4; using value_type = float; using vector_type = value_type __attribute__((vector_size(16))); }; note, how 2 trait specializations same. thought:
template <typename t, unsigned n> using vector = typename vector_traits<t, n>::vector_type; but alias templates can't deduced. so, can't deduce whether i've instantiated vector n=3 or 4. ways exist preserve information, without introducing wrapper class/struct? say
template <typename t, unsigned n> struct vector<t, n> { typename vector_traits<t, n>::vector_type data_; };
Comments
Post a Comment