diff --git a/common/typetraits.hh b/common/typetraits.hh index 7de0ec144d8a1eae93058cd84c51b5fafb477b15..9e532dc738da73d31631b09e3e690f8e953ba07d 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 46548c5cd038ae07d4cf4e494ddfcf3898061ae8..f0e17a6c648b361f1c24a861bd1a038cfb59ce81 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.