Let's say I have a class "Vector" (Math not Container) and I'd like to overload the operators, so I can chain calculations.
That works fine for me:
friend Vector operator+(const Vector<N, Type>& a, const Vector<N, Type>& b)
friend Vector operator+( Vector<N, Type>& a, const Vector<N, Type>& b)
and with that I can do stuff like
auto a = vec<3>(.0f, .0f, .0f);
auto b = a + a + a;
However I also implemented an initializer list
Vector& operator=(Type const (&arr)[N])
Which makes it possible for me to write something like this:
a = { .1f, .1f, .1f };
a += { .1f, .1f, .1f };
However what I can't do is chain those initializer lists.
a = { .1f, .1f, .1f } + b;
a = { .1f, .1f, .1f } + { .1f, .1f, .1f };
I already tried adding operator overloads like
friend Vector operator+(const Vector<N, Type>& a, Type const (&arr)[N])
friend Vector operator+( Vector<N, Type>& a, Type const (&arr)[N])
friend Vector operator+(Type const (&arr)[N], const Vector<N, Type>& a)
friend Vector operator+(Type const (&arr)[N], Vector<N, Type>& a)
but it doesn't work...
Is this possible?
Aucun commentaire:
Enregistrer un commentaire