Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54235 - in sandbox/monotonic: boost/monotonic libs/monotonic/test
From: christian.schladetsch_at_[hidden]
Date: 2009-06-22 18:10:15


Author: cschladetsch
Date: 2009-06-22 18:10:15 EDT (Mon, 22 Jun 2009)
New Revision: 54235
URL: http://svn.boost.org/trac/boost/changeset/54235

Log:
added region_allocator<Region, Type>

Added:
   sandbox/monotonic/boost/monotonic/region_allocator.hpp (contents, props changed)
Text files modified:
   sandbox/monotonic/boost/monotonic/forward_declarations.hpp | 4 ++++
   sandbox/monotonic/libs/monotonic/test/basic_tests.cpp | 13 +++++++++++++
   sandbox/monotonic/libs/monotonic/test/monotonic.vcproj | 4 ++++
   3 files changed, 21 insertions(+), 0 deletions(-)

Modified: sandbox/monotonic/boost/monotonic/forward_declarations.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/forward_declarations.hpp (original)
+++ sandbox/monotonic/boost/monotonic/forward_declarations.hpp 2009-06-22 18:10:15 EDT (Mon, 22 Jun 2009)
@@ -66,6 +66,10 @@
                 template <class>
                 struct allocator;
 
+ /// a monotonic region allocator uses a specified storage
+ template <size_t RegionNumber, class T>
+ struct region_allocator;
+
                 /// a monotonic shared_allocator has a shared storage buffer and a no-op deallocate() method
                 /// defaults to use static_storage_base<..., shared_storage>
                 template <class>

Added: sandbox/monotonic/boost/monotonic/region_allocator.hpp
==============================================================================
--- (empty file)
+++ sandbox/monotonic/boost/monotonic/region_allocator.hpp 2009-06-22 18:10:15 EDT (Mon, 22 Jun 2009)
@@ -0,0 +1,43 @@
+// Copyright (C) 2009 Christian Schladetsch
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_MONOTONIC_REGION_ALLOCATOR_HPP
+#define BOOST_MONOTONIC_REGION_ALLOCATOR_HPP
+
+#include <boost/monotonic/allocator_base.hpp>
+
+namespace boost
+{
+ namespace monotonic
+ {
+ template <>
+ struct region_allocator<void>
+ {
+ typedef void* pointer;
+ typedef const void* const_pointer;
+
+ typedef void value_type;
+ template <class U>
+ struct rebind
+ {
+ typedef region_allocator<U> other;
+ };
+ };
+
+ storage_base &get_storage();
+ storage_base *set_storage(storage_base &);
+
+ template <size_t Region, class T>
+ struct region_allocator : allocator_base<T, region_allocator<T> >
+ {
+ };
+
+ } // namespace monotonic
+
+} // namespace boost
+
+#endif // #define BOOST_MONOTONIC_REGION_ALLOCATOR_HPP
+
+//EOF

Modified: sandbox/monotonic/libs/monotonic/test/basic_tests.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/basic_tests.cpp (original)
+++ sandbox/monotonic/libs/monotonic/test/basic_tests.cpp 2009-06-22 18:10:15 EDT (Mon, 22 Jun 2009)
@@ -19,6 +19,19 @@
 #endif
 
 
+BOOST_AUTO_TEST_CASE(test_local_allocator)
+{
+ monotonic::storage<> storage;
+ monotonic::allocator_region<0>(storage);
+ typedef std::list<int, monotonic::region_allocator<0, int> > List;
+ {
+ List list;
+ generate_n(back_inserter(list), 10, rand);
+ list.sort();
+ }
+}
+
+
 BOOST_AUTO_TEST_CASE(test_local_storage)
 {
         monotonic::storage<10*1024> storage;

Modified: sandbox/monotonic/libs/monotonic/test/monotonic.vcproj
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/monotonic.vcproj (original)
+++ sandbox/monotonic/libs/monotonic/test/monotonic.vcproj 2009-06-22 18:10:15 EDT (Mon, 22 Jun 2009)
@@ -291,6 +291,10 @@
>
                                 </File>
                                 <File
+ RelativePath="..\..\..\boost\monotonic\region_allocator.hpp"
+ >
+ </File>
+ <File
                                         RelativePath="..\..\..\boost\monotonic\shared_allocator.hpp"
>
                                 </File>


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