28 #include <type_traits>
50 static_assert(std::is_nothrow_destructible_v<T>,
51 "This should be true for all types. Destructors are noexcept by default.");
55 if (std::is_trivially_destructible_v<T>) {
59 for (
int64_t i = 0; i < n; i++) {
81 if (std::is_trivially_constructible_v<T>) {
87 for (; current < n; current++) {
88 new (
static_cast<void *
>(
ptr + current))
T;
113 for (
int64_t i = 0; i < n; i++) {
136 for (; current < n; current++) {
137 new (
static_cast<void *
>(dst + current))
T(src[current]);
158 template<
typename From,
typename To>
165 for (; current < n; current++) {
166 new (
static_cast<void *
>(dst + current)) To(
static_cast<To
>(src[current]));
191 for (
int64_t i = 0; i < n; i++) {
192 dst[i] = std::move(src[i]);
214 for (; current < n; current++) {
215 new (
static_cast<void *
>(dst + current))
T(std::move(src[current]));
280 for (
int64_t i = 0; i < n; i++) {
301 for (; current < n; current++) {
302 new (
static_cast<void *
>(dst + current))
T(value);
322 template<
typename T>
using destruct_ptr = std::unique_ptr<T, DestructValueAtAddress<T>>;
328 template<
size_t Size,
size_t Alignment>
class alignas(Alignment)
AlignedBuffer {
331 char buffer_[(Size > 0) ? Size : 1];
339 operator const void *()
const
367 return static_cast<T *
>(buffer_.ptr());
370 operator const T *()
const
372 return static_cast<const T *
>(buffer_.ptr());
377 return *
static_cast<T *
>(buffer_.ptr());
382 return *
static_cast<const T *
>(buffer_.ptr());
387 return static_cast<T *
>(buffer_.ptr());
392 return static_cast<const T *
>(buffer_.ptr());
397 return *
static_cast<T *
>(buffer_.ptr());
402 return *
static_cast<const T *
>(buffer_.ptr());
412 template<
size_t ReservedSize = 64,
size_t ReservedAlignment = 64>
416 char reserved_buffer_[(ReservedSize > 0) ? ReservedSize : 1];
424 if (
size <= ReservedSize && alignment <= ReservedAlignment) {
425 buffer_ = reserved_buffer_;
433 if (buffer_ != reserved_buffer_) {
471 template<
typename From,
typename To>
473 std::is_convertible_v<From, To> &&std::is_pointer_v<From> &&std::is_pointer_v<To>;
481 template<
typename From,
typename To>
484 std::is_pointer_v<From> &&std::is_pointer_v<To> &&
486 std::is_same_v<From, To> ||
488 std::is_same_v<const std::remove_pointer_t<From>, std::remove_pointer_t<To>> ||
490 (!std::is_const_v<std::remove_pointer_t<From>> && std::is_same_v<To, void *>) ||
492 std::is_same_v<To, const void *>);
500 return (
static_cast<int64_t>(element_size) < 100) ? 4 : 0;
514 Container container_copy{src};
515 dst = std::move(container_copy);
524 template<
typename Container>
526 std::is_nothrow_move_constructible_v<Container>)
533 if constexpr (std::is_nothrow_move_constructible_v<Container>) {
534 new (&dst) Container(std::move(src));
538 new (&dst) Container(std::move(src));
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
DynamicStackBuffer & operator=(const DynamicStackBuffer &other)=delete
DynamicStackBuffer(const DynamicStackBuffer &other)=delete
DynamicStackBuffer(const int64_t size, const int64_t alignment)
DynamicStackBuffer(DynamicStackBuffer &&other)=delete
DynamicStackBuffer & operator=(DynamicStackBuffer &&other)=delete
const T & operator*() const
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN_aligned)(size_t len, size_t alignment, const char *str)
Container & move_assign_container(Container &dst, Container &&src) noexcept(std::is_nothrow_move_constructible_v< Container >)
void default_construct_n(T *ptr, int64_t n)
void initialized_relocate_n(T *src, int64_t n, T *dst)
Container & copy_assign_container(Container &dst, const Container &src)
std::unique_ptr< T, DestructValueAtAddress< T > > destruct_ptr
void initialized_fill_n(T *dst, int64_t n, const T &value)
void initialized_move_n(T *src, int64_t n, T *dst)
constexpr bool is_convertible_pointer_v
constexpr int64_t default_inline_buffer_capacity(size_t element_size)
void uninitialized_fill_n(T *dst, int64_t n, const T &value)
void uninitialized_relocate_n(T *src, int64_t n, T *dst)
void initialized_copy_n(const T *src, int64_t n, T *dst)
void uninitialized_convert_n(const From *src, int64_t n, To *dst)
void destruct_n(T *ptr, int64_t n)
constexpr bool is_span_convertible_pointer_v
void uninitialized_copy_n(const T *src, int64_t n, T *dst)
void uninitialized_move_n(T *src, int64_t n, T *dst)