Skip to content

Commit

Permalink
<mdspan>: Final cleanups (#3852)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
  • Loading branch information
JMazurkiewicz and StephanTLavavej authored Jul 8, 2023
1 parent 7943441 commit 2c495f5
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 216 deletions.
258 changes: 142 additions & 116 deletions stl/inc/mdspan

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/std/include/test_mdspan_support.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ constexpr void check_members_with_various_extents(Fn&& fn) {
details::check_members_with_various_extents_impl(std::forward<Fn>(fn), std::make_index_sequence<2>{});
details::check_members_with_various_extents_impl(std::forward<Fn>(fn), std::make_index_sequence<4>{});
details::check_members_with_various_extents_impl(std::forward<Fn>(fn), std::make_index_sequence<8>{});
#ifndef _PREFAST_
details::check_members_with_various_extents_impl(std::forward<Fn>(fn), std::make_index_sequence<16>{});
#endif // _PREFAST_
if (!std::is_constant_evaluated()) {
details::check_members_with_various_extents_impl(std::forward<Fn>(fn), std::make_index_sequence<16>{});
}
}

namespace details {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@

#if empty_bases != 6
#error bad macro expansion
#endif // noop_dtor != 6
#endif // empty_bases != 6
2 changes: 1 addition & 1 deletion tests/std/tests/P0009R18_mdspan_extents_death/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void test_construction_from_pack_with_unrepresentable_as_index_type_values_2() {
}

void test_construction_from_pack_with_unrepresentable_as_index_type_values_3() {
static_assert(signed_integral<char>, "char is not signed integral");
static_assert(signed_integral<char>, "This test assumes that it isn't being compiled with /J");
// Either sizeof...(exts) must be equal to 0 or each element of exts must be nonnegative and must be representable
// as value of type index_type
[[maybe_unused]] extents<signed char, 1, dynamic_extent> e{static_cast<char>(-1)};
Expand Down
29 changes: 8 additions & 21 deletions tests/std/tests/P0009R18_mdspan_layout_left/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ constexpr void check_members(const extents<IndexType, Extents...>& ext, index_se
// Other tests are defined in 'check_construction_from_other_right_mapping' function
}

#ifdef __clang__
if (!is_constant_evaluated()) // FIXME clang hits constexpr limit here
#endif
{ // Check construction from layout_stride::mapping
array<IndexType, Ext::rank()> strides{};
if constexpr (Ext::rank() > 0) {
Expand Down Expand Up @@ -261,14 +258,14 @@ constexpr void check_construction_from_other_right_mapping() {

constexpr void check_construction_from_other_stride_mapping() {
{ // Check construction from layout_stride::mapping<E> with various values of E::rank()
static_assert(
is_constructible_v<layout_left::mapping<dextents<int, 0>>, layout_stride::mapping<dextents<int, 0>>>);
static_assert(
is_constructible_v<layout_left::mapping<dextents<int, 1>>, layout_stride::mapping<dextents<int, 1>>>);
static_assert(
is_constructible_v<layout_left::mapping<dextents<int, 2>>, layout_stride::mapping<dextents<int, 2>>>);
static_assert(
is_constructible_v<layout_left::mapping<dextents<int, 3>>, layout_stride::mapping<dextents<int, 3>>>);
static_assert(is_nothrow_constructible_v<layout_left::mapping<dextents<int, 0>>,
layout_stride::mapping<dextents<int, 0>>>); // strengthened
static_assert(is_nothrow_constructible_v<layout_left::mapping<dextents<int, 1>>,
layout_stride::mapping<dextents<int, 1>>>); // strengthened
static_assert(is_nothrow_constructible_v<layout_left::mapping<dextents<int, 2>>,
layout_stride::mapping<dextents<int, 2>>>); // strengthened
static_assert(is_nothrow_constructible_v<layout_left::mapping<dextents<int, 3>>,
layout_stride::mapping<dextents<int, 3>>>); // strengthened
}

{ // Check construction from layout_stride::mapping<E> when E is invalid
Expand Down Expand Up @@ -423,10 +420,6 @@ constexpr void check_correctness() {
#endif // ^^^ !defined(__cpp_multidimensional_subscript) ^^^
}


#ifdef __clang__
if (!is_constant_evaluated()) // FIXME clang hits constexpr limit here
#endif
{ // 3x2 matrix with column-major order
const array values{0, 1, 2, 3, 4, 5};
mdspan<const int, extents<int, 3, 2>, layout_left> matrix{values.data()};
Expand All @@ -448,9 +441,6 @@ constexpr void check_correctness() {
#endif // ^^^ !defined(__cpp_multidimensional_subscript) ^^^
}

#ifdef __clang__
if (!is_constant_evaluated()) // FIXME clang hits constexpr limit here
#endif
{ // 3x2x4 tensor
const array values{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23};
mdspan<const int, dextents<size_t, 3>, layout_left> tensor{values.data(), 3, 2, 4};
Expand All @@ -472,9 +462,6 @@ constexpr void check_correctness() {
#endif // ^^^ !defined(__cpp_multidimensional_subscript) ^^^
}

#ifdef __clang__
if (!is_constant_evaluated()) // FIXME clang hits constexpr limit here
#endif
{ // 2x3x2x3 tensor
const array values{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35};
Expand Down
6 changes: 0 additions & 6 deletions tests/std/tests/P0009R18_mdspan_layout_right/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ constexpr void check_members(const extents<IndexType, Extents...>& ext, index_se
static_assert(same_as<typename Mapping::rank_type, typename Ext::rank_type>);
static_assert(same_as<typename Mapping::layout_type, layout_right>);

#ifdef __clang__
if (!is_constant_evaluated()) // FIXME clang hits constexpr limit here
#endif
{ // Check default and copy constructor
const Mapping m;
Mapping cpy = m;
Expand Down Expand Up @@ -63,9 +60,6 @@ constexpr void check_members(const extents<IndexType, Extents...>& ext, index_se
using Ext2 = extents<OtherIndexType, Extents...>;
using Mapping2 = layout_right::mapping<Ext2>;

#ifdef __clang__
if (!is_constant_evaluated()) // FIXME clang hits constexpr limit here
#endif
{ // Check construction from other layout_right::mapping
Mapping m1{ext};
Mapping2 m2{m1};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using namespace std;

void test_default_construction() {
using Ext = extents<signed char, dynamic_extent, 4, 5, 7>;
// Value of layout_right::mapping<extents_type>().required_span_size() must be
// Value of layout_stride::mapping<extents_type>().required_span_size() must be
// representable as a value of type index_type
[[maybe_unused]] layout_stride::mapping<Ext> m{}; // NB: strides are [140, 35, 7, 1]
}
Expand Down
Loading

0 comments on commit 2c495f5

Please sign in to comment.