Cleanup: Add protection for void CPPType and GPointer

Previously using these types with a void type would give a
linker error. Compile errors are much easier to diagnose.

Pull Request: https://projects.blender.org/blender/blender/pulls/140296
This commit is contained in:
Hans Goudey
2025-06-12 18:44:58 +02:00
committed by Hans Goudey
parent d3b567f47f
commit 72e49ba20a
2 changed files with 7 additions and 1 deletions

View File

@@ -447,6 +447,9 @@ void register_cpp_types();
namespace blender {
/* Give a compile error instead of a link error when type information is missing. */
template<> const CPPType &CPPType::get_impl<void>() = delete;
/**
* Two types only compare equal when their pointer is equal. No two instances of CPPType for the
* same C++ type should be created.

View File

@@ -100,7 +100,10 @@ class GPointer {
GPointer(const CPPType &type, const void *data = nullptr) : type_(&type), data_(data) {}
template<typename T> GPointer(T *data) : GPointer(&CPPType::get<T>(), data) {}
template<typename T, BLI_ENABLE_IF((!std::is_void_v<T>))>
GPointer(T *data) : GPointer(&CPPType::get<T>(), data)
{
}
operator bool() const
{