-
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 3 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 |
---|---|---|
|
@@ -391,9 +391,11 @@ TYPED_TEST(TestLayoutConversion, implicit_conversion) { | |
#endif | ||
map1 = typename TestFixture::map_1_t(map2); | ||
|
||
for(size_t r=0; r != this->exts1.rank(); ++r) { | ||
ASSERT_EQ(map1.extents().extent(r), map2.extents().extent(r)); | ||
ASSERT_EQ(map1.stride(r), map2.stride(r)); | ||
if constexpr (TestFixture::exts_1_t::rank() > 0) { | ||
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. We still test this with C++14 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. 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Updated. May not be the best-looking 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. This code should be fine even if 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. This check is for the case when |
||
for(size_t r=0; r != this->exts1.rank(); ++r) { | ||
ASSERT_EQ(map1.extents().extent(r), map2.extents().extent(r)); | ||
ASSERT_EQ(map1.stride(r), map2.stride(r)); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,15 +143,21 @@ void check_correctness(MDA& m, size_t rank, size_t rank_dynamic, | |
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 constexpr (MDA::extents_type::rank()>0) { | ||
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. same as above. |
||
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 constexpr (MDA::extents_type::rank()>0) { | ||
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 constexpr (MDA::extents_type::rank()>0) { | ||
ASSERT_EQ(m.stride(2), stride_2); | ||
} | ||
} | ||
if(ptr_matches) | ||
ASSERT_EQ(m.data(),ptr); | ||
|
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.
I don't like introducing a template parameter here for C++17/14. I would say we just do this only for C++20 using a requires clause on a non-templated function, and note down in the readme that this constraint is not implemented pre-c++20,