dune-istl  2.9.0
allocator.hh
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3 #ifndef DUNE_ISTL_ALLOCATOR_HH
4 #define DUNE_ISTL_ALLOCATOR_HH
5 
6 #include <memory>
7 #include <type_traits>
8 
9 #include <dune/common/typetraits.hh>
10 
11 namespace Dune {
12 
13  template<typename T>
14  struct exists{
15  static const bool value = true;
16  };
17 
18  template<typename T, typename = void>
20  {
21  using type = std::allocator<T>;
22  };
23 
24  template<typename T>
25  struct DefaultAllocatorTraits<T, std::void_t<typename T::allocator_type> >
26  {
27  using type = typename T::allocator_type;
28  };
29 
30  template<typename T>
31  struct AllocatorTraits : public DefaultAllocatorTraits<T> {};
32 
33  template<typename T>
35 
36  template<typename T, typename X>
37  using ReboundAllocatorType = typename std::allocator_traits<typename AllocatorTraits<T>::type>::template rebind_alloc<X>;
38 
39 } // end namespace Dune
40 
41 #endif // DUNE_ISTL_ALLOCATOR_HH
Definition: allocator.hh:11
typename std::allocator_traits< typename AllocatorTraits< T >::type >::template rebind_alloc< X > ReboundAllocatorType
Definition: allocator.hh:37
typename AllocatorTraits< T >::type AllocatorType
Definition: allocator.hh:34
Definition: allocator.hh:14
static const bool value
Definition: allocator.hh:15
Definition: allocator.hh:20
std::allocator< T > type
Definition: allocator.hh:21
typename T::allocator_type type
Definition: allocator.hh:27
Definition: allocator.hh:31