Blender V5.0
CPPType Class Reference

#include <BLI_cpp_type.hh>

Inherits blender::NonCopyable, and blender::NonMovable.

Public Member Functions

template<typename T, CPPTypeFlags Flags>
 CPPType (TypeTag< T >, TypeForValue< CPPTypeFlags, Flags >, StringRef debug_name)
virtual ~CPPType ()=default
StringRefNull name () const
bool is_printable () const
bool is_equality_comparable () const
bool is_hashable () const
bool pointer_has_valid_alignment (const void *ptr) const
bool pointer_can_point_to_instance (const void *ptr) const
void default_construct (void *ptr) const
void default_construct_n (void *ptr, int64_t n) const
void default_construct_indices (void *ptr, const IndexMask &mask) const
void value_initialize (void *ptr) const
void value_initialize_n (void *ptr, int64_t n) const
void value_initialize_indices (void *ptr, const IndexMask &mask) const
void destruct (void *ptr) const
void destruct_n (void *ptr, int64_t n) const
void destruct_indices (void *ptr, const IndexMask &mask) const
void copy_assign (const void *src, void *dst) const
void copy_assign_n (const void *src, void *dst, int64_t n) const
void copy_assign_indices (const void *src, void *dst, const IndexMask &mask) const
void copy_assign_compressed (const void *src, void *dst, const IndexMask &mask) const
void copy_construct (const void *src, void *dst) const
void copy_construct_n (const void *src, void *dst, int64_t n) const
void copy_construct_indices (const void *src, void *dst, const IndexMask &mask) const
void copy_construct_compressed (const void *src, void *dst, const IndexMask &mask) const
void move_assign (void *src, void *dst) const
void move_assign_n (void *src, void *dst, int64_t n) const
void move_assign_indices (void *src, void *dst, const IndexMask &mask) const
void move_construct (void *src, void *dst) const
void move_construct_n (void *src, void *dst, int64_t n) const
void move_construct_indices (void *src, void *dst, const IndexMask &mask) const
void relocate_assign (void *src, void *dst) const
void relocate_assign_n (void *src, void *dst, int64_t n) const
void relocate_assign_indices (void *src, void *dst, const IndexMask &mask) const
void relocate_construct (void *src, void *dst) const
void relocate_construct_n (void *src, void *dst, int64_t n) const
void relocate_construct_indices (void *src, void *dst, const IndexMask &mask) const
void fill_assign_n (const void *value, void *dst, int64_t n) const
void fill_assign_indices (const void *value, void *dst, const IndexMask &mask) const
void fill_construct_n (const void *value, void *dst, int64_t n) const
void fill_construct_indices (const void *value, void *dst, const IndexMask &mask) const
bool can_exist_in_buffer (const int64_t buffer_size, const int64_t buffer_alignment) const
void print (const void *value, std::stringstream &ss) const
std::string to_string (const void *value) const
void print_or_default (const void *value, std::stringstream &ss, StringRef default_value) const
bool is_equal (const void *a, const void *b) const
bool is_equal_or_false (const void *a, const void *b) const
uint64_t hash (const void *value) const
uint64_t hash () const
uint64_t hash_or_fallback (const void *value, uint64_t fallback_hash) const
const void * default_value () const
template<typename T>
bool is () const
template<typename... T>
bool is_any () const
template<typename... Types, typename Fn>
void to_static_type (const Fn &fn) const
template<typename... Types, typename Fn>
void to_static_type_tag (const Fn &fn) const

Static Public Member Functions

template<typename T>
static const CPPTypeget ()
template<typename T>
static const CPPTypeget_impl ()
template<>
const CPPTypeget_impl ()=delete

Public Attributes

int64_t size = 0
int64_t alignment = 0
bool is_trivial = false
bool is_trivially_destructible = false
bool has_special_member_functions = false
bool is_default_constructible = false
bool is_copy_constructible = false
bool is_move_constructible = false
bool is_destructible = false
bool is_copy_assignable = false
bool is_move_assignable = false
void(*)(void *) destruct_fn () const

Detailed Description

Definition at line 100 of file BLI_cpp_type.hh.

Constructor & Destructor Documentation

◆ CPPType()

template<typename T, CPPTypeFlags Flags>
blender::CPPType::CPPType ( TypeTag< T > ,
TypeForValue< CPPTypeFlags, Flags > ,
StringRef debug_name )

Definition at line 316 of file BLI_cpp_type_make.hh.

◆ ~CPPType()

virtual blender::CPPType::~CPPType ( )
virtualdefault

Member Function Documentation

◆ can_exist_in_buffer()

bool blender::CPPType::can_exist_in_buffer ( const int64_t buffer_size,
const int64_t buffer_alignment ) const
inline

