From: Francesco Chemolli Date: Sun, 1 Feb 2015 17:15:32 +0000 (+0100) Subject: Added documentation for SBufIterator, fixed SBuf unit test, simplified SBufIterator X-Git-Tag: merge-candidate-3-v1~302^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0262056364358242881263ae6cd4accb7ffadd6e;p=thirdparty%2Fsquid.git Added documentation for SBufIterator, fixed SBuf unit test, simplified SBufIterator --- diff --git a/src/SBuf.h b/src/SBuf.h index 4d3b8f8f2e..7434726126 100644 --- a/src/SBuf.h +++ b/src/SBuf.h @@ -78,6 +78,11 @@ public: class CharacterSet; class SBuf; +/** Forward input iterator for SBufs + * + * Please note that any operation on the underlying SBuf may invalidate + * all iterators over it, resulting in undefined behavior by them. + */ class SBufIterator : public std::iterator { public: @@ -92,10 +97,14 @@ public: protected: SBufIterator(const SBuf &, size_type); - const SBuf &sbuf; const char *iter; }; +/** Reverse input iterator for SBufs + * + * Please note that any operation on the underlying SBuf may invalidate + * all iterators over it, resulting in undefined behavior by them. + */ class SBufReverseIterator : public SBufIterator { friend class SBuf; @@ -669,21 +678,21 @@ ToLower(SBuf buf) inline SBufIterator::SBufIterator(const SBuf &s, size_type pos) - : sbuf(s), iter(s.rawContent()+pos) + : iter(s.rawContent()+pos) {} inline bool SBufIterator::operator==(const SBufIterator &s) const { // note: maybe the sbuf comparison is unnecessary? - return iter == s.iter && sbuf == s.sbuf; + return iter == s.iter; } inline bool SBufIterator::operator!=(const SBufIterator &s) const { // note: maybe the sbuf comparison is unnecessary? - return iter != s.iter || sbuf != s.sbuf; + return iter != s.iter; } #endif /* SQUID_SBUF_H */ diff --git a/src/tests/testSBuf.cc b/src/tests/testSBuf.cc index 44e1c285d1..2a23439721 100644 --- a/src/tests/testSBuf.cc +++ b/src/tests/testSBuf.cc @@ -924,7 +924,7 @@ testSBuf::testIterators() CPPUNIT_ASSERT(text.begin() != text2.begin()); { auto i = text.begin(); - auto e = text.end() + auto e = text.end(); CPPUNIT_ASSERT_EQUAL('f', *i); CPPUNIT_ASSERT(i != e); ++i;