view: cast to more expressive types when asserting split indices
This commit is contained in:
parent
762678a50f
commit
eb97b5ac01
8
view.hpp
8
view.hpp
@ -340,7 +340,13 @@ namespace cruft {
|
|||||||
[[nodiscard]] constexpr auto
|
[[nodiscard]] constexpr auto
|
||||||
split (IndexT idx) const
|
split (IndexT idx) const
|
||||||
{
|
{
|
||||||
CHECK_LIMIT (idx, IndexT {0u}, cruft::cast::lossless<IndexT> (size ()));
|
// It's ok if `idx` points to the end iterator; this just means the
|
||||||
|
// second element of the returned pair is an empty view.
|
||||||
|
static_assert (
|
||||||
|
std::numeric_limits<IndexT>::max () <= std::numeric_limits<size_type>::max ()
|
||||||
|
);
|
||||||
|
CHECK_GE (idx, IndexT {0});
|
||||||
|
CHECK_LE (cruft::cast::lossless<size_type> (idx), size ());
|
||||||
|
|
||||||
auto last = m_begin;
|
auto last = m_begin;
|
||||||
std::advance (last, idx);
|
std::advance (last, idx);
|
||||||
|
Loading…
Reference in New Issue
Block a user