Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions include/beman/execution/detail/allocator_of.hpp

This file was deleted.

28 changes: 0 additions & 28 deletions include/beman/execution/detail/error_types_of.hpp

This file was deleted.

20 changes: 10 additions & 10 deletions include/beman/execution/detail/find_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@
#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_FIND_ALLOCATOR
#define INCLUDED_BEMAN_EXECUTION_DETAIL_FIND_ALLOCATOR

#include <beman/execution/detail/common.hpp>
#ifdef BEMAN_HAS_IMPORT_STD
import std;
#else
#include <concepts>
#include <memory>
#endif

// ----------------------------------------------------------------------------

namespace beman::execution::detail {
/*!
* \brief Utility locating an allocator_arg/allocator pair
* \headerfile beman/execution/task.hpp <beman/execution/task.hpp>
* \internal
*/
Comment on lines -13 to -17

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this? I don't think it is wrong.

template <typename Allocator>
Allocator find_allocator() {
Allocator find_allocator() noexcept {
return Allocator();
}
template <typename Allocator>
Allocator find_allocator(const std::allocator_arg_t&) {
Allocator find_allocator(const ::std::allocator_arg_t&) noexcept {
static_assert(
requires {
{ Allocator() } -> std::same_as<void>;
{ Allocator() } -> ::std::same_as<void>;
}, "There needs to be an allocator argument following std::allocator_arg");
return Allocator();
}

template <typename Allocator, typename Alloc, typename... A>
Allocator find_allocator(const std::allocator_arg_t&, const Alloc& alloc, const A&...) {
Allocator find_allocator(const ::std::allocator_arg_t&, const Alloc& alloc, const A&...) noexcept {
static_assert(
requires(const Alloc& a) { Allocator(a); },
"The allocator needs to be constructible from the argument following std::allocator");
return Allocator(alloc);
}
template <typename Allocator, typename A0, typename... A>
Allocator find_allocator(A0 const&, const A&... a) {
Allocator find_allocator(A0 const&, const A&... a) noexcept {
return ::beman::execution::detail::find_allocator<Allocator>(a...);
}

Expand Down
49 changes: 0 additions & 49 deletions include/beman/execution/detail/handle.hpp

This file was deleted.

33 changes: 33 additions & 0 deletions include/beman/execution/detail/meta_index.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// include/beman/execution/detail/meta_index.hpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_META_INDEX
#define INCLUDED_BEMAN_EXECUTION_DETAIL_META_INDEX

#include <beman/execution/detail/common.hpp>
#ifdef BEMAN_HAS_IMPORT_STD
import std;
#else
#include <cstddef>
#endif

// ----------------------------------------------------------------------------

namespace beman::execution::detail::meta {
template <::std::size_t, typename, typename>
struct index {
static constexpr ::std::size_t value = static_cast<::std::size_t>(-1);
};
template <::std::size_t I, template <typename...> class L, typename First, typename... Rest, typename T>
struct index<I, L<First, Rest...>, T> : index<I + 1uz, L<Rest...>, T> {};
template <::std::size_t I, template <typename...> class L, typename... Rest, typename T>
struct index<I, L<T, Rest...>, T> {
static constexpr ::std::size_t value = I;
};
template <typename List, typename T>
inline constexpr ::std::size_t index_v{::beman::execution::detail::meta::index<0uz, List, T>::value};
} // namespace beman::execution::detail::meta

// ----------------------------------------------------------------------------

#endif // INCLUDED_BEMAN_EXECUTION_DETAIL_META_INDEX
45 changes: 45 additions & 0 deletions include/beman/execution/detail/new_object.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// include/beman/execution/detail/new_object.hpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef INCLUDED_INCLUDE_BEMAN_EXECUTION_DETAIL_NEW_OBJECT
#define INCLUDED_INCLUDE_BEMAN_EXECUTION_DETAIL_NEW_OBJECT

#include <beman/execution/detail/common.hpp>
#ifdef BEMAN_HAS_IMPORT_STD
import std;
#else
#include <memory>
#include <utility>
#endif

// ----------------------------------------------------------------------------

namespace beman::execution::detail {
template <typename T, typename Allocator, typename... Args>
[[nodiscard]] auto new_object(const Allocator& allocator, Args&&... args) -> T* {
using alloc_t = typename ::std::allocator_traits<Allocator>::template rebind_alloc<T>;
using alloc_traits = ::std::allocator_traits<alloc_t>;
alloc_t alloc(allocator);
auto ptr = alloc_traits::allocate(alloc, 1);
try {
alloc_traits::construct(alloc, ptr, ::std::forward<Args>(args)...);
return ptr;
} catch (...) {
alloc_traits::deallocate(alloc, ptr, 1);
throw;
}
}

template <typename Allocator, typename T>
auto delete_object(const Allocator& allocator, T* ptr) noexcept -> void {
using alloc_t = typename ::std::allocator_traits<Allocator>::template rebind_alloc<T>;
using alloc_traits = ::std::allocator_traits<alloc_t>;
alloc_t alloc(allocator);
alloc_traits::destroy(alloc, ptr);
alloc_traits::deallocate(alloc, ptr, 1);
}
} // namespace beman::execution::detail

// ----------------------------------------------------------------------------

#endif // INCLUDED_INCLUDE_BEMAN_EXECUTION_DETAIL_NEW_OBJECT
Loading
Loading