[wpiutil] Update to foonathan memory 0.7-3 (#5573)

This commit is contained in:
Tyler Veness
2023-08-28 15:03:36 -07:00
committed by GitHub
parent 0d2d989e84
commit 969979d6c7
63 changed files with 196 additions and 261 deletions

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_ALIGNED_ALLOCATOR_HPP_INCLUDED
#define WPI_MEMORY_ALIGNED_ALLOCATOR_HPP_INCLUDED
@@ -52,7 +51,7 @@ namespace wpi
aligned_allocator& operator=(aligned_allocator&& other) noexcept
{
allocator_type::operator=(detail::move(other));
min_alignment_ = other.min_alignment_;
min_alignment_ = other.min_alignment_;
return *this;
}
/// @}

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_ALLOCATOR_STORAGE_HPP_INCLUDED
#define WPI_MEMORY_ALLOCATOR_STORAGE_HPP_INCLUDED
@@ -126,7 +125,7 @@ namespace wpi
WPI_REQUIRES(
(!std::is_base_of<allocator_storage, typename std::decay<Alloc>::type>::value))>
allocator_storage(Alloc&& alloc,
WPI_SFINAE(new storage_policy(detail::forward<Alloc>(alloc))))
WPI_SFINAE(new storage_policy(std::declval<Alloc>())))
: storage_policy(detail::forward<Alloc>(alloc))
{
}
@@ -136,8 +135,10 @@ namespace wpi
/// \requires The expression <tt>new storage_policy(other.get_allocator())</tt> must be well-formed,
/// otherwise this constructor does not participate in overload resolution.
template <class OtherPolicy>
allocator_storage(const allocator_storage<OtherPolicy, Mutex>& other,
WPI_SFINAE(new storage_policy(other.get_allocator())))
allocator_storage(
const allocator_storage<OtherPolicy, Mutex>& other,
WPI_SFINAE(new storage_policy(
std::declval<const allocator_storage<OtherPolicy, Mutex>&>().get_allocator())))
: storage_policy(other.get_allocator())
{
}
@@ -165,7 +166,7 @@ namespace wpi
/// @{
/// \effects Copies the \c allocator_storage object.
/// \requires The \c StoragePolicy must be copyable.
allocator_storage(const allocator_storage&) = default;
allocator_storage(const allocator_storage&) = default;
allocator_storage& operator=(const allocator_storage&) = default;
/// @}
@@ -296,9 +297,9 @@ namespace wpi
return detail::lock_allocator(get_allocator(), static_cast<actual_mutex&>(*this));
}
auto lock() const noexcept -> WPI_IMPL_DEFINED(decltype(
detail::lock_allocator(std::declval<const storage_policy>().get_allocator(),
std::declval<actual_mutex&>())))
auto lock() const noexcept -> WPI_IMPL_DEFINED(decltype(detail::lock_allocator(
std::declval<const storage_policy>().get_allocator(),
std::declval<actual_mutex&>())))
{
return detail::lock_allocator(get_allocator(), static_cast<actual_mutex&>(*this));
}
@@ -552,9 +553,9 @@ namespace wpi
{
using storage = detail::reference_storage_impl<
typename allocator_traits<RawAllocator>::allocator_type,
decltype(
detail::reference_type(typename allocator_traits<RawAllocator>::is_stateful{},
is_shared_allocator<RawAllocator>{}))>;
decltype(detail::reference_type(typename allocator_traits<
RawAllocator>::is_stateful{},
is_shared_allocator<RawAllocator>{}))>;
public:
using allocator_type = typename allocator_traits<RawAllocator>::allocator_type;
@@ -580,7 +581,7 @@ namespace wpi
/// @{
/// \effects Copies the \c allocator_reference object.
/// Only copies the pointer to it in the stateful case.
reference_storage(const reference_storage&) noexcept = default;
reference_storage(const reference_storage&) noexcept = default;
reference_storage& operator=(const reference_storage&) noexcept = default;
/// @}
@@ -795,9 +796,9 @@ namespace wpi
: public base_allocator,
private detail::reference_storage_impl<
typename allocator_traits<RawAllocator>::allocator_type,
decltype(
detail::reference_type(typename allocator_traits<RawAllocator>::is_stateful{},
is_shared_allocator<RawAllocator>{}))>
decltype(detail::reference_type(typename allocator_traits<
RawAllocator>::is_stateful{},
is_shared_allocator<RawAllocator>{}))>
{
using traits = allocator_traits<RawAllocator>;
using composable = is_composable_allocator<typename traits::allocator_type>;
@@ -805,7 +806,7 @@ namespace wpi
typename allocator_traits<RawAllocator>::allocator_type,
decltype(detail::reference_type(typename allocator_traits<
RawAllocator>::is_stateful{},
is_shared_allocator<RawAllocator>{}))>;
is_shared_allocator<RawAllocator>{}))>;
public:
// non stateful

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_ALLOCATOR_TRAITS_HPP_INCLUDED
#define WPI_MEMORY_ALLOCATOR_TRAITS_HPP_INCLUDED
@@ -375,12 +374,12 @@ namespace wpi
template <typename T>
struct has_invalid_alloc_function
: std::is_same<decltype(
traits_detail::allocate_node(traits_detail::full_concept{},
std::declval<typename allocator_traits<
T>::allocator_type&>(),
0, 0)),
traits_detail::error>
: std::is_same<
decltype(traits_detail::allocate_node(traits_detail::full_concept{},
std::declval<typename allocator_traits<
T>::allocator_type&>(),
0, 0)),
traits_detail::error>
{
};
@@ -564,13 +563,12 @@ namespace wpi
template <typename T>
struct has_invalid_try_dealloc_function
: std::is_same<
decltype(
traits_detail::try_deallocate_node(traits_detail::full_concept{},
std::declval<typename allocator_traits<
T>::allocator_type&>(),
nullptr, 0, 0)),
traits_detail::error>
: std::is_same<decltype(traits_detail::
try_deallocate_node(traits_detail::full_concept{},
std::declval<typename allocator_traits<
T>::allocator_type&>(),
nullptr, 0, 0)),
traits_detail::error>
{
};

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
/// \file
/// Configuration macros.
@@ -140,7 +139,7 @@
/// Set to `1` to disable automatic lifetime managment of the per-thread stack,
/// requires managing it through the \ref wpi::memory::temporary_stack_initializer.
/// Set to `0` to disable the per-thread stack completely.
/// \ref get_temporary_stack() will abort the program upon call.
/// \ref wpi::memory::get_temporary_stack() will abort the program upon call.
/// \ingroup allocator
#define WPI_MEMORY_TEMPORARY_STACK_MODE 2
#endif

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_CONTAINER_HPP_INCLUDED
#define WPI_MEMORY_CONTAINER_HPP_INCLUDED
@@ -276,8 +275,9 @@ namespace wpi
/// @{
/// Contains the node size of a node based STL container with a specific type.
/// These classes are auto-generated and only available if the tools are build and without
/// cross-compiling.
///
/// This trait is auto-generated and may not be available depending on the build configuration,
/// especially when doing cross compilation.
template <typename T>
struct forward_list_node_size : std::integral_constant<std::size_t, implementation_defined>
{
@@ -314,25 +314,30 @@ namespace wpi
{
};
/// \copydoc forward_list_node_size
/// Contains the node size of a node based STL container with a specific type.
///
/// This trait is auto-generated and may not be available depending on the build configuration,
/// especially when doing cross compilation.
///
/// \notes `T` is always the `value_type` of the container, e.g. `std::pair<const Key, Value>`.
template <typename T>
struct map_node_size : std::integral_constant<std::size_t, implementation_defined>
{
};
/// \copydoc forward_list_node_size
/// \copydoc map_node_size
template <typename T>
struct multimap_node_size : std::integral_constant<std::size_t, implementation_defined>
{
};
/// \copydoc forward_list_node_size
/// \copydoc map_node_size
template <typename T>
struct unordered_map_node_size : std::integral_constant<std::size_t, implementation_defined>
{
};
/// \copydoc forward_list_node_size
/// \copydoc map_node_size
template <typename T>
struct unordered_multimap_node_size
: std::integral_constant<std::size_t, implementation_defined>

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_DEBUGGING_HPP_INCLUDED
#define WPI_MEMORY_DEBUGGING_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_DEFAULT_ALLOCATOR_HPP_INCLUDED
#define WPI_MEMORY_DEFAULT_ALLOCATOR_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_DELETER_HPP_INCLUDED
#define WPI_MEMORY_DELETER_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_DETAIL_ALIGN_HPP_INCLUDED
#define WPI_MEMORY_DETAIL_ALIGN_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_DETAIL_ASSERT_HPP_INCLUDED
#define WPI_MEMORY_DETAIL_ASSERT_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_DETAIL_CONTAINER_NODE_SIZES_HPP_INCLUDED
#define WPI_MEMORY_DETAIL_CONTAINER_NODE_SIZES_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_DEBUG_HELPERS_HPP_INCLUDED
#define WPI_MEMORY_DEBUG_HELPERS_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_DETAIL_EBO_STORAGE_HPP_INCLUDED
#define WPI_MEMORY_DETAIL_EBO_STORAGE_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_DETAILL_FREE_LIST_HPP_INCLUDED
#define WPI_MEMORY_DETAILL_FREE_LIST_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_DETAIL_FREE_LIST_ARRAY_HPP
#define WPI_MEMORY_DETAIL_FREE_LIST_ARRAY_HPP

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_DETAIL_ILOG2_HPP_INCLUDED
#define WPI_MEMORY_DETAIL_ILOG2_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_DETAIL_LOWLEVEL_ALLOCATOR_HPP_INCLUDED
#define WPI_MEMORY_DETAIL_LOWLEVEL_ALLOCATOR_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_DETAIL_MEMORY_STACK_HPP_INCLUDED
#define WPI_MEMORY_DETAIL_MEMORY_STACK_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_DETAIL_SMALL_FREE_LIST_HPP_INCLUDED
#define WPI_MEMORY_DETAIL_SMALL_FREE_LIST_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_DETAIL_UTILITY_HPP
#define WPI_MEMORY_DETAIL_UTILITY_HPP

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
/// \file
/// The exception classes.

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_FALLBACK_ALLOCATOR_HPP_INCLUDED
#define WPI_MEMORY_FALLBACK_ALLOCATOR_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_HEAP_ALLOCATOR_HPP_INCLUDED
#define WPI_MEMORY_HEAP_ALLOCATOR_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_ITERATION_ALLOCATOR_HPP_INCLUDED
#define WPI_MEMORY_ITERATION_ALLOCATOR_HPP_INCLUDED
@@ -77,8 +76,8 @@ namespace wpi
iteration_allocator& operator=(iteration_allocator&& other) noexcept
{
allocator_type::operator=(detail::move(other));
block_ = other.block_;
cur_ = other.cur_;
block_ = other.block_;
cur_ = other.cur_;
for (auto i = 0u; i != N; ++i)
stacks_[i] = detail::move(other.stacks_[i]);

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_JOINT_ALLOCATOR_HPP_INCLUDED
#define WPI_MEMORY_JOINT_ALLOCATOR_HPP_INCLUDED
@@ -515,7 +514,7 @@ namespace wpi
{
}
joint_allocator(const joint_allocator& other) noexcept = default;
joint_allocator(const joint_allocator& other) noexcept = default;
joint_allocator& operator=(const joint_allocator& other) noexcept = default;
/// \effects Allocates a node with given properties.
@@ -709,7 +708,7 @@ namespace wpi
}
joint_array& operator=(const joint_array&) = delete;
joint_array& operator=(joint_array&&) = delete;
joint_array& operator=(joint_array&&) = delete;
//=== accessors ===//
/// @{
@@ -810,7 +809,7 @@ namespace wpi
stack_->unwind(objects_);
}
builder(builder&&) = delete;
builder(builder&&) = delete;
builder& operator=(builder&&) = delete;
template <typename... Args>

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_MALLOC_ALLOCATOR_HPP_INCLUDED
#define WPI_MEMORY_MALLOC_ALLOCATOR_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_MEMORY_ARENA_HPP_INCLUDED
#define WPI_MEMORY_MEMORY_ARENA_HPP_INCLUDED
@@ -548,7 +547,7 @@ namespace wpi
if (block_size_)
{
auto mem = traits::allocate_array(get_allocator(), block_size_, 1,
detail::max_alignment);
detail::max_alignment);
memory_block block(mem, block_size_);
block_size_ = 0u;
return block;

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_MEMORY_POOL_HPP_INCLUDED
#define WPI_MEMORY_MEMORY_POOL_HPP_INCLUDED
@@ -103,8 +102,8 @@ namespace wpi
memory_pool& operator=(memory_pool&& other) noexcept
{
leak_checker::operator=(detail::move(other));
arena_ = detail::move(other.arena_);
free_list_ = detail::move(other.free_list_);
arena_ = detail::move(other.arena_);
free_list_ = detail::move(other.free_list_);
return *this;
}
/// @}

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_MEMORY_POOL_COLLECTION_HPP_INCLUDED
#define WPI_MEMORY_MEMORY_POOL_COLLECTION_HPP_INCLUDED
@@ -76,8 +75,7 @@ namespace wpi
/// the size of the initial memory block and other constructor arguments for the \concept{concept_blockallocator,BlockAllocator}.
/// The \c BucketDistribution controls how many free lists are created,
/// but unlike in \ref memory_pool all free lists are initially empty and the first memory block queued.
/// \requires \c max_node_size must be a valid \concept{concept_node,node} size
/// and \c block_size must be non-zero.
/// \requires \c block_size must be non-zero and \c max_node_size must be a valid \concept{concept_node,node} size and smaller than \c block_size divided by the number of pools.
template <typename... Args>
memory_pool_collection(std::size_t max_node_size, std::size_t block_size,
Args&&... args)
@@ -85,6 +83,7 @@ namespace wpi
stack_(allocate_block()),
pools_(stack_, block_end(), max_node_size)
{
detail::check_allocation_size<bad_node_size>(max_node_size, def_capacity(), info());
}
/// \effects Destroys the \ref memory_pool_collection by returning all memory blocks,
@@ -107,9 +106,9 @@ namespace wpi
memory_pool_collection& operator=(memory_pool_collection&& other) noexcept
{
leak_checker::operator=(detail::move(other));
arena_ = detail::move(other.arena_);
stack_ = detail::move(other.stack_);
pools_ = detail::move(other.pools_);
arena_ = detail::move(other.arena_);
stack_ = detail::move(other.stack_);
pools_ = detail::move(other.pools_);
return *this;
}
/// @}

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_MEMORY_POOL_TYPE_HPP_INCLUDED
#define WPI_MEMORY_MEMORY_POOL_TYPE_HPP_INCLUDED
@@ -28,7 +27,7 @@ namespace wpi
};
/// Tag type defining a memory pool optimized for arrays.
/// It keeps the nodes oredered inside the free list and searches the list for an appropriate memory block.
/// It keeps the nodes ordered inside the free list and searches the list for an appropriate memory block.
/// Array allocations are still pretty slow, if the array gets big enough it can get slower than \c new.
/// Node allocations are still fast, unless there is deallocation in random order.
/// \note Use this tag type only if you really need to have a memory pool!

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_MEMORY_RESOURCE_ADAPTER_HPP_INCLUDED
#define WPI_MEMORY_MEMORY_RESOURCE_ADAPTER_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_MEMORY_STACK_HPP_INCLUDED
#define WPI_MEMORY_MEMORY_STACK_HPP_INCLUDED
@@ -203,7 +202,8 @@ namespace wpi
arena_.deallocate_block();
detail::debug_check_pointer(
[&] {
[&]
{
auto cur = arena_.current_block();
return m.end == static_cast<char*>(cur.memory) + cur.size;
},

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_NAMESPACE_ALIAS_HPP_INCLUDED
#define WPI_MEMORY_NAMESPACE_ALIAS_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_NEW_ALLOCATOR_HPP_INCLUDED
#define WPI_MEMORY_NEW_ALLOCATOR_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_SEGREGATOR_HPP_INCLUDED
#define WPI_MEMORY_SEGREGATOR_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_SMART_PTR_HPP_INCLUDED
#define WPI_MEMORY_SMART_PTR_HPP_INCLUDED
@@ -192,18 +191,6 @@ namespace wpi
detail::forward<RawAllocator>(alloc)),
detail::forward<Args>(args)...);
}
#if !defined(DOXYGEN)
#include "detail/container_node_sizes.hpp"
#else
/// Contains the node size needed for a `std::shared_ptr`.
/// These classes are auto-generated and only available if the tools are build and without cross-compiling.
/// \ingroup adapter
template <typename T>
struct shared_ptr_node_size : std::integral_constant<std::size_t, implementation_defined>
{
};
#endif
} // namespace memory
} // namespace wpi

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_STATIC_ALLOCATOR_HPP_INCLUDED
#define WPI_MEMORY_STATIC_ALLOCATOR_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_STD_ALLOCATOR_HPP_INCLUDED
#define WPI_MEMORY_STD_ALLOCATOR_HPP_INCLUDED
@@ -134,7 +133,8 @@ namespace wpi
// MSVC seems to ignore access rights in decltype SFINAE below
// use this to prevent this constructor being chosen instead of move/copy for types inheriting from it
WPI_REQUIRES((!std::is_base_of<std_allocator, RawAlloc>::value))>
std_allocator(RawAlloc& alloc, WPI_SFINAE(alloc_reference(alloc))) noexcept
std_allocator(RawAlloc& alloc,
WPI_SFINAE(alloc_reference(std::declval<RawAlloc&>()))) noexcept
: alloc_reference(alloc)
{
}
@@ -149,7 +149,8 @@ namespace wpi
// MSVC seems to ignore access rights in decltype SFINAE below
// use this to prevent this constructor being chosen instead of move/copy for types inheriting from it
WPI_REQUIRES((!std::is_base_of<std_allocator, RawAlloc>::value))>
std_allocator(const RawAlloc& alloc, WPI_SFINAE(alloc_reference(alloc))) noexcept
std_allocator(const RawAlloc& alloc, WPI_SFINAE(alloc_reference(
std::declval<const RawAlloc&>()))) noexcept
: alloc_reference(alloc)
{
}

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_TEMPORARY_ALLOCATOR_HPP_INCLUDED
#define WPI_MEMORY_TEMPORARY_ALLOCATOR_HPP_INCLUDED
@@ -195,7 +194,7 @@ namespace wpi
/// \effects Destroys the per-thread stack if it isn't already destroyed.
~temporary_stack_initializer() noexcept;
temporary_stack_initializer(temporary_stack_initializer&&) = delete;
temporary_stack_initializer(temporary_stack_initializer&&) = delete;
temporary_stack_initializer& operator=(temporary_stack_initializer&&) = delete;
};
@@ -229,7 +228,7 @@ namespace wpi
~temporary_allocator() noexcept;
temporary_allocator(temporary_allocator&&) = delete;
temporary_allocator(temporary_allocator&&) = delete;
temporary_allocator& operator=(temporary_allocator&&) = delete;
/// \effects Allocates memory from the internal \ref memory_stack by forwarding to it.

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_THREADING_HPP_INCLUDED
#define WPI_MEMORY_THREADING_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_TRACKING_HPP_INCLUDED
#define WPI_MEMORY_TRACKING_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_VIRTUAL_MEMORY_HPP_INCLUDED
#define WPI_MEMORY_VIRTUAL_MEMORY_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/debugging.hpp"

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/detail/align.hpp"

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/detail/assert.hpp"

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/detail/debug_helpers.hpp"

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/detail/free_list.hpp"

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/detail/free_list_array.hpp"

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#ifndef WPI_MEMORY_SRC_DETAIL_FREE_LIST_UTILS_HPP_INCLUDED
#define WPI_MEMORY_SRC_DETAIL_FREE_LIST_UTILS_HPP_INCLUDED

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/detail/small_free_list.hpp"

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/error.hpp"

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/heap_allocator.hpp"

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/iteration_allocator.hpp"

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/config.hpp"
#if WPI_HOSTED_IMPLEMENTATION

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/memory_arena.hpp"
@@ -42,7 +41,7 @@ bool memory_block_stack::owns(const void* ptr) const noexcept
auto address = static_cast<const char*>(ptr);
for (auto cur = head_; cur; cur = cur->prev)
{
auto mem = static_cast<char*>(static_cast<void*>(cur));
auto mem = static_cast<char*>(static_cast<void*>(cur)) + implementation_offset();
if (address >= mem && address < mem + cur->usable_size)
return true;
}

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/memory_pool.hpp"

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/memory_pool_collection.hpp"

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/memory_stack.hpp"

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/new_allocator.hpp"

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/static_allocator.hpp"
@@ -38,9 +37,9 @@ memory_block static_block_allocator::allocate_block()
void static_block_allocator::deallocate_block(memory_block block) noexcept
{
detail::
debug_check_pointer([&] { return static_cast<char*>(block.memory) + block.size == cur_; },
info(), block.memory);
detail::debug_check_pointer([&]
{ return static_cast<char*>(block.memory) + block.size == cur_; },
info(), block.memory);
cur_ -= block_size_;
}

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/temporary_allocator.hpp"
@@ -216,9 +215,8 @@ temporary_stack& wpi::memory::get_temporary_stack(std::size_t initial_size)
namespace
{
WPI_THREAD_LOCAL alignas(
temporary_stack) char temporary_stack_storage[sizeof(temporary_stack)];
WPI_THREAD_LOCAL bool is_created = false;
thread_local alignas(temporary_stack) char temporary_stack_storage[sizeof(temporary_stack)];
thread_local bool is_created = false;
temporary_stack& get() noexcept
{

View File

@@ -1,6 +1,5 @@
// Copyright (C) 2015-2021 Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
// SPDX-License-Identifier: Zlib
#include "wpi/memory/virtual_memory.hpp"