From fe6b6ec82f4dd62773a39ea84bdeb73b9fbdd81e Mon Sep 17 00:00:00 2001 From: Ole Erik Peistorpet Date: Tue, 4 Jun 2024 16:25:04 +0200 Subject: [PATCH] adl_begin, adl_end now takes auto &, and [[nodiscard]] index_valid More consistent with std::ranges::begin --- util.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/util.h b/util.h index f6e1b0c2..b7cfbe6e 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 operator[]) +/** * Requires that `r.size()` or `end(r) - begin(r)` is valid. */ template< typename Integral, typename SizedRangeLike > -constexpr bool index_valid(SizedRangeLike & r, Integral index) +[[nodiscard]] constexpr bool index_valid(SizedRangeLike & r, Integral index) { static_assert( sizeof(Integral) >= sizeof _detail::Size(r) or std::is_unsigned_v, "Mismatched index type, please use a wider integer (or unsigned)" ); @@ -104,10 +104,10 @@ inline constexpr for_overwrite_t for_overwrite; //!< An instance of for_overwrit //! Same as `begin(range)` with a previous `using std::begin;`. For use in classes with a member named begin inline constexpr auto adl_begin = - [](auto && range) -> decltype(begin(range)) { return begin(range); }; + [](auto & range) -> decltype(begin(range)) { return begin(range); }; //! Same as `end(range)` with a previous `using std::end;`. For use in classes with a member named end inline constexpr auto adl_end = - [](auto && range) -> decltype(end(range)) { return end(range); }; + [](auto & range) -> decltype(end(range)) { return end(range); };