-
Notifications
You must be signed in to change notification settings - Fork 69
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
Add constraint for layout_left|right|stride::stride()
, and add test
#238
Changes from all commits
b421aa5
1e81887
18f3e1e
087c14c
078e87d
45a00ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,18 +141,24 @@ void check_correctness(MDA& m, size_t rank, size_t rank_dynamic, | |
bool exhaustive) { | ||
ASSERT_EQ(m.rank(), rank); | ||
ASSERT_EQ(m.rank_dynamic(), rank_dynamic); | ||
if(rank>0) { | ||
ASSERT_EQ(m.extent(0), extent_0); | ||
ASSERT_EQ(m.stride(0), stride_0); | ||
} | ||
if(rank>1) { | ||
ASSERT_EQ(m.extent(1), extent_1); | ||
ASSERT_EQ(m.stride(1), stride_1); | ||
} | ||
if(rank>2) { | ||
ASSERT_EQ(m.extent(2), extent_2); | ||
ASSERT_EQ(m.stride(2), stride_2); | ||
#if MDSPAN_HAS_CXX_20 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't we just move that above 144. After all runtime wise these checks anyway only execute if rank>0 and we don't need to check that it compiles, there are other tests which do taht. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And I mean with that we only need one big constexpr if protection for all runtime check rank clauses. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. Updated. |
||
if constexpr (MDA::extents_type::rank()>0) { | ||
#endif | ||
if(rank>0) { | ||
ASSERT_EQ(m.extent(0), extent_0); | ||
ASSERT_EQ(m.stride(0), stride_0); | ||
} | ||
if(rank>1) { | ||
ASSERT_EQ(m.extent(1), extent_1); | ||
ASSERT_EQ(m.stride(1), stride_1); | ||
} | ||
if(rank>2) { | ||
ASSERT_EQ(m.extent(2), extent_2); | ||
ASSERT_EQ(m.stride(2), stride_2); | ||
} | ||
#if MDSPAN_HAS_CXX_20 | ||
} | ||
#endif | ||
if(ptr_matches) | ||
ASSERT_EQ(m.data(),ptr); | ||
else | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still test this with C++14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given my other comment, I would just protect the condition with whether C++20 is on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me. Will update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. May not be the best-looking
#if
s...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code should be fine even if
MDSPAN_HAS_CXX_20
defined, because the constraint onstride(r)
won't come into play, no? I'd rather have fewer macros if we can avoid it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is for the case when
exts_1_t::rank() == 0
in the C++20 mode, in which case we have the constraint and it'll result in a compilation error without theif constexpr
.Well, that being said, I think we should only protect the line that calls
stride()
. I'll fix that.