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;
This is type traits for scalar and vector, the only difference is that the scalar type, for a vector, is the type of its element. Works fine.
But I'd really like to be able to use the same name for those two classes.
template<typename T>
struct numeric_type_traits_c
{
typedef T type_t;
typedef ????? scalar_t;
};
I know this is possible to do so if the class is explicitly specialized for each type I need: int, float, vec3, vec3...
That's a lot of duplication... How can I keep the simplicity of the first bit of code but have the same class name at the same time?