Skip to content

Commit

Permalink
Make sure StaticExtentFromRange recognizes device-compatible integral…
Browse files Browse the repository at this point in the history
…_constant
  • Loading branch information
nmm0 committed Oct 2, 2024
1 parent 56d8424 commit 00969d8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/experimental/__p2630_bits/submdspan_extents.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@ struct StaticExtentFromRange<std::integral_constant<Integral0, val0>,
constexpr static size_t value = val1 - val0;
};

template <class Integral0, Integral0 val0, class Integral1, Integral1 val1>
struct StaticExtentFromRange<integral_constant<Integral0, val0>,
integral_constant<Integral1, val1>> {
constexpr static size_t value = val1 - val0;
};

// compute new static extent from strided_slice, preserving static
// knowledge
template <class Arg0, class Arg1> struct StaticExtentFromStridedRange {
Expand All @@ -314,6 +320,12 @@ struct StaticExtentFromStridedRange<std::integral_constant<Integral0, val0>,
constexpr static size_t value = val0 > 0 ? 1 + (val0 - 1) / val1 : 0;
};

template <class Integral0, Integral0 val0, class Integral1, Integral1 val1>
struct StaticExtentFromStridedRange<integral_constant<Integral0, val0>,
integral_constant<Integral1, val1>> {
constexpr static size_t value = val0 > 0 ? 1 + (val0 - 1) / val1 : 0;
};

// creates new extents through recursive calls to next_extent member function
// next_extent has different overloads for different types of stride specifiers
template <size_t K, class Extents, size_t... NewExtents>
Expand Down

0 comments on commit 00969d8

Please sign in to comment.