$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r54435 - in sandbox/monotonic: boost libs/monotonic/test/clones
From: christian.schladetsch_at_[hidden]
Date: 2009-06-28 02:13:14
Author: cschladetsch
Date: 2009-06-28 02:13:14 EDT (Sun, 28 Jun 2009)
New Revision: 54435
URL: http://svn.boost.org/trac/boost/changeset/54435
Log:
moved make_cloneable_allocator to boost/cloneable.hpp
Text files modified: 
   sandbox/monotonic/boost/cloneable.hpp                 |    43 ++++++++++++++++++++++++++++++++++++    
   sandbox/monotonic/libs/monotonic/test/clones/main.cpp |    47 ++------------------------------------- 
   2 files changed, 46 insertions(+), 44 deletions(-)
Modified: sandbox/monotonic/boost/cloneable.hpp
==============================================================================
--- sandbox/monotonic/boost/cloneable.hpp	(original)
+++ sandbox/monotonic/boost/cloneable.hpp	2009-06-28 02:13:14 EDT (Sun, 28 Jun 2009)
@@ -8,6 +8,7 @@
 
 #include <boost/abstract_allocator.hpp>
 #include <boost/aligned_storage.hpp>
+#include <boost/type_traits/is_convertible.hpp>
 
 namespace boost 
 {
@@ -104,6 +105,48 @@
                         }
                 };
 
+		namespace impl
+		{
+			template <class Alloc>
+			struct cloneable_allocator : Alloc, boost::abstract_allocator
+			{
+				typedef typename Alloc::template rebind<char>::other CharAlloc;
+
+				boost::abstract_allocator::pointer allocate_bytes(size_t num_bytes, size_t alignment)
+				{
+					CharAlloc alloc;
+					// todo: alignment; this is done already for monotonic, copy that here
+					return alloc.allocate(num_bytes);
+				}
+
+				void deallocate_bytes(boost::abstract_allocator::pointer ptr)
+				{
+					CharAlloc alloc;
+					alloc.deallocate(ptr, 1);
+				}
+			};
+
+			template <class Alloc, bool>
+			struct make_cloneable_allocator
+			{		
+				typedef cloneable_allocator<Alloc> type;
+			};
+
+			template <class Alloc>
+			struct make_cloneable_allocator<Alloc, true>
+			{
+				typedef Alloc type;
+			};
+		}
+
+		template <class Alloc>
+		struct make_cloneable_allocator
+		{
+			typedef boost::is_convertible<Alloc *, boost::abstract_allocator *> is_convertible;
+			BOOST_STATIC_CONSTANT(bool, is_cloneable = is_convertible::value);
+			typedef typename impl::make_cloneable_allocator<Alloc, is_cloneable>::type type;
+		};
+
         } // namespace cloneable
 
 } // namespace boost
Modified: sandbox/monotonic/libs/monotonic/test/clones/main.cpp
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/clones/main.cpp	(original)
+++ sandbox/monotonic/libs/monotonic/test/clones/main.cpp	2009-06-28 02:13:14 EDT (Sun, 28 Jun 2009)
@@ -34,48 +34,6 @@
         explicit derived2(std::string const &n) : str(n) { }
 };
 
-namespace detail2
-{
-	template <class Alloc>
-	struct cloneable_allocator : Alloc, boost::abstract_allocator
-	{
-		typedef typename Alloc::template rebind<char>::other CharAlloc;
-
-		boost::abstract_allocator::pointer allocate_bytes(size_t num_bytes, size_t alignment)
-		{
-			CharAlloc alloc;
-			// todo: alignment; this is done already for monotonic, copy that here
-			return alloc.allocate(num_bytes);
-		}
-
-		void deallocate_bytes(boost::abstract_allocator::pointer ptr)
-		{
-			CharAlloc alloc;
-			alloc.deallocate(ptr, 1);
-		}
-	};
-
-	template <class Alloc, bool>
-	struct make_cloneable_allocator
-	{		
-		typedef cloneable_allocator<Alloc> type;
-	};
-
-	template <class Alloc>
-	struct make_cloneable_allocator<Alloc, true>
-	{
-		typedef Alloc type;
-	};
-}
-
-template <class Alloc>
-struct make_cloneable_allocator
-{
-	typedef boost::is_convertible<Alloc *, boost::abstract_allocator *> is_convertible;
-	BOOST_STATIC_CONSTANT(bool, is_cloneable = is_convertible::value);
-	typedef typename detail2::make_cloneable_allocator<Alloc, is_cloneable>::type type;
-};
-
 /*
 
 namespace boost { namespace ptr_container {
@@ -90,8 +48,9 @@
 
 int main()
 {
-	//typedef make_cloneable_allocator<std::allocator<int> >::type alloc_type;
-	typedef make_cloneable_allocator<monotonic::allocator<int> >::type alloc_type;
+	//typedef cloneable::make_cloneable_allocator<std::allocator<int> >::type alloc_type;
+	typedef cloneable::make_cloneable_allocator<monotonic::allocator<int> >::type alloc_type;
+
         typedef ptr_vector<cloneable::common_base, cloneable::allocator, alloc_type > vec;
 
         {