Expose types used internally in SIMD classes as typedefs.
Issue #12
resolved
All vector classes should expose typedefed names for used types. This can be useful in user code. Consider this:
SIMD4_32u foo(SIMD4_32u & vec, uint32_t scal) {
...
vec.add(scal);
...
return vec;
}
This piece of code will be correct, but when user wants to use templates, he either has to pass scalar type as another template parameter.
template <typename VEC_TYPE, typename SCALAR_TYPE>
SIMD4_32u foo(VEC_TYPE & vec, SCALAR_TYPE scal) {
...
vec.add(scal);
...
return vec;
}
It would be nice to have syntax like this:
template <typename VEC_TYPE>
SIMD4_32u foo(VEC_TYPE & vec, typename VEC_TYPE::SCALAR_TYPE scal) {
...
vec.add(scal);
...
return vec;
}
This would reduce overall number of template arguments for multi-level template indirection. If not possible for template arguments, it would at least be possible to use VEC_TYPE::SCALAR_TYPE instead of decltype(vec[0]) for dependant type resolution.
Comments (2)
-
reporter -
reporter - changed status to resolved
- Log in to comment
It is now possible to use SIMDTraits<VEC_TYPE>:: to extract necessary dependant type. Using direct overloads would be unpractical, because it would require redundancy in the specialized classes.