For an assignment, i have to code a matrix class following some clear instructions. One of the instructions is overloading the << operator , so that we can read the values this exact way for a matrix m :
m << 1,2,3,4,5,6;
i tried looking into functions with variable parameters , but then i saw that i can't overload the operator with a variable number of parameters.
i tried looking in std::initializer_list , using some reference code from cpp reference
std::vector<float> mat;
Mat<M,N>& operator<<(std::initializer_list<float> l)
{
this->mat.insert(this->mat.begin(),l.begin(),l.end());
return *this;
}
so my question is, what class/type of parameters can i use to achieve this, the options that i thought of did not work , or maybe i did not use them the right way.
thank you very much.
EDIT : After the great answer from @bames53 i tried to incorporate and it works just great !