$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r54257 - in sandbox/monotonic: boost/monotonic libs/monotonic/test libs/monotonic/test/Tests
From: christian.schladetsch_at_[hidden]
Date: 2009-06-23 00:08:23
Author: cschladetsch
Date: 2009-06-23 00:08:22 EDT (Tue, 23 Jun 2009)
New Revision: 54257
URL: http://svn.boost.org/trac/boost/changeset/54257
Log:
added new implementation for shared_allocator<T>, based on allocator<T,R,shared_access_tag>
Added:
   sandbox/monotonic/boost/monotonic/shared_allocator.hpp   (contents, props changed)
Text files modified: 
   sandbox/monotonic/boost/monotonic/forward_declarations.hpp |    14 +++++++-------                          
   sandbox/monotonic/boost/monotonic/shared_storage.hpp       |     7 -------                                 
   sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp      |     5 +++++                                   
   sandbox/monotonic/libs/monotonic/test/monotonic.vcproj     |     4 ++++                                    
   4 files changed, 16 insertions(+), 14 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-23 00:08:22 EDT (Tue, 23 Jun 2009)
@@ -83,15 +83,15 @@
                 template <class T, class Region = default_region_tag, class Access = default_access_tag> 
                 struct allocator;
 
-		///// a monotonic shared_allocator has a shared storage buffer and a no-op deallocate() method
-		///// defaults to use static_storage_base<..., shared_storage>
+		/// 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 T, class Region = default_region_tag> 
-		struct shared_allocator;// : allocator<T, Region, shared_access_tag> { };
+		struct shared_allocator;
         
-		///// a monotonic local_allocator has a shared storage buffer and a no-op deallocate() method
-		///// defaults to use static_storage_base<..., thread_local_storage>
-		//template <class T, class Region = thread_local_region_tag> 
-		//struct local_allocator;
+		/// a monotonic local_allocator has a shared storage buffer and a no-op deallocate() method
+		/// defaults to use static_storage_base<..., thread_local_storage>
+		template <class T, class Region = default_region_tag>
+		struct thread_local_allocator;
 
         } // namespace monotonic
 
Added: sandbox/monotonic/boost/monotonic/shared_allocator.hpp
==============================================================================
--- (empty file)
+++ sandbox/monotonic/boost/monotonic/shared_allocator.hpp	2009-06-23 00:08:22 EDT (Tue, 23 Jun 2009)
@@ -0,0 +1,80 @@
+// 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_SHARED_ALLOCATOR_HPP
+#define BOOST_MONOTONIC_SHARED_ALLOCATOR_HPP
+
+#include <boost/monotonic/shared_storage.hpp>
+
+namespace boost
+{
+	namespace monotonic
+	{
+		template <class Region> 
+		struct shared_allocator<void, Region>
+		{
+			typedef void* pointer;
+			typedef const void* const_pointer;
+
+			typedef void value_type;
+			template <class U> 
+			struct rebind 
+			{ 
+				typedef shared_allocator<U, Region> other; 
+			};
+		};
+
+		template <class T, class Region>
+		struct shared_allocator : allocator<T, Region, shared_access_tag>
+		{
+			typedef allocator<T, Region, shared_access_tag> Parent;
+			using typename Parent::size_type;
+			using typename Parent::difference_type;
+			using typename Parent::pointer;
+			using typename Parent::const_pointer;
+			using typename Parent::reference;
+			using typename Parent::const_reference;
+			using typename Parent::value_type;
+
+			template <class U> 
+			struct rebind 
+			{ 
+				typedef shared_allocator<U, Region> other; 
+			};
+
+			shared_allocator() throw() 
+				: Parent(boost::monotonic::get_storage<Region,shared_access_tag>()) { }
+
+		public:
+			shared_allocator(storage_base &store) throw() 
+				: Parent(store) { }
+
+		public:
+			shared_allocator(const shared_allocator& alloc) throw() 
+				: Parent(alloc) { }
+
+			template <class U> 
+			shared_allocator(const shared_allocator<U, Region> &alloc) throw()
+				: Parent(alloc) { }
+
+			friend bool operator==(shared_allocator<T,Region> const &A, shared_allocator<T,Region> const &B) 
+			{ 
+				return static_cast<Parent const &>(A) == static_cast<Parent const &>(B);
+			}
+
+			friend bool operator!=(shared_allocator<T,Region> const &A, shared_allocator<T,Region> const &B) 
+			{ 
+				return static_cast<Parent const &>(A) != static_cast<Parent const &>(B);
+			}
+		};
+
+	} // namespace monotonic
+
+} // namespace boost
+
+#endif // BOOST_MONOTONIC_SHARED_ALLOCATOR_HPP
+
+//EOF
+
Modified: sandbox/monotonic/boost/monotonic/shared_storage.hpp
==============================================================================
--- sandbox/monotonic/boost/monotonic/shared_storage.hpp	(original)
+++ sandbox/monotonic/boost/monotonic/shared_storage.hpp	2009-06-23 00:08:22 EDT (Tue, 23 Jun 2009)
@@ -83,13 +83,6 @@
 
                 };
 
-		//extern static_storage_base<
-		//	DefaultSizes::StaticInlineSize
-		//	, DefaultSizes::StaticMinHeapIncrement
-		//	, std::allocator<char>
-		//	, shared_storage> 
-		//static_shared_storage;
-		
         } // namespace monotonic
 
 } // namespace boost
Modified: sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp	(original)
+++ sandbox/monotonic/libs/monotonic/test/Tests/tests.cpp	2009-06-23 00:08:22 EDT (Tue, 23 Jun 2009)
@@ -10,6 +10,7 @@
 //#include <boost/monotonic/shared_allocator.hpp>
 #include <boost/monotonic/shared_storage.hpp>
 #include <boost/monotonic/thread_local_storage.hpp>
+#include <boost/monotonic/shared_allocator.hpp>
 
 #define BOOST_TEST_MODULE basic_test test
 #include <boost/test/unit_test.hpp>
@@ -31,6 +32,10 @@
         typedef std::list<int, monotonic::allocator<int, region0, monotonic::shared_access_tag> > List0;
         List0 list0;
 
+	// same thing, less typing:
+	typedef std::list<int, monotonic::shared_allocator<int, region0> > List2;
+	List2 list2;
+
         typedef std::list<int, monotonic::allocator<int, region0, monotonic::thread_local_access_tag> > List1;
         List1 list1;
 }
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-23 00:08:22 EDT (Tue, 23 Jun 2009)
@@ -287,6 +287,10 @@
 					>
                                 </File>
                                 <File
+					RelativePath="..\..\..\boost\monotonic\shared_allocator.hpp"
+					>
+				</File>
+				<File
                                         RelativePath="..\..\..\boost\monotonic\shared_storage.hpp"
 					>
                                 </File>