|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82131 - sandbox/static_vector/boost/container
From: adam.wulkiewicz_at_[hidden]
Date: 2012-12-20 22:37:40
Author: awulkiew
Date: 2012-12-20 22:37:39 EST (Thu, 20 Dec 2012)
New Revision: 82131
URL: http://svn.boost.org/trac/boost/changeset/82131
Log:
Two versions of swap_dispatch() added. Headers and comments cleaned.
Text files modified:
sandbox/static_vector/boost/container/static_vector.hpp | 38 ++++++++++++++++++++++++++++++--------
1 files changed, 30 insertions(+), 8 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-20 22:37:39 EST (Thu, 20 Dec 2012)
@@ -38,14 +38,17 @@
namespace static_vector_detail {
-struct error_handling
+template <typename SizeType = std::size_t>
+struct default_strategy
{
+ typedef SizeType size_type;
+
template <typename V, std::size_t Capacity, typename S>
static void check_capacity(container::static_vector<V, Capacity, S> const&, std::size_t s)
{
- //BOOST_ASSERT_MSG(s <= Capacity, "size can't exceed the capacity");
- if ( Capacity < s )
- throw std::bad_alloc();
+ BOOST_ASSERT_MSG(s <= Capacity, "size can't exceed the capacity");
+// if ( Capacity < s )
+// throw std::bad_alloc();
}
template <typename V, std::size_t C, typename S>
@@ -84,9 +87,17 @@
}
};
+template <typename Value, std::size_t Capacity, typename Strategy>
+struct static_vector_traits
+{
+ typedef typename Strategy::size_type size_type;
+ typedef boost::true_type use_nonthrowing_swap;
+ typedef Strategy strategy;
+};
+
} // namespace static_vector_detail
-template <typename Value, std::size_t Capacity, typename StoredSizeType = std::size_t>
+template <typename Value, std::size_t Capacity, typename Strategy = static_vector_detail::default_strategy<> >
class static_vector
{
BOOST_MPL_ASSERT_MSG(
@@ -101,11 +112,17 @@
boost::alignment_of<Value[Capacity]>::value
> aligned_storage_type;
- typedef static_vector_detail::error_handling errh;
+ typedef typename
+ static_vector_detail::static_vector_traits<
+ Value, Capacity, Strategy
+ >::strategy errh;
public:
typedef Value value_type;
- typedef StoredSizeType size_type;
+ typedef typename
+ typedef static_vector_detail::static_vector_traits<
+ Value, Capacity, Strategy
+ >::size_type size_type;
typedef std::ptrdiff_t difference_type;
typedef Value& reference;
typedef Value const& const_reference;
@@ -191,7 +208,12 @@
// swap (note: linear complexity)
void swap(static_vector & other)
{
- this->swap_dispatch(other, boost::true_type());
+ typedef typename
+ static_vector_detail::static_vector_traits<
+ Value, Capacity, Strategy
+ >::use_nonthrowing_swap use_nonthrowing_swap;
+
+ this->swap_dispatch(other, use_nonthrowing_swap());
}
// basic
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