Debian Codegraph @

dune/istl/allocator.hh

raw
1 // SPDX-FileCopyrightText: Copyright © 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>
19 struct DefaultAllocatorTraits
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>
34 using AllocatorType = typename AllocatorTraits<T>::type;
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