Definition at line 677 of file BLI_cpp_type.hh.

◆ copy_assign()

void blender::CPPType::copy_assign ( const void * src,
void * dst ) const
inline

Copy an instance of this type from src to dst.

C++ equivalent: dst = src;

Definition at line 549 of file BLI_cpp_type.hh.

◆ copy_assign_compressed()

void blender::CPPType::copy_assign_compressed ( const void * src,
void * dst,
const IndexMask & mask ) const
inline

Similar to copy_assign_indices, but does not leave gaps in the #dst array.

Definition at line 564 of file BLI_cpp_type.hh.

◆ copy_assign_indices()

void blender::CPPType::copy_assign_indices ( const void * src,
void * dst,
const IndexMask & mask ) const
inline

Definition at line 559 of file BLI_cpp_type.hh.

◆ copy_assign_n()

void blender::CPPType::copy_assign_n ( const void * src,
void * dst,
int64_t n ) const
inline

Definition at line 554 of file BLI_cpp_type.hh.

◆ copy_construct()

void blender::CPPType::copy_construct ( const void * src,
void * dst ) const
inline

Copy an instance of this type from src to dst.

The memory pointed to by dst should be uninitialized.

C++ equivalent: new (dst) T(src);

Definition at line 571 of file BLI_cpp_type.hh.

◆ copy_construct_compressed()

void blender::CPPType::copy_construct_compressed ( const void * src,
void * dst,
const IndexMask & mask ) const
inline

Similar to copy_construct_indices, but does not leave gaps in the #dst array.

Definition at line 588 of file BLI_cpp_type.hh.

◆ copy_construct_indices()

void blender::CPPType::copy_construct_indices ( const void * src,
void * dst,
const IndexMask & mask ) const
inline

Definition at line 581 of file BLI_cpp_type.hh.

◆ copy_construct_n()

void blender::CPPType::copy_construct_n ( const void * src,
void * dst,
int64_t n ) const
inline

Definition at line 576 of file BLI_cpp_type.hh.

Referenced by shrink_attribute_storage().

◆ default_construct()

void blender::CPPType::default_construct ( void * ptr) const
inline

Call the default constructor at the given memory location. The memory should be uninitialized before this method is called. For some trivial types (like int), this method does nothing.

C++ equivalent: new (ptr) T;

Definition at line 504 of file BLI_cpp_type.hh.

◆ default_construct_indices()

void blender::CPPType::default_construct_indices ( void * ptr,
const IndexMask & mask ) const
inline

Definition at line 514 of file BLI_cpp_type.hh.

◆ default_construct_n()

void blender::CPPType::default_construct_n ( void * ptr,
int64_t n ) const
inline

Definition at line 509 of file BLI_cpp_type.hh.

◆ default_value()

const void * blender::CPPType::default_value ( ) const
inline

Get a pointer to a constant value of this type. The specific value depends on the type. It is usually a zero-initialized or default constructed value.

Definition at line 715 of file BLI_cpp_type.hh.

◆ destruct()

void blender::CPPType::destruct ( void * ptr) const
inline

Call the destructor on the given instance of this type. The pointer must not be nullptr.

For some trivial types, this does nothing.

C++ equivalent: ptr->~T();

Definition at line 534 of file BLI_cpp_type.hh.

Referenced by geometry_attribute_get_tarmat().

◆ destruct_indices()

void blender::CPPType::destruct_indices ( void * ptr,
const IndexMask & mask ) const
inline

Definition at line 544 of file BLI_cpp_type.hh.

◆ destruct_n()

void blender::CPPType::destruct_n ( void * ptr,
int64_t n ) const
inline

Definition at line 539 of file BLI_cpp_type.hh.

◆ fill_assign_indices()

void blender::CPPType::fill_assign_indices ( const void * value,
void * dst,
const IndexMask & mask ) const
inline

Definition at line 660 of file BLI_cpp_type.hh.

◆ fill_assign_n()

void blender::CPPType::fill_assign_n ( const void * value,
void * dst,
int64_t n ) const
inline

Copy the given value to the first n elements in an array starting at dst.

Other instances of the same type should live in the array before this method is called.

Definition at line 655 of file BLI_cpp_type.hh.

◆ fill_construct_indices()

void blender::CPPType::fill_construct_indices ( const void * value,
void * dst,
const IndexMask & mask ) const
inline

Definition at line 670 of file BLI_cpp_type.hh.

◆ fill_construct_n()

void blender::CPPType::fill_construct_n ( const void * value,
void * dst,
int64_t n ) const
inline

Copy the given value to the first n elements in an array starting at dst.

The array should be uninitialized before this method is called.

Definition at line 665 of file BLI_cpp_type.hh.

◆ get()

