Header c_array_support.hpp
Header c_array_compare.hpp
Header c_array_assign.hpp
Depends on std <type_traits> header.
-
lml::c_array<T>matches C array (and references to array) -
lml::c_array_unpadded<T>matches C arrays with no padding (and refs)
The c_array concepts also match references to C array,
useful in practice as arrays are passed by reference.
Padding in nested array types is possible but rare.
Unpadded nested arrays can be safely reinterpret cast to a flat array.
-
lml::c_array_t<T,N...>maps variadic Args to array type ->T[N][...] -
lml::all_extents_removed_t<A>remove_all_extents, under any reference qualification -
lml::flat_cast_t<A>maps possibly nested arrayAto flattened array typeE.g.
lml::flat_cast_t<T[M][N][...]>->T[M*N*...]
-
flat_size<A>yields the total number of elements in arrayA
(the product of extents of all ranks ofA). -
same_extents<A,B>predicate to tell ifAandBhave the same extents;
either both array types with the same extents or both rank 0 (non-array) types.
auto&& flat_index(c_array auto&& a, std::size_t i = 0)auto&& subscript(c_array auto&& a, std::size_t i = 0)
flat_index(arg,i)returns a[i];
the element at index i of the flattened array.
subscript(a,i) returns a[i], an rvalue if the argument is an array rvalue.
A workaround for MSVC subscript-expression-with-an-rvalue-array-is-an-xvalue
C-array supporting comparison concepts, aliases and functors, mostly replacing std lib features, plus some detection traits.
Depends only on std <compare> for three-way operator <=> support.
- Concepts:
lml::three_way_comparable [_with] c.f. std::three_way_comparable
lml::equality_comparable [_with] c.f. std::equality_comparable
lml::totally_ordered [_with] c.f. std::totally_ordered
lml::pointer_equality_comparable_with (no std equivalent)
lml::pointer_less_than_comparable_with (no std equivalent)- Aliases:
lml::compare_three_way_result_t c.f. std::compare_three_way_result_t- Functors:
lml::compare_three_way c.f. std::compare_three_way
lml::equal_to c.f. std::ranges::equal_to
lml::not_equal_to c.f. std::ranges::not_equal_to
lml::less c.f. std::ranges::lessIf you want greater, greater_equal or less_equal
then cut n paste with:
greater(a,b) == less(b,a)
greater_equal(a,b) == ! less(a,b)
less_equal(a,b) == ! less(b,a)Depends on std <concepts>
-
lml::assignable_from<L,R>=std::assignable_from<eL,eR> && same_extents<L,R> -
lml::empty_list_initializable(no std equivalent) -
lml::empty_list_assignable(no std equivalent)
-
lml::is_assignable_v = std::is_assignable_v
-
lml::is_copy_assignable_v = std::is_copy_assignable_v
-
lml::is_move_assignable_v = std::is_move_assignable_v
... plus all trivially and nothrow variants ...
lml::assign(no std equivalent)