Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82076 - sandbox/static_vector/boost/container
From: adam.wulkiewicz_at_[hidden]
Date: 2012-12-18 08:07:19


Author: awulkiew
Date: 2012-12-18 08:07:18 EST (Tue, 18 Dec 2012)
New Revision: 82076
URL: http://svn.boost.org/trac/boost/changeset/82076

Log:
Added MPL_ASSERT checking the correctness of StoredSizeType.
Text files modified:
   sandbox/static_vector/boost/container/static_vector.hpp | 12 ++++++++++--
   1 files changed, 10 insertions(+), 2 deletions(-)

Modified: sandbox/static_vector/boost/container/static_vector.hpp
==============================================================================
--- sandbox/static_vector/boost/container/static_vector.hpp (original)
+++ sandbox/static_vector/boost/container/static_vector.hpp 2012-12-18 08:07:18 EST (Tue, 18 Dec 2012)
@@ -125,10 +125,18 @@
 template <typename Value, std::size_t Capacity, typename StoredSizeType = std::size_t>
 class static_vector
 {
+ BOOST_MPL_ASSERT_MSG(
+ ( boost::is_unsigned<StoredSizeType>::value &&
+ sizeof(typename boost::uint_value_t<Capacity>::least) <= sizeof(StoredSizeType) ),
+ SIZE_TYPE_IS_TOO_SMALL,
+ (static_vector)
+ );
+
     typedef boost::aligned_storage<
         sizeof(Value[Capacity]),
         boost::alignment_of<Value[Capacity]>::value
> aligned_storage_type;
+
     typedef detail::static_vector::error_handling errh;
 
 public:
@@ -259,7 +267,7 @@
         if ( this->size() < other.size() )
         {
             for (; it != this->end() ; ++it, ++other_it)
- boost::swap(*it, *other_it); // may throw
+ boost::swap(*it, *other_it); // may throw
             this->insert(it, other_it, other.end()); // may throw
             other.erase(other_it, other.end());
         }
@@ -267,7 +275,7 @@
         {
             for (; other_it != other.end() ; ++it, ++other_it)
                 boost::swap(*it, *other_it); // may throw
- other.insert(other_it,it,this->end()); // may throw
+ other.insert(other_it,it,this->end()); // may throw
             this->erase(it, this->end());
         }
     }


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