Initializing vectors and matrices from scalars and ranges

Issue #271 new
Matthias Moulin created an issue

A bit orthogonal to Issues #253 and #270, it could also be possible to initialize vectors and matrices from pretty much everything (more concretely: scalars, and ranges which could be iterated) passed instead and getting rid off the constructors taking std::initializer_lists.

That way one can

  • initialize a 1x7 vector using 2x scalars, a 1x2 vector and a 1x3 vector passed in arbitrary order;
  • initialize a 1x7 vector using a 1x3 vector (padded with zeros);
  • initialize a 1x7 vector using a eastl::array, eastl::span, eastl::vector, std::array, std::span, std::vector, C style array (or any other custom contiguous sequence or view to that sequence) containing at most 7 elements.

Matrices can be constructed in a similar fashion by constructing the rows first using the above approach which seems the most logical imho (i.e. I see no use case for constructing a matrix from two or more smaller matrices).

So basically this requires adding a variadic argument constructor (which may not interfere with all the remaining constructors) to the vectors, which unpacks the given arguments to tuples and concatenates those tuples to a single tuple (technically an array but it will be easier using tuples as intermediates).

Comments (2)

  1. Klaus Iglberger

    Hi Matthias!

    Thanks for creating this issue. You are correct, this sounds like the most flexible way to initialize vectors and matrices. We will evaluate if and how this could be realized while preserving the existing interface and without too much compile time and runtime penalties. Thanks,

    Best regards,

    Klaus!

  2. Log in to comment