Skip to content

<mdspan>: Improve debug checks - #3821

Merged
Stephan T. Lavavej (StephanTLavavej) merged 29 commits into
microsoft:feature/mdspan2from
JMazurkiewicz:mdspan/debug-guards
Jul 3, 2023
Merged

<mdspan>: Improve debug checks#3821
Stephan T. Lavavej (StephanTLavavej) merged 29 commits into
microsoft:feature/mdspan2from
JMazurkiewicz:mdspan/debug-guards

Conversation

@JMazurkiewicz

@JMazurkiewicz Jakub Mazurkiewicz (JMazurkiewicz) commented Jun 22, 2023

Copy link
Copy Markdown
Contributor
  • Guard all existing debug checks with #if _CONTAINER_DEBUG_LEVEL > 0 (addresses <mdspan>: Completely rework std::extents #3586 (comment)),
  • extents:
    • Make _Static_extents array public and use it when possible,
    • Add new _Multidim_index_space_size_is_always_zero static member variable,
    • Split _Is_index_space_size_representable into two functions: _Is_static_multidim_index_space_size_representable and _Is_dynamic_multidim_index_space_size_representable,
    • Report DevCom-10398426 and silence it,
    • Improve debug check in extents(_OtherIndexTypes... _Exts) constructor,
  • layout_(left|right|stride)
    • Implement missing debug checks,
    • Replace scary looking immediately invoked lambda expressions with simple for loops (layout_(left|right)'s constructors from layout_stride),
    • Move precondition checks from operator() to corresponding _Index_impl functions (to avoid casting _Indices to index_type twice),
    • Drive-by: Remove unnecessary [[maybe_unused]] attributes in tests,
    • Drive-by: Simplify calls to check_members_with_various_extents in tests,
    • Drive-by: use ranges::adjacent_find instead of views::pairwise_transform in get_mapping_properties function,
    • Drive-by: fix exhaustiveness check in get_mapping_properties - previously, non-unique exhaustive mappings were recognized as non-exhaustive,
  • mdspan:
    • Implement missing debug checks,
    • Manually inline call to extents_type::static_extent in mdspan::static_extent and add precondition check,
    • Drive-by: improve performance of mdspan::empty,
    • Implement new death tests.

@JMazurkiewicz

This comment was marked as resolved.

Drive-by:
* Remove unnecessary `[[maybe_unused]]` attributes
* Simplify calls to `check_members_with_various_extents`
@JMazurkiewicz

This comment was marked as resolved.

Comment thread stl/inc/mdspan
Comment thread tests/std/tests/P0009R18_mdspan_extents_death/test.cpp
Comment thread tests/std/tests/P0009R18_mdspan_layout_stride_death/test.cpp
constexpr array<int, 256> some_ints{};

void test_construction_from_other_mdspan() {
auto mds1 = mdspan{some_ints.data(), 8, 2, 8};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an occurrence of "almost always auto" which we conventionally avoid. mdspan mds1{some_ints.data(), 8, 2, 8}; is the preferred form.

Occurs below.

@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit 1984147 into microsoft:feature/mdspan2 Jul 3, 2023
@StephanTLavavej

Copy link
Copy Markdown
Member

Thank you! I have minor comments for followup but nothing that prevented a merge.

@JMazurkiewicz
Jakub Mazurkiewicz (JMazurkiewicz) deleted the mdspan/debug-guards branch July 3, 2023 22:15
Jakub Mazurkiewicz (JMazurkiewicz) added a commit to JMazurkiewicz/STL that referenced this pull request Jul 5, 2023
Jakub Mazurkiewicz (JMazurkiewicz) added a commit to JMazurkiewicz/STL that referenced this pull request Jul 5, 2023
Jakub Mazurkiewicz (JMazurkiewicz) added a commit to JMazurkiewicz/STL that referenced this pull request Jul 5, 2023
Jakub Mazurkiewicz (JMazurkiewicz) added a commit to JMazurkiewicz/STL that referenced this pull request Jul 7, 2023
Jakub Mazurkiewicz (JMazurkiewicz) added a commit to JMazurkiewicz/STL that referenced this pull request Jul 7, 2023
Jakub Mazurkiewicz (JMazurkiewicz) added a commit to JMazurkiewicz/STL that referenced this pull request Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mdspan C++23 mdspan

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants