Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82212 - in sandbox/static_vector: boost/container test
From: adam.wulkiewicz_at_[hidden]
Date: 2012-12-26 12:55:16


Author: awulkiew
Date: 2012-12-26 12:55:15 EST (Wed, 26 Dec 2012)
New Revision: 82212
URL: http://svn.boost.org/trac/boost/changeset/82212

Log:
size_type moved from strategy to traits, ..._COPYABLE_AND_MOVABLE macro removed
Text files modified:
   sandbox/static_vector/boost/container/static_vector.hpp | 49 ++++++++++++++-------------------------
   sandbox/static_vector/test/static_vector.cpp | 15 -----------
   2 files changed, 19 insertions(+), 45 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-26 12:55:15 EST (Wed, 26 Dec 2012)
@@ -32,27 +32,6 @@
 // or boost/detail/iterator.hpp ?
 #include <boost/iterator/reverse_iterator.hpp>
 
-#if defined(BOOST_NO_RVALUE_REFERENCES)
-
-#define BOOST_CONTAINER_STATIC_VECTOR_COPYABLE_AND_MOVABLE() \
-BOOST_COPYABLE_AND_MOVABLE(static_vector) \
-public: \
- template <std::size_t C, typename S> \
- static_vector & operator=(static_vector<Value, C, S> & t) \
- { \
- typedef static_vector<Value, C, S> O; \
- this->operator=(static_cast<const ::boost::rv<O> &>(const_cast<const O &>(t))); \
- return *this; \
- } \
-private:
-
-#else
-
-#define BOOST_CONTAINER_STATIC_VECTOR_COPYABLE_AND_MOVABLE() \
-BOOST_COPYABLE_AND_MOVABLE(static_vector)
-
-#endif
-
 namespace boost { namespace container {
 
 // Forward declaration
@@ -63,11 +42,8 @@
 
 // TODO - remove size_type from here and allow setting it only in traits?
 
-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)
     {
@@ -82,7 +58,7 @@
         if ( v.size() <= i )
             throw std::out_of_range("index out of bounds");
 #else // BOOST_NO_EXCEPTIONS
- BOOST_ASSERT_MSG(i <= v.size(), "index out of bounds");
+ BOOST_ASSERT_MSG(i < v.size(), "index out of bounds");
 #endif // BOOST_NO_EXCEPTIONS
     }
 
@@ -117,7 +93,7 @@
 template <typename Value, std::size_t Capacity, typename Strategy>
 struct static_vector_traits
 {
- typedef typename Strategy::size_type size_type;
+ typedef std::size_t size_type;
     typedef boost::false_type use_memop_in_swap_and_move;
     typedef boost::false_type use_optimized_swap;
     typedef Strategy strategy;
@@ -125,7 +101,7 @@
 
 } // namespace static_vector_detail
 
-template <typename Value, std::size_t Capacity, typename Strategy = static_vector_detail::default_strategy<> >
+template <typename Value, std::size_t Capacity, typename Strategy = static_vector_detail::default_strategy >
 class static_vector
 {
     typedef typename
@@ -153,18 +129,29 @@
     template <typename V, std::size_t C, typename S>
     friend class static_vector;
 
- BOOST_CONTAINER_STATIC_VECTOR_COPYABLE_AND_MOVABLE()
+ BOOST_COPYABLE_AND_MOVABLE(static_vector)
+
+#ifdef BOOST_NO_RVALUE_REFERENCES
+public:
+ template <std::size_t C, typename S>
+ static_vector & operator=(static_vector<Value, C, S> & sv)
+ {
+ typedef static_vector<Value, C, S> other;
+ this->operator=(static_cast<const ::boost::rv<other> &>(const_cast<const other &>(sv)));
+ return *this;
+ }
+#endif
 
 public:
     typedef Value value_type;
     typedef stored_size_type size_type;
     typedef std::ptrdiff_t difference_type;
- typedef Value& reference;
+ typedef Value & reference;
     typedef Value const& const_reference;
- typedef Value * pointer;
+ typedef Value* pointer;
     typedef const Value* const_pointer;
     typedef Value* iterator;
- typedef const Value * const_iterator;
+ typedef const Value* const_iterator;
     typedef boost::reverse_iterator<iterator> reverse_iterator;
     typedef boost::reverse_iterator<const_iterator> const_reverse_iterator;
 

Modified: sandbox/static_vector/test/static_vector.cpp
==============================================================================
--- sandbox/static_vector/test/static_vector.cpp (original)
+++ sandbox/static_vector/test/static_vector.cpp 2012-12-26 12:55:15 EST (Wed, 26 Dec 2012)
@@ -527,7 +527,7 @@
 #endif
 }
 
-struct bad_alloc_strategy : public static_vector_detail::default_strategy<>
+struct bad_alloc_strategy : public static_vector_detail::default_strategy
 {
     template <typename V, std::size_t Capacity, typename S>
     static void check_capacity(static_vector<V, Capacity, S> const&, std::size_t s)
@@ -541,19 +541,6 @@
     }
 };
 
-namespace boost { namespace container { namespace static_vector_detail {
-
-template <typename Value, std::size_t Capacity>
-struct static_vector_traits<Value, Capacity, bad_alloc_strategy>
-{
- typedef std::size_t size_type;
- typedef boost::false_type use_memop_in_swap_and_move;
- typedef boost::false_type use_optimized_swap;
- typedef bad_alloc_strategy strategy;
-};
-
-}}}
-
 template <typename T>
 void test_capacity_0_nd()
 {


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