Would be nice if as many as possible of the following lines worked: Eigen::Array3d a = std::array<double, 3>{1, 2, 3}; Eigen::Vector3d v = std::array<double, 3>{1, 2, 3}; std::array<double, 3> A1 = Eigen::Array3d{1, 2, 3}; std::array<double, 3> A2 = Eigen::Vector3d{1, 2, 3}; and similarly for (1d) types with run time size and std::vector. I don't mean Eigen::Map but conversion.
And similarly for construction, not sure if constructing an std::array can/should be supported: Eigen::Array3d a{std::array<double, 3>{1, 2, 3}}; Eigen::Vector3d v{std::array<double, 3>{1, 2, 3}}; //std::array<double, 3> A1{Eigen::Array3d{1, 2, 3}}; //std::array<double, 3> A2{Eigen::Vector3d{1, 2, 3}};
That's worth considering. One possible drawback is that this might silently introduce overhead (in contrast to Map). Also, if we allow implicit conversions, it might hide programming errors. And we definitely can't support expressions such as (Array3d() + std::array<double,3>()). Overall, I'd be ok with allowing explicit conversions, but I'd consider the current conversion and Map possibilities good enough. If you have lots of these conversions, you may want to reconsider how you store data. If you are sure you need these conversions, you can also inherit from Vector3d and provide the corresponding constructors and cast operators. > [...] not sure if constructing an std::array can/should be supported: If we allowed automatic conversion to std::array (via implementing operator std::array<Scalar, SizeAtCompileTime>()), constructing a std::array would automatically be possible. This line is also tries to call a constructor of std::array: std::array<double,3> A1 = Array3d{1,2,3}; Also note that we haven't implemented initializer lists yet. So Array3d{1,2,3} only works because Array3d(double, double, double) is implemented.
I'm also rather reluctant in adding implicit conversion, but I would be ok with explicit ctor from std::array to Eigen::Array/Vector. We could also think about adding implicit conversion to Ref<>?
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/988.