wrote:
> Not 100% sure what you are trying to do but here is what one possible
> solution would look like based on the information you have provided.
>
> template<class T, size_t numDim>
> class VecBasis
> {
> };
>
> typedef VecBasis<float, 3> vec3;
>
> template<class T, size_t size>
> class MatBasis
> {
> template<class V >
> V column(size_t c) const;
> };
>
> template<class T>
> class MatBasis<T, 3>
> {
> public:
> template<class V >
> V column() const;
> };
>
> template<>
> class MatBasis<float, 3>
> {
> public:
> template<class V >
> V column() const;
> };
>
>
> template<>
> inline vec3 MatBasis<float, 3>::column<vec3>() const
> {
> static vec3 v;
> return v;
> }
Oh ****, I made a mistake when I tried to simply my code. In reality,
I'm not using "typedef VecBasis<float, 3> vec3;". __vec3 is another
class__.
Sorry guys :/. change "typedef VecBasis<float, 3> vec3;" by "class
vec3 {};".
Amparikh, your solution uses a class template specialization for
which I'm forced to do inheritance because the specialized class is
exactly the same as the non-specialized one except to the column
member. It doesn't seem to be a nice approach.
What I want to do is make a member (the column) that uses VecBasis<>
as its template parameter by default and, when its class's second
template parameter is 3, that member uses the vec3 type as its template
parameter. As follows:
MatBasis<float, 2> mat0;
mat0.column(0); // returns a VecBasis<float, 2>
MatBasis<float, 3> mat1;
mat1.column(0); // returns a vec3
Thanks