From a22d40e868c956a92f92abcbc30dfd14d20bd98f Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 26 May 2008 20:51:31 +0000 Subject: Speculative "fix" for solaris compile errors discussed on qpid-dev. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@660302 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/RangeSet.h | 59 +++++++++++++++++------------------- cpp/src/qpid/framing/SequenceSet.cpp | 4 +-- cpp/src/tests/SessionState.cpp | 2 +- 3 files changed, 31 insertions(+), 34 deletions(-) diff --git a/cpp/src/qpid/RangeSet.h b/cpp/src/qpid/RangeSet.h index b0757a0249..a8849cf9b8 100644 --- a/cpp/src/qpid/RangeSet.h +++ b/cpp/src/qpid/RangeSet.h @@ -96,11 +96,7 @@ class RangeSet boost::additive2, Range, boost::additive2, T> > > { - public: - typedef qpid::Range Range; - - private: - typedef InlineVector Ranges; // TODO aconway 2008-04-21: what's the optimial inlined value? + typedef InlineVector, 3> Ranges; // TODO aconway 2008-04-21: what's the optimial inlined value? public: @@ -132,32 +128,32 @@ class RangeSet typedef iterator const_iterator; RangeSet() {} - explicit RangeSet(const Range& r) { *this += r; } - RangeSet(const T& a, const T& b) { *this += Range(a,b); } + explicit RangeSet(const Range& r) { *this += r; } + RangeSet(const T& a, const T& b) { *this += Range(a,b); } bool contiguous() const { return ranges.size() <= 1; } bool contains(const T& t) const; - bool contains(const Range&) const; + bool contains(const Range&) const; /**@pre contiguous() */ - Range toRange() const; + Range toRange() const; bool operator==(const RangeSet&) const; - void addRange (const Range&); - void addSet (const RangeSet&); + void addRange (const Range&); + void addSet (const RangeSet&); - RangeSet& operator+=(const T& t) { return *this += Range(t); } - RangeSet& operator+=(const Range& r) { addRange(r); return *this; } - RangeSet& operator+=(const RangeSet& s) { addSet(s); return *this; } + RangeSet& operator+=(const T& t) { return *this += Range(t); } + RangeSet& operator+=(const Range& r) { addRange(r); return *this; } + RangeSet& operator+=(const RangeSet& s) { addSet(s); return *this; } - void removeRange (const Range&); - void removeSet (const RangeSet&); + void removeRange (const Range&); + void removeSet (const RangeSet&); - RangeSet& operator-=(const T& t) { return *this -= Range(t); } - RangeSet& operator-=(const Range& r) { removeRange(r); return *this; } - RangeSet& operator-=(const RangeSet& s) { removeSet(s); return *this; } + RangeSet& operator-=(const T& t) { return *this -= Range(t); } + RangeSet& operator-=(const Range& r) { removeRange(r); return *this; } + RangeSet& operator-=(const RangeSet& s) { removeSet(s); return *this; } T front() const { return ranges.front().begin(); } T back() const { return ranges.back().end(); } @@ -178,11 +174,11 @@ class RangeSet /** Return the largest contiguous range containing x. * Returns the empty range [x,x) if x is not in the set. */ - Range rangeContaining(const T&) const; + Range rangeContaining(const T&) const; template void serialize(S& s) { s.split(*this); s(ranges.begin(), ranges.end()); } - template void encode(S& s) const { s(uint16_t(ranges.size()*sizeof(Range))); } - template void decode(S& s) { uint16_t sz; s(sz); ranges.resize(sz/sizeof(Range)); } + template void encode(S& s) const { s(uint16_t(ranges.size()*sizeof(Range))); } + template void decode(S& s) { uint16_t sz; s(sz); ranges.resize(sz/sizeof(Range)); } private: Ranges ranges; @@ -213,13 +209,13 @@ bool RangeSet::contains(const T& t) const { } template -bool RangeSet::contains(const Range& r) const { +bool RangeSet::contains(const Range& r) const { typename Ranges::const_iterator i = std::lower_bound(ranges.begin(), ranges.end(), r.begin()); return i != ranges.end() && i->contains(r); } -template void RangeSet::addRange(const Range& r) { +template void RangeSet::addRange(const Range& r) { if (r.empty()) return; typename Ranges::iterator i = std::lower_bound(ranges.begin(), ranges.end(), r.begin()); @@ -237,11 +233,12 @@ template void RangeSet::addRange(const Range& r) { template void RangeSet::addSet(const RangeSet& s) { + typedef RangeSet& (RangeSet::*RangeSetRangeOp)(const Range&); std::for_each(s.ranges.begin(), s.ranges.end(), - boost::bind((RangeSet& (RangeSet::*)(const Range&))&RangeSet::operator+=, this, _1)); + boost::bind((RangeSetRangeOp)&RangeSet::operator+=, this, _1)); } -template void RangeSet::removeRange(const Range& r) { +template void RangeSet::removeRange(const Range& r) { if (r.empty()) return; typename Ranges::iterator i,j; i = std::lower_bound(ranges.begin(), ranges.end(), r.begin()); @@ -250,8 +247,8 @@ template void RangeSet::removeRange(const Range& r) { if (*i == r) // Erase i ranges.erase(i); else if (i->strictContains(r)) { // Split i - Range i1(i->begin(), r.begin()); - Range i2(r.end(), i->end()); + Range i1(i->begin(), r.begin()); + Range i2(r.end(), i->end()); *i = i2; ranges.insert(i, i1); } else { @@ -267,7 +264,7 @@ template void RangeSet::removeRange(const Range& r) { } } -template void RangeSet::removeSet(const RangeSet& r) { +template void RangeSet::removeSet(const RangeSet& r) { std::for_each( r.ranges.begin(), r.ranges.end(), boost::bind(&RangeSet::removeRange, this, _1)); @@ -275,7 +272,7 @@ template void RangeSet::removeSet(const RangeSet& r) { template Range RangeSet::toRange() const { assert(contiguous()); - return empty() ? Range() : ranges.front(); + return empty() ? Range() : ranges.front(); } template void RangeSet::iterator::increment() { @@ -308,7 +305,7 @@ template bool RangeSet::iterator::equal(const iterator& i) const { template Range RangeSet::rangeContaining(const T& t) const { typename Ranges::const_iterator i = std::lower_bound(ranges.begin(), ranges.end(), t); - return (i != ranges.end() && i->contains(t)) ? *i : Range(t,t); + return (i != ranges.end() && i->contains(t)) ? *i : Range(t,t); } diff --git a/cpp/src/qpid/framing/SequenceSet.cpp b/cpp/src/qpid/framing/SequenceSet.cpp index 9ba55b2fa8..9610b9180c 100644 --- a/cpp/src/qpid/framing/SequenceSet.cpp +++ b/cpp/src/qpid/framing/SequenceSet.cpp @@ -67,7 +67,7 @@ bool SequenceSet::contains(const SequenceNumber& s) const { void SequenceSet::add(const SequenceNumber& s) { *this += s; } void SequenceSet::add(const SequenceNumber& start, const SequenceNumber& finish) { - *this += Range::makeClosed(std::min(start,finish), std::max(start, finish)); + *this += Range::makeClosed(std::min(start,finish), std::max(start, finish)); } void SequenceSet::add(const SequenceSet& set) { *this += set; } @@ -75,7 +75,7 @@ void SequenceSet::add(const SequenceSet& set) { *this += set; } void SequenceSet::remove(const SequenceSet& set) { *this -= set; } void SequenceSet::remove(const SequenceNumber& start, const SequenceNumber& finish) { - *this -= Range::makeClosed(std::min(start,finish), std::max(start, finish)); + *this -= Range::makeClosed(std::min(start,finish), std::max(start, finish)); } void SequenceSet::remove(const SequenceNumber& s) { *this -= s; } diff --git a/cpp/src/tests/SessionState.cpp b/cpp/src/tests/SessionState.cpp index 40922b3be8..43b949cfff 100644 --- a/cpp/src/tests/SessionState.cpp +++ b/cpp/src/tests/SessionState.cpp @@ -250,7 +250,7 @@ QPID_AUTO_TEST_CASE(testCompleted) { BOOST_CHECK_EQUAL(s.receiverGetUnknownComplete(), SequenceSet(SequenceSet()+1)); s.receiverCompleted(0); BOOST_CHECK_EQUAL(s.receiverGetUnknownComplete(), - SequenceSet(SequenceSet() + SequenceSet::Range(0,2))); + SequenceSet(SequenceSet() + qpid::Range(0,2))); s.receiverKnownCompleted(SequenceSet(SequenceSet()+1)); BOOST_CHECK_EQUAL(s.receiverGetUnknownComplete(), SequenceSet(SequenceSet()+2)); // TODO aconway 2008-04-30: missing tests for known-completed. -- cgit v1.2.1