kokkos / mdarray

Other
10 stars 9 forks source link

P1684: Consider not requiring default-constructible elements, because ranges::to construction should always work #20

Closed mhoemmen closed 2 years ago

mhoemmen commented 2 years ago

This comes from 1684R2 LEWG review on 2022/04/19.

One reviewer suggests: iota + cartesian_product should mean that we can construct a range over the input mdarray or mdspan, and thus should be able to use ranges::to construction. Thus, we shouldn't have to preallocate an empty container with default-constructed elements. This would remove the requirement that elements be default constructible.

However, see #13 (if we need to use a particular parallel ExecutionPolicy for iterating over elements, then the current ranges::to interface will not suffice).

The question is whether we should permit implementations to separate container allocation (with default construction of elements if they are not trivially default constructible) from copying elements into the container. This permission would let conforming implementations use a parallel algorithm to copy elements into the container, rather than (essentially) requiring ranges::to. In turn, this permission would make it possible to write mdarray in Standard C++ without requiring default constructibility of the elements. (Note that vector does not require default constructibility of its elements, unless you invoke one of the vector constructors that default-constructs elements.)

mhoemmen commented 2 years ago

Superseded by https://github.com/ORNL/cpp-proposals-pub/issues/263 . Proposal issues belong in that repository.