Skip to content
Snippets Groups Projects
Commit 8da92ce1 authored by Christian Engwer's avatar Christian Engwer
Browse files

[fix] use allocator traits to support containes with and without allocators

parent 1df1e0e5
No related branches found
No related tags found
1 merge request!87[multirhstest] Check with AlignedNumber.
Pipeline #
#ifndef DUNE_ISTL_ALLOCATOR_HH
#define DUNE_ISTL_ALLOCATOR_HH
#include <dune/common/typetraits.hh>
#include <memory>
namespace Dune {
template<typename T>
struct exists{
static const bool value = true;
};
template<typename T, typename = void>
struct DefaultAllocatorTraits
{
using type = std::allocator<T>;
};
template<typename T>
struct DefaultAllocatorTraits<T, void_t<typename T::allocator_type> >
{
using type = typename T::allocator_type;
};
template<typename T>
struct AllocatorTraits : public DefaultAllocatorTraits<T> {};
template<typename T>
using AllocatorType = typename AllocatorTraits<T>::type;
template<typename T, typename X>
using ReboundAllocatorType = typename AllocatorTraits<T>::type::template rebind<X>::other;
} // end namespace Dune
#endif // DUNE_ISTL_ALLOCATOR_HH
......@@ -14,6 +14,7 @@
#include <array>
#include <type_traits>
#include "allocator.hh"
#include "istlexception.hh"
#include "operators.hh"
#include "scalarproducts.hh"
......@@ -907,11 +908,9 @@ namespace Dune {
using typename IterativeSolver<X,X>::scalar_real_type;
//! \bief field_type Allocator retrieved from domain type
using fAlloc =
typename X::allocator_type::template rebind<field_type>::other;
using fAlloc = ReboundAllocatorType<X,field_type>;
//! \bief real_type Allocator retrieved from domain type
using rAlloc =
typename X::allocator_type::template rebind<real_type>::other;
using rAlloc = ReboundAllocatorType<X,real_type>;
public:
......@@ -1235,7 +1234,8 @@ namespace Dune {
using typename IterativeSolver<X,X>::scalar_real_type;
//! \bief field_type Allocator retrieved from domain type
typedef typename X::allocator_type::template rebind<field_type>::other fAlloc;
using fAlloc = ReboundAllocatorType<X,field_type>;
public:
/*!
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment