From e680bd79a26869f8a85ae497511dd46c05ae0d3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 30 Jul 2025 23:57:26 +0200 Subject: [PATCH] Fix class invariant comment. In this implementation default constructed deque make no allocation so in that case start and finish are singular iterators. --- doc/container.qbk | 4 ++-- include/boost/container/deque.hpp | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/doc/container.qbk b/doc/container.qbk index 7b1889b..d7ade25 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -481,7 +481,7 @@ inserted predominantly on one extreme (e.g. pushed at one extreme and popped fro To avoid unbounded memory waste, Boost.Container's `devector` uses a different strategy: * If elements are inserted near a extreme and there is free space on that extreme, the insertion is performed - without any additional data movement (only the elements between the insertion point and the extreme are moved. + without any additional data movement (only the elements between the insertion point and the extreme are moved). * If elements are inserted near one extreme and the free space on that extreme is exhausted, all existing elements are relocated (moved) to the center of the internal memory buffer. This makes room in the exhausted extreme @@ -492,7 +492,7 @@ To avoid unbounded memory waste, Boost.Container's `devector` uses a different s relocations must be limited ('relocation limit') and a reallocation (allocation of a new memory buffer) will be performed if the load-factor of the container defined as (size()/length_of_buffer) surpasses the relocation limit (see Lars Greger Nordland Hagen's [@http://larshagencpp.github.io/blog/2016/05/22/devector "Double-ended vector - is it useful?"] - article for more details. + article for more details). * This approach offers a reasonable balance between a reasonable memory overhead and performance. diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp index c1cb4c4..a452cfa 100644 --- a/include/boost/container/deque.hpp +++ b/include/boost/container/deque.hpp @@ -91,9 +91,6 @@ namespace dtl { // i.cur is a pointer in the range [i.first, i.last). NOTE: // the implication of this is that i.cur is always a dereferenceable // pointer, even if i is a past-the-end iterator. -// Start and Finish are always nonsingular iterators. NOTE: this means -// that an empty deque must have one node, and that a deque -// with N elements, where N is the buffer size, must have two nodes. // For every node other than start.node and finish.node, every element // in the node is an initialized object. If start.node == finish.node, // then [start.cur, finish.cur) are initialized objects, and @@ -255,8 +252,7 @@ class deque_iterator offset > 0 ? (offset / block_size) : (-difference_type((-offset - 1) / block_size) - 1); this->priv_set_node(this->m_node + node_offset, size_type(block_size)); - this->m_cur = this->m_first + - (offset - node_offset * block_size); + this->m_cur = this->m_first + (offset - node_offset * block_size); } return *this; }