PR 574: use variadic template instead of initializer_list to implement fixed-size vector ctor from coefficients.

This commit is contained in:
David Tellenbach
2019-01-23 00:07:19 +01:00
parent bd6dadcda8
commit 237b03b372
8 changed files with 55 additions and 48 deletions

View File

@@ -109,11 +109,11 @@ Vector3d b(5.0, 6.0, 7.0);
Vector4d c(5.0, 6.0, 7.0, 8.0);
\endcode
If C++11 is enabled, fixed-size column or row vectors of arbitrary size can be initialized through a single initializer list (\link Matrix::Matrix(const std::initializer_list<Scalar>&) details \endlink):
If C++11 is enabled, fixed-size column or row vectors of arbitrary size can be initialized by passing an arbitrary number of coefficients:
\code
Vector2i a {1, 2}; // A column vector containing the elements {1, 2}
Vector2i a(1, 2); // A column vector containing the elements {1, 2}
Matrix<int, 5, 1> b {1, 2, 3, 4, 5}; // A row-vector containing the elements {1, 2, 3, 4, 5}
Matrix<int, 1, 5> c {1, 2, 3, 4, 5}; // A column vector containing the elements {1, 2, 3, 4, 5}
Matrix<int, 1, 5> c = {1, 2, 3, 4, 5}; // A column vector containing the elements {1, 2, 3, 4, 5}
\endcode
In the general case of matrices and vectors with either fixed or runtime sizes,

View File

@@ -1,3 +0,0 @@
Array<int, 1, 6> a {1, 2, 3, 4, 5, 6};
Array<int, 3, 1> b {1, 2, 3};
cout << a << "\n\n" << b << endl;

View File

@@ -0,0 +1,3 @@
Array<int, 1, 6> a(1, 2, 3, 4, 5, 6);
Array<int, 3, 1> b {1, 2, 3};
cout << a << "\n\n" << b << endl;

View File

@@ -1,3 +0,0 @@
Matrix<int, 1, 6> a {1, 2, 3, 4, 5, 6};
Matrix<int, 3, 1> b {1, 2, 3};
cout << a << "\n\n" << b << endl;

View File

@@ -0,0 +1,3 @@
Matrix<int, 1, 6> a(1, 2, 3, 4, 5, 6);
Matrix<int, 3, 1> b {1, 2, 3};
cout << a << "\n\n" << b << endl;