template<typename T>
class vec3
{
public:
typename T type_t;
T x;
T y;
T z;
};
template<typename T>
struct numeric_type_traits_basic_c
{
typedef T type_t;
typedef T scalar_t;
};
template<typename T>
struct numeric_type_traits_vec3_c
{
typedef T type_t;
typedef typename T::type_t scalar_t;
};
typedef numeric_type_traits_basic_c<int> int_type_traits;
typedef numeric_type_traits_vec3_c< vec3<int> > vec3_int_type_traits;
These are characteristic features for scalar and vector, the only difference is that the scalar type for a vector is the type of its element. It works great.
But I would really like to have the same name for these two classes.
template<typename T>
struct numeric_type_traits_c
{
typedef T type_t;
typedef ????? scalar_t;
};
I know that this is possible if the class is explicitly specialized for each type that I need: int, float, vec3, vec3 ...
This is a lot of duplication ... How can I keep the simplicity of the first bit of code, but at the same time have the same class name?
anon
source
share