Workaround for possible bug in pool allocator

release/4.3a0
Richard Roberts 2012-02-13 20:27:59 +00:00
parent 7e9a4c1a25
commit 30bb9e61cc
1 changed files with 17 additions and 2 deletions

View File

@ -50,14 +50,29 @@ public:
/** Constructor from a range, passes through to base class */
template<typename INPUTITERATOR>
explicit FastVector(INPUTITERATOR first, INPUTITERATOR last) : Base(first, last) {}
explicit FastVector(INPUTITERATOR first, INPUTITERATOR last) {
// This if statement works around a bug in boost pool allocator and/or
// STL vector where if the size is zero, the pool allocator will allocate
// huge amounts of memory.
if(first != last)
Base::assign(first, last);
}
/** Copy constructor from another FastSet */
FastVector(const FastVector<VALUE>& x) : Base(x) {}
/** Copy constructor from the base map class */
/** Copy constructor from the base class */
FastVector(const Base& x) : Base(x) {}
/** Copy constructor from a standard STL container */
FastVector(const std::vector<VALUE>& x) {
// This if statement works around a bug in boost pool allocator and/or
// STL vector where if the size is zero, the pool allocator will allocate
// huge amounts of memory.
if(x.size() > 0)
Base::assign(x.begin(), x.end());
}
private:
/** Serialization function */
friend class boost::serialization::access;