|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82324 - in sandbox/static_vector: boost/container test
From: adam.wulkiewicz_at_[hidden]
Date: 2013-01-02 15:34:54
Author: awulkiew
Date: 2013-01-02 15:34:54 EST (Wed, 02 Jan 2013)
New Revision: 82324
URL: http://svn.boost.org/trac/boost/changeset/82324
Log:
Added allocator_adaptor_strategy.
Text files modified:
sandbox/static_vector/boost/container/static_vector.hpp | 27 ++++++++++++++++++++++-----
sandbox/static_vector/test/static_vector_interprocess_test.cpp | 2 +-
sandbox/static_vector/test/static_vector_test.cpp | 2 +-
3 files changed, 24 insertions(+), 7 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 2013-01-02 15:34:54 EST (Wed, 02 Jan 2013)
@@ -36,18 +36,18 @@
// or boost/detail/iterator.hpp ?
#include <boost/iterator/reverse_iterator.hpp>
-// TODO - change the name Strategy to NullAllocator?
+// TODO - change the name Strategy to NullAllocator, StaticAllocator, FakeAllocator or something similar?
namespace boost { namespace container {
// Forward declaration
-template <typename Value, std::size_t Capacity, typename Strategy/*NullAllocator*/>
+template <typename Value, std::size_t Capacity, typename Strategy/*FakeAllocator*/>
class static_vector;
namespace static_vector_detail {
template <typename Value>
-struct default_strategy/*null_allocator*/
+struct default_strategy/*fake_allocator*/
{
typedef Value value_type;
typedef std::size_t size_type;
@@ -63,6 +63,23 @@
}
};
+template <typename Allocator>
+struct allocator_adaptor_strategy/*fake_allocator_adaptor*/
+{
+ typedef typename Allocator::value_type value_type;
+ typedef typename Allocator::size_type size_type;
+ typedef typename Allocator::difference_type difference_type;
+ typedef typename Allocator::pointer pointer;
+ typedef typename Allocator::const_pointer const_pointer;
+ typedef typename Allocator::reference reference;
+ typedef typename Allocator::const_reference const_reference;
+
+ static void allocate_failed()
+ {
+ BOOST_ASSERT_MSG(false, "size can't exceed the capacity");
+ }
+};
+
struct default_error_handler
{
template <typename V, std::size_t Capacity, typename S>
@@ -113,7 +130,7 @@
}
};
-template <typename Value, std::size_t Capacity, typename Strategy/*NullAllocator*/>
+template <typename Value, std::size_t Capacity, typename Strategy/*FakeAllocator*/>
struct static_vector_traits
{
typedef typename Strategy::value_type value_type;
@@ -132,7 +149,7 @@
} // namespace static_vector_detail
-template <typename Value, std::size_t Capacity, typename Strategy/*NullAllocator*/ = static_vector_detail::default_strategy<Value>/*null_allocator*/ >
+template <typename Value, std::size_t Capacity, typename Strategy/*FakeAllocator*/ = static_vector_detail::default_strategy<Value>/*fake_allocator*/ >
class static_vector
{
typedef static_vector_detail::static_vector_traits<
Modified: sandbox/static_vector/test/static_vector_interprocess_test.cpp
==============================================================================
--- sandbox/static_vector/test/static_vector_interprocess_test.cpp (original)
+++ sandbox/static_vector/test/static_vector_interprocess_test.cpp 2013-01-02 15:34:54 EST (Wed, 02 Jan 2013)
@@ -23,7 +23,7 @@
#include <algorithm>
template <typename V, typename SegmentManager>
-struct interprocess_strategy /*interprocess_null_allocator*/
+struct interprocess_strategy /*interprocess_fake_allocator*/
: public boost::interprocess::allocator<V, SegmentManager>
{
static void allocate_failed()
Modified: sandbox/static_vector/test/static_vector_test.cpp
==============================================================================
--- sandbox/static_vector/test/static_vector_test.cpp (original)
+++ sandbox/static_vector/test/static_vector_test.cpp 2013-01-02 15:34:54 EST (Wed, 02 Jan 2013)
@@ -35,7 +35,7 @@
#include "static_vector_test.hpp"
template <typename V>
-struct bad_alloc_strategy /*bad_alloc_null_allocator*/
+struct bad_alloc_strategy /*bad_alloc_fake_allocator*/
: public static_vector_detail::default_strategy<V>
{
static void allocate_failed()
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