|
Boost-Commit : |
From: eric_at_[hidden]
Date: 2008-06-25 13:58:23
Author: eric_niebler
Date: 2008-06-25 13:58:23 EDT (Wed, 25 Jun 2008)
New Revision: 46687
URL: http://svn.boost.org/trac/boost/changeset/46687
Log:
remove dependence on undefined vector capacity behavior in tail_impl
Text files modified:
trunk/boost/accumulators/statistics/tail.hpp | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
Modified: trunk/boost/accumulators/statistics/tail.hpp
==============================================================================
--- trunk/boost/accumulators/statistics/tail.hpp (original)
+++ trunk/boost/accumulators/statistics/tail.hpp 2008-06-25 13:58:23 EDT (Wed, 25 Jun 2008)
@@ -10,6 +10,7 @@
#include <vector>
#include <functional>
+#include <boost/assert.hpp>
#include <boost/range.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/or.hpp>
@@ -167,7 +168,7 @@
, indices(that.indices)
, samples(that.samples)
{
- this->indices.reserve(that.indices.capacity());
+ this->indices.reserve(this->samples.size());
}
// This just stores the heap and the samples.
@@ -185,7 +186,7 @@
template<typename Args>
void operator ()(Args const &args)
{
- if(this->indices.size() < this->indices.capacity())
+ if(this->indices.size() < this->samples.size())
{
this->indices.push_back(this->indices.size());
this->assign(args, this->indices.back());
@@ -232,6 +233,7 @@
template<typename Args>
void assign(Args const &args, std::size_t index)
{
+ BOOST_ASSERT(index < this->samples.size());
this->samples[index] = args[sample];
std::push_heap(this->indices.begin(), this->indices.end(), indirect_cmp(this->samples));
this->is_sorted = false;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk