From 4b5f95af9c0e67f10779f1d93f37dc9877904796 Mon Sep 17 00:00:00 2001
From: Christian Engwer <christi@dune-project.org>
Date: Wed, 19 Dec 2007 12:55:51 +0000
Subject: [PATCH] added AllocatorType traits class

[[Imported from SVN: r5031]]
---
 common/typetraits.hh | 51 ++++++++++++++++++++++++++++++++++++++++++++
 doc/doxygen/Doxyfile |  2 +-
 2 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/common/typetraits.hh b/common/typetraits.hh
index 7de0ec144..9e532dc73 100644
--- a/common/typetraits.hh
+++ b/common/typetraits.hh
@@ -355,6 +355,57 @@ namespace Dune
   {
     typedef T2 Type;
   };
+
+  /**
+   * @brief provided one allocator, get the same allocator for a different object type
+   *
+   * the resulting type is exported as Type
+   *
+   * this class does not implement anything, it must be specialized
+   * for each allocator class in use
+   */
+
+  template <class A, class T>
+  struct AllocatorType;
+
+  /**
+     @copydoc AllocatorType
+
+     specialization for all allocators of the for ALLOCATOR<TYPE>
+
+     this is expected to work for
+
+     std::allocator
+     __gnu_cxx::new_allocator<T>
+     __gnu_cxx::malloc_allocator<T>
+     __gnu_cxx::__pool_alloc<T>
+     __gnu_cxx::__mt_alloc<T>
+     __gnu_cxx::bitmap_allocator<T>
+     __gnu_cxx::array_allocator<T>
+     __gnu_cxx::throw_allocator<T>
+   */
+  template <template<class> class Allocator, class T1, class T2>
+  struct AllocatorType< Allocator<T1>, T2 >
+  {
+    typedef Allocator<T2> Type;
+  };
+
+#ifdef _DEBUG_ALLOCATOR_H
+  /**
+     @copydoc AllocatorType
+
+     if you want to use this specialization, you have to ensure that
+     <ext/debug_allocator.h> is included before <dune/common/typetraits.hh>
+
+     specialization for __gnu_cxx::debug_allocator< Allocator >
+   */
+  template <class A, class T>
+  struct AllocatorType< __gnu_cxx::debug_allocator<A>, T >
+  {
+    typedef typename __gnu_cxx::debug_allocator< typename AllocatorType<A,T>::Type > Type;
+  };
+#endif
+
   /** @} */
 }
 #endif
diff --git a/doc/doxygen/Doxyfile b/doc/doxygen/Doxyfile
index 46548c5cd..f0e17a6c6 100644
--- a/doc/doxygen/Doxyfile
+++ b/doc/doxygen/Doxyfile
@@ -995,7 +995,7 @@ INCLUDE_FILE_PATTERNS  =
 # undefined via #undef or recursively expanded use the := operator 
 # instead of the = operator.
 
-PREDEFINED             = DOXYGEN HAVE_MPI:=1
+PREDEFINED             = DOXYGEN HAVE_MPI:=1 _DEBUG_ALLOCATOR_H:=1
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
 # this tag can be used to specify a list of macro names that should be expanded. 
-- 
GitLab