• Create Account

### #ActualMatt-D

Posted 27 July 2012 - 03:03 PM

Actually the initializer list solves the whole problem very well. But just one more question.
How do I make a constructor that could build the matrix using syntax like that (assuming that one can write here any number of rows):

M={
{1,2,3} //row 1
{4,5,6} //row 2
{7,8,9} //row 3
};

That is a problem because matrix defined in such manner can have any number of arguments (rows). How do I make that working? Should I use a variadic template?

Unfortunately, this is not as clean:
https://groups.googl...1d7802958427622

However, you may consider supplying the arguments similarly to what you had in mind in your operator, solution:
M={
1,2,3, //row 1
4,5,6, //row 2
7,8,9 //row 3
};

### #2Matt-D

Posted 27 July 2012 - 03:02 PM

Actually the initializer list solves the whole problem very well. But just one more question.
How do I make a constructor that could build the matrix using syntax like that (assuming that one can write here any number of rows):

M={
{1,2,3} //row 1
{4,5,6} //row 2
{7,8,9} //row 3
};

That is a problem because matrix defined in such manner can have any number of arguments (rows). How do I make that working? Should I use a variadic template?

Unfortunately, this is not as clean:
https://groups.googl...1d7802958427622

However, you can consider supplying the arguments similarly to what you had in mind in your operator, solution:
M={
1,2,3, //row 1
4,5,6, //row 2
7,8,9 //row 3
};

### #1Matt-D

Posted 27 July 2012 - 03:01 PM

Actually the initializer list solves the whole problem very well. But just one more question.
How do I make a constructor that could build the matrix using syntax like that (assuming that one can write here any number of rows):

M={
{1,2,3} //row 1
{4,5,6} //row 2
{7,8,9} //row 3
};

That is a problem because matrix defined in such manner can have any number of arguments (rows). How do I make that working? Should I use a variadic template?