14 #include <type_traits>
28 std::is_trivially_destructible_v<T>;
31 is_trivial_extended_v<T> || std::is_trivially_copy_constructible_v<T>;
34 is_trivial_extended_v<T> || std::is_trivially_move_constructible_v<T>;
51 static_assert(std::is_nothrow_destructible_v<T>,
52 "This should be true for all types. Destructors are noexcept by default.");
56 if (is_trivially_destructible_extended_v<T>) {
60 for (
int64_t i = 0; i < n; i++) {
82 if (std::is_trivially_constructible_v<T>) {
88 for (; current < n; current++) {
89 new (
static_cast<void *
>(
ptr + current))
T;
114 for (
int64_t i = 0; i < n; i++) {
137 for (; current < n; current++) {
138 new (
static_cast<void *
>(dst + current))
T(
src[current]);
159 template<
typename From,
typename To>
166 for (; current < n; current++) {
167 new (
static_cast<void *
>(dst + current)) To(
static_cast<To
>(
src[current]));
192 for (
int64_t i = 0; i < n; i++) {
193 dst[i] = std::move(
src[i]);
215 for (; current < n; current++) {
216 new (
static_cast<void *
>(dst + current))
T(std::move(
src[current]));
281 for (
int64_t i = 0; i < n; i++) {
302 for (; current < n; current++) {
303 new (
static_cast<void *
>(dst + current))
T(value);
329 template<
typename T>
using destruct_ptr = std::unique_ptr<T, DestructValueAtAddress<T>>;
338 struct alignas(Alignment) Sized {
343 using BufferType = std::conditional_t<Size == 0, Empty, Sized>;
352 operator const void *()
const
380 return static_cast<T *
>(buffer_.ptr());
383 operator const T *()
const
385 return static_cast<const T *
>(buffer_.ptr());
390 return *
static_cast<T *
>(buffer_.ptr());
395 return *
static_cast<const T *
>(buffer_.ptr());
400 return static_cast<T *
>(buffer_.ptr());
405 return static_cast<const T *
>(buffer_.ptr());
410 return *
static_cast<T *
>(buffer_.ptr());
415 return *
static_cast<const T *
>(buffer_.ptr());
425 template<
size_t ReservedSize = 64,
size_t ReservedAlignment = 64>
429 char reserved_buffer_[(ReservedSize > 0) ? ReservedSize : 1];
437 if (
size <= ReservedSize && alignment <= ReservedAlignment) {
438 buffer_ = reserved_buffer_;
446 if (buffer_ != reserved_buffer_) {
484 template<
typename From,
typename To>
486 std::is_convertible_v<From, To> &&std::is_pointer_v<From> &&std::is_pointer_v<To>;
494 template<
typename From,
typename To>
497 std::is_pointer_v<From> &&std::is_pointer_v<To> &&
499 std::is_same_v<From, To> ||
501 std::is_same_v<const std::remove_pointer_t<From>, std::remove_pointer_t<To>> ||
503 (!std::is_const_v<std::remove_pointer_t<From>> && std::is_same_v<To, void *>) ||
505 std::is_same_v<To, const void *>);
510 template<
typename T,
typename... Args>
519 return (
static_cast<int64_t>(element_size) < 100) ? 4 : 0;
533 Container container_copy{
src};
534 dst = std::move(container_copy);
543 template<
typename Container>
545 std::is_nothrow_move_constructible_v<Container>)
552 if constexpr (std::is_nothrow_move_constructible_v<Container>) {
553 new (&dst) Container(std::move(
src));
557 new (&dst) Container(std::move(
src));
572 if (old_value != new_value) {
573 old_value = std::move(new_value);
594 #define BLI_SCOPED_DEFER_NAME1(a, b) a##b
595 #define BLI_SCOPED_DEFER_NAME2(a, b) BLI_SCOPED_DEFER_NAME1(a, b)
596 #define BLI_SCOPED_DEFER_NAME(a) BLI_SCOPED_DEFER_NAME2(_scoped_defer_##a##_, __LINE__)
604 #define BLI_SCOPED_DEFER(function_to_defer) \
605 auto BLI_SCOPED_DEFER_NAME(func) = (function_to_defer); \
606 blender::detail::ScopedDeferHelper<decltype(BLI_SCOPED_DEFER_NAME(func))> \
607 BLI_SCOPED_DEFER_NAME(helper){std::move(BLI_SCOPED_DEFER_NAME(func))};
#define BLI_NO_UNIQUE_ADDRESS
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
SyclQueue void void * src
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN_aligned)(size_t len, size_t alignment, const char *str)
constexpr bool is_same_any_v
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
bool assign_if_different(T &old_value, T new_value)
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 bool is_trivially_move_constructible_extended_v
constexpr int64_t default_inline_buffer_capacity(size_t element_size)
constexpr bool is_trivially_destructible_extended_v
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)
constexpr bool is_trivially_copy_constructible_extended_v
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)
constexpr bool is_trivial_extended_v
void uninitialized_move_n(T *src, int64_t n, T *dst)
DestructValueAtAddress()=default
DestructValueAtAddress(const U &)