34#ifndef Foam_ListPolicy_H
35#define Foam_ListPolicy_H
130 && !std::is_pointer_v<T>
131 && !std::is_union_v<T>
139template<
class IntType>
142 return (
n >= IntType(200));
147template<
class IntType>
150 return (
n >= IntType(3000));
155template<
class IntType>
158 return (
n >= IntType(1000));
165 return std::align_val_t(256);
170template<
class T,
class IntType>
192 return new (pool_ptr)
T[
n];
214template<
class T,
class IntType>
234template<
class T,
class IntType>
235inline void deallocate(
T* ptr, [[maybe_unused]] IntType
n)
267template<
int SizeMin,
int Numerator,
class IntType>
268inline IntType
reserve_size(IntType requested, IntType capacity)
noexcept
270 static_assert(Numerator > 1,
"Invalid numerator");
275 IntType size(capacity*Numerator);
276 if (size < requested)
280 if constexpr (SizeMin > 0)
293template<
int SizeMin,
int Numerator,
int Denominator,
class IntType>
294inline IntType
reserve_size(IntType requested, IntType capacity)
noexcept
296 static_assert(Numerator > Denominator,
"Invalid numerator");
297 static_assert(Denominator > 0,
"Invalid denominator");
304 IntType size((capacity/Denominator)*Numerator);
305 if (size < requested)
309 if constexpr (SizeMin > 0)
333template<
class InputIt>
341 const auto& elem0 = *first;
343 for ((
void)++first; (first != last); (void)++first)
static void * try_allocate(std::size_t nbytes)
Allocate from pool (if active).
static bool try_deallocate(void *ptr)
Deallocate a pointer managed by the pool.
A class for handling keywords in dictionaries.
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
A class for handling words, derived from Foam::string.
Additional compile-time controls of List behaviour.
constexpr bool is_aligned_type() noexcept
Consider aligned allocation for the given type?
T * allocate(IntType n)
Allocate from memory pool (if active), or aligned, or normal.
constexpr bool use_memory_pool(IntType n) noexcept
True if size exceeds the min-size for using the memory pool.
constexpr bool use_offload(IntType n) noexcept
True if size exceeds the min-size for offloading.
IntType reserve_size(IntType requested, IntType capacity) noexcept
Calculate a reserve size (eg, doubling) based on the requested length and the current capacity.
void deallocate(T *ptr)
Deallocate from memory pool, or normal.
uniformity
Classification of list/container uniformity. The values can be used with bit-wise or reduction.
@ EMPTY
An empty container.
@ MIXED
Mixed uniform/non-uniform (eg, after reduction).
@ UNIFORM
Container (non-empty) with identical values.
@ NONUNIFORM
Container (non-empty) with different values.
enum uniformity check_uniformity(InputIt first, InputIt last)
Algorithm to determine list/container uniformity.
constexpr bool use_alignment(IntType n) noexcept
True if size exceeds the min-size for using memory alignment.
constexpr std::align_val_t default_alignment() noexcept
Default alignment for larger fields.
constexpr bool is_contiguous_v
The is_contiguous value of Type (after stripping of qualifiers).
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Can suppress additional line breaks separate ASCII data content when the data elements are primitives...
Number of items before requiring line-breaks in the list output.