Skip to content

Commit

Permalink
[[nodiscard]] index_valid
Browse files Browse the repository at this point in the history
  • Loading branch information
OleErikPeistorpet committed Jun 11, 2024
1 parent 710106e commit 4f07b10
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions util.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ using oel::ssize;
}


/** @brief Check if index is valid (within bounds for operator[])
*
//! Returns true if index is within bounds (for `r[index]`)
/**
* Requires that `r.size()` or `end(r) - begin(r)` is valid. */
template< typename Integer, typename SizedRangeLike >
constexpr bool index_valid(SizedRangeLike & r, Integer index)
[[nodiscard]] constexpr bool index_valid(SizedRangeLike & r, Integer index)
{
static_assert( sizeof(Integer) >= sizeof _detail::Size(r) or std::is_unsigned_v<Integer>,
"Mismatched index type, please use a wider integer (or unsigned)" );
Expand Down

0 comments on commit 4f07b10

Please sign in to comment.