From a8ecc000bf17d3e00cbc7052c7a02d7421821be3 Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 9 Oct 2022 23:15:21 +0000 Subject: [PATCH] Return sentinel from segment_object_range_t --- common/main/segiter.h | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/common/main/segiter.h b/common/main/segiter.h index e08b3fe9d..ccb171a33 100644 --- a/common/main/segiter.h +++ b/common/main/segiter.h @@ -20,20 +20,13 @@ #include #endif -namespace detail -{ - -template -struct unspecified_pointer_t; - -}; - namespace dsx { template class segment_object_range_t { class iterator; + class sentinel; const iterator b; public: segment_object_range_t(iterator &&o) : @@ -41,12 +34,12 @@ public: { } const iterator &begin() const { return b; } - static iterator end() { return T(object_none, static_cast(nullptr)); } + static sentinel end() { return {}; } template static segment_object_range_t construct(const unique_segment &s, OF &of, SF &sf) { if (s.objects == object_none) - return end(); + return iterator(T(object_none, static_cast(nullptr))); auto &&opi = of(s.objects); const object_base &o = opi; #if DXX_SEGITER_DEBUG_OBJECT_LINKAGE @@ -71,6 +64,11 @@ public: } }; +template +class segment_object_range_t::sentinel +{ +}; + template class segment_object_range_t::iterator : T @@ -119,10 +117,14 @@ public: } return *this; } - bool operator==(const iterator &rhs) const + constexpr bool operator==(const iterator &rhs) const { return m_idx == rhs.m_idx; } + constexpr bool operator==(const sentinel &) const + { + return m_idx == object_none; + } }; template ()(object_first))>>