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

remove lambda expression in layout stride #311

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Changes from all commits
Commits
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
29 changes: 17 additions & 12 deletions include/experimental/__p0009_bits/layout_stride.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,21 @@ struct layout_stride {
// Can't use defaulted parameter in the __deduction_workaround template because of a bug in MSVC warning C4348.
using __impl = __deduction_workaround<std::make_index_sequence<Extents::rank()>>;

static constexpr __strides_storage_t strides_storage(std::true_type) {
__strides_storage_t s{};

extents_type e;
index_type stride = 1;
for(int r = static_cast<int>(extents_type::rank() - 1); r >= 0; r--) {
s[r] = stride;
stride *= e.extent(r);
}

return s;
}
static constexpr __strides_storage_t strides_storage(std::false_type) {
return {};
}

//----------------------------------------------------------------------------

Expand All @@ -246,18 +261,8 @@ struct layout_stride {
#else
: __base_t(__base_t{__member_pair_t(
#endif
extents_type(), __strides_storage_t([]() {
__strides_storage_t s{};
if constexpr (extents_type::rank() > 0) {
extents_type e;
index_type stride = 1;
for(int r = static_cast<int>(extents_type::rank() - 1); r >= 0; r--) {
s[r] = stride;
stride *= e.extent(r);
}
}
return s;
}())
extents_type(),
__strides_storage_t(strides_storage(std::integral_constant<bool, (extents_type::rank() > 0)>{}))
#if defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS)
}
#else
Expand Down
Loading