* 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>
* Fixed make_array rejecting const-qualified lvalues of the element type
make_array forwarded each argument as T (the element type) rather than
as its own deduced type. etl::forward<T> accepts only a non-const T& or
a T&&, and a T&& cannot bind to a reference-related const lvalue, so
any call passing a const-qualified lvalue of type T failed to compile:
static const char c = 42;
etl::make_array<char>(c, c); // error: would lose const qualifier
Arguments of *other* types slipped through via temporary
materialisation, which is why the existing conversion and move tests
never caught it.
Forward each argument as its own deduced type and convert explicitly
with static_cast<T>. The explicit conversion is required rather than
plain forwarding: function parameters are not constant expressions, so
narrowing initialisers such as make_array<char>(0, 1) - which the old
code accepted and the tests cover - would otherwise be rejected by the
braced initialiser list.
Adds regression tests for const/non-const lvalues of the element type
and for constexpr evaluation. Verified with clang 22 (C++14/17/20) and
GCC 14 (C++11/20); existing conversion and move-only patterns still
compile.
* Fixed make_deque rejecting const-qualified lvalues of the element type
make_deque had the same defect fixed for make_array in the previous
commit: it forwarded each argument as T (the element type) rather than
as its own deduced type. etl::forward<T> accepts only a non-const T& or
a T&&, and a T&& cannot bind to a reference-related const lvalue, so
any call passing a const-qualified lvalue of type T failed to compile:
static const char c = 42;
etl::make_deque<char>(c, c); // error: would lose const qualifier
An audit of all other make_xxx container factories found no further
instances - they forward each argument as its own deduced pack type,
which is the correct idiom.
Forward each argument as its own deduced type and convert explicitly
with static_cast<T>. The explicit conversion keeps narrowing
initialisers such as make_deque<char>(0, 1) - which the old code
accepted and test_make_deque covers - working, which plain forwarding
into the braced initialiser list would reject.
Adds a regression test for const/non-const lvalues of the element type.
No constexpr test, unlike make_array: etl::deque is not a literal type,
so make_deque cannot be evaluated at compile time. Verified with
clang 22 (C++14/17/20); the new test fails to compile before the fix
and passes after, and all 101 deque tests pass.
* Added narrowing-conversion regression tests for make_array and make_deque
Review feedback on the make_deque fix: the const-lvalue regression test
only passes arguments that already have the element type, so nothing
exercises the static_cast<T> conversion that keeps narrowing
initialisers working. If the implementation regressed to plain
forwarding into the braced initialiser list, narrowing calls such as
make_deque<char>(0, 1) would fail to compile.
make_array already covered narrowing from int literals via
test_make_array, but neither container covered conversion from
const-qualified lvalues of a different type (const int narrowed to
char), which combines both dimensions of the fix.
Adds a matching test to each container covering int literals plus
const/non-const int lvalues, all narrowed to char. Verified with
clang 22 (C++17): 102 deque and 53 array tests pass.
* Added const-lvalue regression tests for the remaining make_xxx factories
Review feedback on the make_array/make_deque fixes asked whether the
same defect - rejecting const-qualified lvalue arguments by forwarding
each argument as the element type rather than as its own deduced type -
exists in the other make_xxx container factories. The audit found that
it does not: the other factories forward each argument as its own
deduced pack type. These tests pin that down explicitly for every
remaining factory, mirroring the make_array and make_deque regression
tests:
- make_vector, make_forward_list, make_indirect_vector (element type
deduced via common_type): const/non-const char lvalues, element type
checked.
- make_set, make_multiset, make_flat_set, make_flat_multiset,
make_unordered_set, make_unordered_multiset: const/non-const lvalues
of the key type.
- make_map, make_multimap, make_flat_map, make_flat_multimap,
make_unordered_map, make_unordered_multimap: const/non-const lvalues
of the pair type.
make_reference_flat_* are excluded: they cannot currently be
instantiated at all (no initializer_list constructor exists in the
reference containers), which is reported separately.
Verified with clang 22 (C++17): all 15 test suites pass (996 tests).
* Added make_forward_list parity tests matching the make_list fixes
Checked whether the make_list defect - taking its argument pack by
value, costing an extra move per lvalue argument - also applies to
make_forward_list. It does not: make_forward_list already takes its
pack by forwarding reference, as make_vector does. No header change is
needed.
Adds the two tests that accompanied the make_list fix so that
forward_list has the same coverage and the same regression detector:
- test_make_forward_list_common_type_from_mixed_types, confirming the
element type deduction through common_type.
- test_make_forward_list_argument_copy_and_move_counts, an
instrumented type counting copy/move constructions. This is the test
that fails if the pack ever regresses to by-value (one extra move
per lvalue argument). The exact move counts are C++17-only, as
before C++17 the non-guaranteed return elision may add a move per
element.
Verified with clang 22 (C++17): all 67 forward_list tests pass.
---------
Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
* Print test names at test time (#1343)
* Suppress false positive compiler warnings when compiling with -O3
The CI checks currently only check everything with -O0. Wenn activating
higher optimization levels, more warnings kick in. Leading to errors,
depending on the configuration.
---------
Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
* Fix compilation with -Wsign-conversion
For tests with GCC and Clang
Fixes https://github.com/ETLCPP/etl/issues/632
* Fix support of negative Id in type_lookup.h: type_from_id
* Fix element access arithmetic in atomic_gcc_sync.h fetch_add/fetch_sub
* Fix rounded_integral_division.h: divide_round_half_odd(): direction is always 1
* add bounds and empty checks to containers
* address code rabbit review
* correct C++11 constexpr error
* rename new constexpr macro and make it global
* rename queue specializations' exceptions
* change front() implementation in locked queue specializations
* refactor usage of CONSTEXPR and NO_EXCEPT
* expand intrusive queue tests
* introduce lock guards on locked queues
* Print test names at test time (#1343)
* revert mutex and return changes on locking queues
* finish reverting the locked queues
---------
Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Updated CI scripts
#786 u8string
#783 Cannot insert existing value to full set
#781 etl::multi_span::iterator::operator *() fails if first span is empty
#780 endian enum_type produces useless-cast warnings
#779 hash.h: warnings produced with -Wfloat-equal
C++14 compiler compatibility
Updated test run scripts
Changed some ETL_ASSERT macros to ETL_ASSERT_OR_RETURN
Changed unit test macros for C++20 compaibility
Updated test run scripts
Updated CMake files to allow C++ standard selection
Replaced ETL_ASSERT_AND_RETURN with ETL_ASSERT_OR_RETURN
Updated C++14 & C++20 unit test compatibility
Changed native char8_t check
Added optional optimisation argument to bash script
void assign(const_pointer, size_t) did not set the truncation flag.
Fixed resize(0) error for etl::fixed_list
Removed erroneous pointers in etl::unordered_map::begin()