diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/context/cdlist_context_memory.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/context/cdlist_context_memory.h b/src/context/cdlist_context_memory.h index 20d672d31..2fd1ceb8c 100644 --- a/src/context/cdlist_context_memory.h +++ b/src/context/cdlist_context_memory.h @@ -476,7 +476,11 @@ public: * Returns an iterator pointing to the first item in the list. */ const_iterator begin() const { - return const_iterator(&d_headSegment, 0); + // This looks curious, but we have to make sure that begin() == end() + // for an empty list, and begin() == (head,0) for a nonempty one. + // Since the segment spill-over is implemented in + // iterator::operator++(), let's reuse it. */ + return ++const_iterator(&d_headSegment, -1); } /** |