21#ifndef EWOMS_ALIGNED_ALLOCATOR_HH
22#define EWOMS_ALIGNED_ALLOCATOR_HH
34constexpr inline bool is_alignment(std::size_t value)
noexcept
36 return (value > 0) && ((value & (value - 1)) == 0);
39template<std::
size_t N>
41 : std::integral_constant<bool, (N > 0) && ((N & (N - 1)) == 0)>
44template<std::
size_t A, std::
size_t B>
46 : std::integral_constant<std::size_t, (A < B) ? A : B>
58 : min_size<sizeof(T), sizeof(offset_object<T>) - sizeof(T)>::type
61template<std::size_t A, std::size_t B>
63 : std::integral_constant<std::size_t,(A > B) ? A : B>
68 : std::integral_constant<std::size_t, ~static_cast<std::size_t>(0) / sizeof(T)>
75inline void* aligned_alloc(std::size_t
alignment,
76 std::size_t size)
noexcept
89inline void aligned_free(
void*
ptr)
95template<
class T, std::
size_t Alignment>
101 using value_type = T;
103 using const_pointer =
const T*;
104 using void_pointer =
void*;
105 using const_void_pointer =
const void*;
106 using size_type = std::size_t;
107 using difference_type = std::ptrdiff_t;
108 using reference = T&;
109 using const_reference =
const T&;
128 pointer address(reference value)
const noexcept
130 return detail::addressof(value);
133 const_pointer address(const_reference value)
const noexcept
135 return detail::addressof(value);
138 pointer allocate(size_type size,
139 const_void_pointer = 0)
141 void*
p = aligned_alloc(MaxAlign::value,
143 if (!
p && size > 0) {
144 throw std::bad_alloc();
146 return static_cast<T*
>(
p);
149 void deallocate(pointer
ptr, size_type)
156 return detail::max_count_of<T>::value;
159 template<
class U,
class...
Args>
160 void construct(
U*
ptr,
Args&&... args)
163 ::new(
p)
U(std::forward<Args>(args)...);
167 void construct(
U*
ptr)
181template<std::
size_t Alignment>
185 "The specified alignment is not a power of two!");
188 using value_type =
void;
189 using pointer =
void*;
190 using const_pointer =
const void*;
199template<
class T1,
class T2, std::
size_t Alignment>
207template<
class T1,
class T2, std::
size_t Alignment>
208inline bool operator!=(
const aligned_allocator<
T1,
Definition alignedallocator.hh:97
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:240
Definition alignedallocator.hh:117
Definition alignedallocator.hh:42
Definition alignedallocator.hh:64
Definition alignedallocator.hh:69
Definition alignedallocator.hh:47