From 4f07b10046ff97e41386145e70207fade8b237cf Mon Sep 17 00:00:00 2001 From: Ole Erik Peistorpet Date: Tue, 11 Jun 2024 12:36:51 +0200 Subject: [PATCH] [[nodiscard]] index_valid --- util.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util.h b/util.h index dcfdf258..9307e3e9 100644 --- a/util.h +++ b/util.h @@ -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, "Mismatched index type, please use a wider integer (or unsigned)" );