I'm currently working on a templated mathematical vector class. While doing so I came across some irritating behavior.
My actual vector class is inheriting the components from another class via a template-parameter (because my components are a union of an array and individual variables (x, y, z)).
I wanted to access the value_type of the component class via a using-declaration. But this yields an error indicating, that the identifier is unknown. Is it illegal to access using-declarations of template parameters? And what would be a nice workaround?
Code example to clearify:
#include <iostream>
template<typename T, size_t N>
struct Components
{
public:
using value_type = T;
constexpr static size_t getDim() {return N;}
union
{
T arr[N];
};
};
template<class COMPONENTS>
struct Vector : public COMPONENTS
{
COMPONENTS::value_type mag()
{
return 22.f;
}
};
int main()
{
Vector<Components<float, 3>> vec;
vec.mag();
}
Thanks in advance, Luis Wirth.