Blender  V3.3
Classes | Namespaces | Macros | Typedefs | Functions | Variables
BLI_memory_utils.hh File Reference
#include <memory>
#include <new>
#include <type_traits>
#include "BLI_utildefines.h"
#include "MEM_guardedalloc.h"

Go to the source code of this file.

Classes

struct  blender::DestructValueAtAddress< T >
 
class  blender::AlignedBuffer< Size, Alignment >
 
class  blender::TypedBuffer< T, Size >
 
class  blender::DynamicStackBuffer< ReservedSize, ReservedAlignment >
 
class  blender::NoInitialization
 
class  blender::NoExceptConstructor
 
struct  blender::detail::ScopedDeferHelper< Func >
 

Namespaces

 blender
 
 blender::detail
 

Macros

#define BLI_SCOPED_DEFER_NAME1(a, b)   a##b
 
#define BLI_SCOPED_DEFER_NAME2(a, b)   BLI_SCOPED_DEFER_NAME1(a, b)
 
#define BLI_SCOPED_DEFER_NAME(a)   BLI_SCOPED_DEFER_NAME2(_scoped_defer_##a##_, __LINE__)
 
#define BLI_SCOPED_DEFER(function_to_defer)
 

Typedefs

template<typename T >
using blender::destruct_ptr = std::unique_ptr< T, DestructValueAtAddress< T > >
 

Functions

template<typename T >
void blender::destruct_n (T *ptr, int64_t n)
 
template<typename T >
void blender::default_construct_n (T *ptr, int64_t n)
 
template<typename T >
void blender::initialized_copy_n (const T *src, int64_t n, T *dst)
 
template<typename T >
void blender::uninitialized_copy_n (const T *src, int64_t n, T *dst)
 
template<typename From , typename To >
void blender::uninitialized_convert_n (const From *src, int64_t n, To *dst)
 
template<typename T >
void blender::initialized_move_n (T *src, int64_t n, T *dst)
 
template<typename T >
void blender::uninitialized_move_n (T *src, int64_t n, T *dst)
 
template<typename T >
void blender::initialized_relocate_n (T *src, int64_t n, T *dst)
 
template<typename T >
void blender::uninitialized_relocate_n (T *src, int64_t n, T *dst)
 
template<typename T >
void blender::initialized_fill_n (T *dst, int64_t n, const T &value)
 
template<typename T >
void blender::uninitialized_fill_n (T *dst, int64_t n, const T &value)
 
constexpr int64_t blender::default_inline_buffer_capacity (size_t element_size)
 
template<typename Container >
Container & blender::copy_assign_container (Container &dst, const Container &src)
 
template<typename Container >
Container & blender::move_assign_container (Container &dst, Container &&src) noexcept(std::is_nothrow_move_constructible_v< Container >)
 
template<typename T >
bool blender::assign_if_different (T &old_value, T new_value)
 

Variables

template<typename T >
constexpr bool blender::is_trivial_extended_v = std::is_trivial_v<T>
 
template<typename T >
constexpr bool blender::is_trivially_destructible_extended_v
 
template<typename T >
constexpr bool blender::is_trivially_copy_constructible_extended_v
 
template<typename T >
constexpr bool blender::is_trivially_move_constructible_extended_v
 
template<typename From , typename To >
constexpr bool blender::is_convertible_pointer_v
 
template<typename From , typename To >
constexpr bool blender::is_span_convertible_pointer_v
 
template<typename T , typename... Args>
constexpr bool blender::is_same_any_v = (std::is_same_v<T, Args> || ...)
 

Detailed Description

Some of the functions below have very similar alternatives in the standard library. However, it is rather annoying to use those when debugging. Therefore, some more specialized and easier to debug functions are provided here.

Definition in file BLI_memory_utils.hh.

Macro Definition Documentation

◆ BLI_SCOPED_DEFER

#define BLI_SCOPED_DEFER (   function_to_defer)
Value:
auto BLI_SCOPED_DEFER_NAME(func) = (function_to_defer); \
blender::detail::ScopedDeferHelper<decltype(BLI_SCOPED_DEFER_NAME(func))> \
BLI_SCOPED_DEFER_NAME(helper){std::move(BLI_SCOPED_DEFER_NAME(func))};
#define BLI_SCOPED_DEFER_NAME(a)

Execute the given function when the current scope ends. This can be used to cheaply implement some RAII-like behavior for C types that don't support it. Long term, the types we want to use this with should either be converted to C++ or get a proper C++ API. Until then, this function can help avoid common resource leakages.

Definition at line 604 of file BLI_memory_utils.hh.

◆ BLI_SCOPED_DEFER_NAME

#define BLI_SCOPED_DEFER_NAME (   a)    BLI_SCOPED_DEFER_NAME2(_scoped_defer_##a##_, __LINE__)

Definition at line 596 of file BLI_memory_utils.hh.

◆ BLI_SCOPED_DEFER_NAME1

#define BLI_SCOPED_DEFER_NAME1 (   a,
 
)    a##b

Definition at line 594 of file BLI_memory_utils.hh.

◆ BLI_SCOPED_DEFER_NAME2

#define BLI_SCOPED_DEFER_NAME2 (   a,
 
)    BLI_SCOPED_DEFER_NAME1(a, b)

Definition at line 595 of file BLI_memory_utils.hh.