template<typename T>
const CPPType & blender::CPPType::get ( )
inlinestatic

Get the CPPType that corresponds to a specific static type. This only works for types that actually implement the template specialization using BLI_CPP_TYPE_MAKE.

Definition at line 467 of file BLI_cpp_type.hh.

Referenced by blender::nodes::evaluate_closure_eagerly(), blender::ed::greasepencil::insert_selected_values(), and blender::ed::greasepencil::select_similar_by_value().

◆ get_impl() [1/2]

template<typename T>
const CPPType & blender::CPPType::get_impl ( )
static

◆ get_impl() [2/2]

template<>
const CPPType & blender::CPPType::get_impl ( )
staticdelete

◆ hash() [1/2]

uint64_t blender::CPPType::hash ( ) const
inline

Definition at line 720 of file BLI_cpp_type.hh.

◆ hash() [2/2]

uint64_t blender::CPPType::hash ( const void * value) const
inline

Definition at line 702 of file BLI_cpp_type.hh.

◆ hash_or_fallback()

uint64_t blender::CPPType::hash_or_fallback ( const void * value,
uint64_t fallback_hash ) const
inline

Definition at line 707 of file BLI_cpp_type.hh.

◆ is()

template<typename T>
bool blender::CPPType::is ( ) const
inline

Definition at line 730 of file BLI_cpp_type.hh.

◆ is_any()

template<typename... T>
bool blender::CPPType::is_any ( ) const
inline

Definition at line 735 of file BLI_cpp_type.hh.

◆ is_equal()

bool blender::CPPType::is_equal ( const void * a,
const void * b ) const
inline

Definition at line 689 of file BLI_cpp_type.hh.

◆ is_equal_or_false()

bool blender::CPPType::is_equal_or_false ( const void * a,
const void * b ) const
inline

Definition at line 694 of file BLI_cpp_type.hh.

◆ is_equality_comparable()

Definition at line 484 of file BLI_cpp_type.hh.

◆ is_hashable()

bool blender::CPPType::is_hashable ( ) const
inline

Definition at line 489 of file BLI_cpp_type.hh.

◆ is_printable()

bool blender::CPPType::is_printable ( ) const
inline

Definition at line 479 of file BLI_cpp_type.hh.

◆ move_assign()

void blender::CPPType::move_assign ( void * src,
void * dst ) const
inline

Move an instance of this type from src to dst.

The memory pointed to by dst should be initialized.

C++ equivalent: dst = std::move(src);

Definition at line 595 of file BLI_cpp_type.hh.

◆ move_assign_indices()

void blender::CPPType::move_assign_indices ( void * src,
void * dst,
const IndexMask & mask ) const
inline

Definition at line 605 of file BLI_cpp_type.hh.

◆ move_assign_n()

void blender::CPPType::move_assign_n ( void * src,
void * dst,
int64_t n ) const
inline

Definition at line 600 of file BLI_cpp_type.hh.

◆ move_construct()

void blender::CPPType::move_construct ( void * src,
void * dst ) const
inline

Move an instance of this type from src to dst.

The memory pointed to by dst should be uninitialized.

C++ equivalent: new (dst) T(std::move(src));

Definition at line 610 of file BLI_cpp_type.hh.

◆ move_construct_indices()

void blender::CPPType::move_construct_indices ( void * src,
void * dst,
const IndexMask & mask ) const
inline

Definition at line 620 of file BLI_cpp_type.hh.

◆ move_construct_n()

void blender::CPPType::move_construct_n ( void * src,
void * dst,
int64_t n ) const
inline

Definition at line 615 of file BLI_cpp_type.hh.

◆ name()

Returns the name of the type for debugging purposes. This name should not be used as identifier.

Definition at line 474 of file BLI_cpp_type.hh.

◆ pointer_can_point_to_instance()

bool blender::CPPType::pointer_can_point_to_instance ( const void * ptr) const
inline

Definition at line 499 of file BLI_cpp_type.hh.

◆ pointer_has_valid_alignment()

bool blender::CPPType::pointer_has_valid_alignment ( const void * ptr) const
inline

Returns true, when the given pointer fulfills the alignment requirement of this type.

Definition at line 494 of file BLI_cpp_type.hh.

◆ print()

void blender::CPPType::print ( const void * value,
std::stringstream & ss ) const
inline

Definition at line 683 of file BLI_cpp_type.hh.

◆ print_or_default()

void blender::CPPType::print_or_default ( const void * value,
std::stringstream & ss,
StringRef default_value ) const

Definition at line 22 of file cpp_type.cc.

◆ relocate_assign()

void blender::CPPType::relocate_assign ( void * src,
void * dst ) const
inline

Relocates an instance of this type from src to dst. src will point to uninitialized memory afterwards.

