I am writing a generic vector base class. The class implements all of the operator overloads so I don't have to implement them over and over and over for each type of vector class.

class VectorBase(size_t S, T) {
        T[S] data;

        ...
}

class Vector3f : VectorBase!(3, float) { ... }

The problem I am having is implementing operations that can take a matching vector. I can't figure out the proper way of declaring the type of input.

eg.

void opAssign(VectorBase!(S, T) r);
> function VectorBase!(3LU,float).VectorBase.opAssign identity assignment operator overload is illegal


void opAssign(this r);
> basic type expected, not this


The only way I can think of handling it is to add another parameter to the template declaration, eg:

class VectorBase(size_t S, T, N) { ... }
class Vector3f : VectorBase!(3, float, Vector3f) { ... }

But I would like to avoid that if possible.

Any hints on how to implement this so I can keep my original declaration? class VectorBase(size_t S, T)

Reply via email to