Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<mdspan>: Final cleanups #3852

Merged
merged 21 commits into from
Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f58adf8
`extents`: Make special constructors private
JMazurkiewicz Jul 5, 2023
a0272c1
Use `_STL_INTERNAL_STATIC_ASSERT` in `_*_prod_of_extents` instead of …
JMazurkiewicz Jul 5, 2023
46b7a2b
Strengthen `layout_left(layout_stride)` constructor
JMazurkiewicz Jul 5, 2023
42e6f21
Strengthen `mdspan()` constructor
JMazurkiewicz Jul 5, 2023
a2154e5
Strengthen `mdspan(data_handle, extents...)` constructor
JMazurkiewicz Jul 5, 2023
18e1fad
Strengthen `mdspan(data_handle, array/span)` constructor
JMazurkiewicz Jul 5, 2023
6535652
Strengthen `mdspan(data_handle, const extents_type&)` constructor
JMazurkiewicz Jul 5, 2023
f789947
Strengthen `mdspan(data_handle, const mapping_type&)` constructor
JMazurkiewicz Jul 5, 2023
bd8c60a
Strengthen `mdspan(data_handle, const mapping_type&, const accessor_t…
JMazurkiewicz Jul 5, 2023
a6991f4
Strengthen `mdspan(const other-mdspan&)` constructor
JMazurkiewicz Jul 5, 2023
ce4d983
Strengthen `mdspan::operator[indices...]`
JMazurkiewicz Jul 5, 2023
d3c4e46
Grammar: `as value` -> `as a value`
JMazurkiewicz Jul 5, 2023
27e8937
Use "This test assumes that it isn't being compiled with /J"
JMazurkiewicz Jul 5, 2023
82116f9
`layout_right` -> `layout_stride`
JMazurkiewicz Jul 5, 2023
7fcd00a
`auto` -> `mdspan`
JMazurkiewicz Jul 5, 2023
c1d6b4d
Simplify `extents::_Make_dynamic_indices_inv`
JMazurkiewicz Jul 5, 2023
4475d23
Fix `noexcept` specifier of `mdspan::_Access_impl`
JMazurkiewicz Jul 7, 2023
162e73b
Make `check_members_with_various_extents` less heavy
JMazurkiewicz Jul 7, 2023
16c8c74
Copy-paste: `noop_dtor` -> `empty_bases`
JMazurkiewicz Jul 7, 2023
ccf0413
Typo: `default_accesor` -> `default_accessor` + grammar fix
JMazurkiewicz Jul 7, 2023
a8ce9be
Use `_Analysis_assume_`.
StephanTLavavej Jul 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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