From b244b896503065198bc736bbff52d6ff79c24986 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 7 Apr 2023 23:47:26 +0100 Subject: Add helper for iterating over a range defined by a pair of iterators --- lib/collections.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib') diff --git a/lib/collections.hpp b/lib/collections.hpp index 2b83500..59cec6f 100644 --- a/lib/collections.hpp +++ b/lib/collections.hpp @@ -117,3 +117,18 @@ materializeRange(const std::pair & in) { return Rtn(in.first, in.second); } + +template struct pair_range { + constexpr auto & + begin() const noexcept + { + return pair.first; + } + constexpr auto & + end() const noexcept + { + return pair.second; + } + const std::pair & pair; +}; +template pair_range(std::pair) -> pair_range; -- cgit v1.2.3