C++ equivalent: dst = std::move(src); src->~T();

Definition at line 625 of file BLI_cpp_type.hh.

◆ relocate_assign_indices()

void blender::CPPType::relocate_assign_indices ( void * src,
void * dst,
const IndexMask & mask ) const
inline

Definition at line 635 of file BLI_cpp_type.hh.

◆ relocate_assign_n()

void blender::CPPType::relocate_assign_n ( void * src,
void * dst,
int64_t n ) const
inline

Definition at line 630 of file BLI_cpp_type.hh.

◆ relocate_construct()

void blender::CPPType::relocate_construct ( void * src,
void * dst ) const
inline

Relocates an instance of this type from src to dst. src will point to uninitialized memory afterwards.

C++ equivalent: new (dst) T(std::move(src)) src->~T();

Definition at line 640 of file BLI_cpp_type.hh.

◆ relocate_construct_indices()

void blender::CPPType::relocate_construct_indices ( void * src,
void * dst,
const IndexMask & mask ) const
inline

Definition at line 650 of file BLI_cpp_type.hh.

◆ relocate_construct_n()

void blender::CPPType::relocate_construct_n ( void * src,
void * dst,
int64_t n ) const
inline

Definition at line 645 of file BLI_cpp_type.hh.

◆ to_static_type()

template<typename... Types, typename Fn>
void blender::CPPType::to_static_type ( const Fn & fn) const
inline

Convert a CPPType that is only known at run-time, to a static type that is known at compile-time. This allows the compiler to optimize a function for specific types, while all other types can still use a generic fallback function.

Parameters
TypesThe types that code should be generated for.
fnThe function object to call. This is expected to have a templated operator() and a non-templated operator(). The templated version will be called if the current CPPType matches any of the given types. Otherwise, the non-templated function is called.

Definition at line 740 of file BLI_cpp_type.hh.

◆ to_static_type_tag()

template<typename... Types, typename Fn>
void blender::CPPType::to_static_type_tag ( const Fn & fn) const
inline

Similar to to_static_type but is easier to use with a lambda function. The function is expected to take a single auto TypeTag parameter. To extract the static type, use: using T = typename decltype(TypeTag)::type;

If the current CPPType is not in #Types, the type tag is void.

Definition at line 428 of file BLI_cpp_type.hh.

◆ to_string()

std::string blender::CPPType::to_string ( const void * value) const

Definition at line 15 of file cpp_type.cc.

◆ value_initialize()

void blender::CPPType::value_initialize ( void * ptr) const
inline

Same as default_construct, but does zero initialization for trivial types.

C++ equivalent: new (ptr) T();

Definition at line 519 of file BLI_cpp_type.hh.

◆ value_initialize_indices()

void blender::CPPType::value_initialize_indices ( void * ptr,
const IndexMask & mask ) const
inline

Definition at line 529 of file BLI_cpp_type.hh.

◆ value_initialize_n()

void blender::CPPType::value_initialize_n ( void * ptr,
int64_t n ) const
inline

Definition at line 524 of file BLI_cpp_type.hh.

Member Data Documentation

◆ alignment

Required memory alignment for an instance of this type.

C++ equivalent: alignof(T);

Definition at line 116 of file BLI_cpp_type.hh.

◆ destruct_fn

void(*)(void *) blender::CPPType::destruct_fn() const

Definition at line 725 of file BLI_cpp_type.hh.

◆ has_special_member_functions

Returns true, when the type has the following functions:

  • Default constructor.
  • Copy constructor.
  • Move constructor.
  • Copy assignment operator.
  • Move assignment operator.
  • Destructor.

Definition at line 145 of file BLI_cpp_type.hh.

◆ is_copy_assignable

Definition at line 151 of file BLI_cpp_type.hh.

◆ is_copy_constructible

◆ is_default_constructible

◆ is_destructible

Definition at line 150 of file BLI_cpp_type.hh.

◆ is_move_assignable

Definition at line 152 of file BLI_cpp_type.hh.

◆ is_move_constructible

◆ is_trivial

When true, the value is like a normal C type, it can be copied around with #memcpy and does not have to be destructed.

C++ equivalent: std::is_trivial_v<T>;

Definition at line 125 of file BLI_cpp_type.hh.

◆ is_trivially_destructible

When true, the destructor does not have to be called on this type. This can sometimes be used for optimization purposes.

C++ equivalent: std::is_trivially_destructible_v<T>;

Definition at line 134 of file BLI_cpp_type.hh.

◆ size

Required memory in bytes for an instance of this type.

C++ equivalent: sizeof(T);

Definition at line 108 of file BLI_cpp_type.hh.

Referenced by reorder_attribute_domain(), and shrink_attribute_storage().


The documentation for this class was generated from the following files: