rleigh-electradx 25e2d6e8a3
Adopt the Library Fundamentals TS make_array design for the sequence factories (#1553)
* Adopt the Library Fundamentals TS make_array design for the sequence factories

make_array, make_deque, make_vector, make_list, make_forward_list and
make_indirect_vector now follow the Library Fundamentals TS
std::experimental::make_array design: a defaulted leading template
parameter selects the element type explicitly, falling back to the
decayed common type of the arguments when it is not supplied. A shared
trait (etl::private_make::element_type) performs the selection lazily,
so common_type is not instantiated when the element type is explicit.

This fixes the explicit-element-type calling style for the four
common-type factories, where make_vector<char>(lvalue) never compiled:
the explicit argument pinned the first pack parameter to char, making
it a char&& that no lvalue can bind to. It also gives make_array and
make_deque the deduced form (e.g. make_array(1, 2L) is array<long, 2>)
for free. All arguments are converted with static_cast, as in the
make_array const-lvalue fix, so const-qualified lvalues and narrowing
initialisers work in both forms.

Intentional behaviour change: an explicit element type now converts
every argument instead of pinning only the first. make_vector<char>(0,
1, ...) previously produced vector<int> - the explicit char affected
only the first argument and the element type was still the common type
- and now produces vector<char>. test_make_vector documented the old
behaviour and has been updated.

The keyed set and map factories are unchanged: their key/mapped types
are separate mandatory template parameters ahead of a fully-deduced
pack, so the explicit-type style already works, and retrofitting
deduction there would interact with the defaulted comparator/hash
parameters.

Adds explicit-element-type tests for the four common-type factories
(const/non-const lvalues plus narrowing initialisers) and
deduced-element-type tests for make_array and make_deque, and updates
the four documented signatures.

* Address review comments on the make_xxx factory design

- Forward same-type arguments in the make_xxx factories instead of
  casting them. static_cast produced a prvalue that, before C++17, had
  to be materialised through the move constructor, rejecting
  copyable-but-non-movable element types. The new
  private_make::convert helper forwards arguments that already have
  the element type and static_casts the rest.
- Drop ETL_NOEXCEPT from make_array: conversions can throw, and the
  other factories do not declare it.
- Remove the redundant etl::decay in element_type<void, ...>;
  etl::common_type already decays its arguments.
- Stop leaking the etl::private_make implementation namespace into the
  documented factory signatures.

* Add a test for make_array with an explicit element type and no arguments

etl::make_array<int>() produces an empty etl::array<int, 0> and now has
a regression test. A call with neither an element type nor arguments
remains ill-formed, matching the Library Fundamentals TS: there is
nothing to deduce the element type from. The array documentation now
states this explicitly.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
2026-08-24 08:53:25 +01:00
..
_index.md Issue/add hugo support for documentation (#1449) 2026-06-06 13:12:44 +01:00
indirect-vector.md Adopt the Library Fundamentals TS make_array design for the sequence factories (#1553) 2026-08-24 08:53:25 +01:00
multi-vector.md Issue/add hugo support for documentation (#1449) 2026-06-06 13:12:44 +01:00
vector.md Adopt the Library Fundamentals TS make_array design for the sequence factories (#1553) 2026-08-24 08:53:25 +01:00