From 72e49ba20a9d1b6dc4e4c0624fd918b0c3a4c829 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 12 Jun 2025 18:44:58 +0200 Subject: [PATCH] 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 --- source/blender/blenlib/BLI_cpp_type.hh | 3 +++ source/blender/blenlib/BLI_generic_pointer.hh | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/source/blender/blenlib/BLI_cpp_type.hh b/source/blender/blenlib/BLI_cpp_type.hh index 085a6505c0e..84e755ef341 100644 --- a/source/blender/blenlib/BLI_cpp_type.hh +++ b/source/blender/blenlib/BLI_cpp_type.hh @@ -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() = delete; + /** * Two types only compare equal when their pointer is equal. No two instances of CPPType for the * same C++ type should be created. diff --git a/source/blender/blenlib/BLI_generic_pointer.hh b/source/blender/blenlib/BLI_generic_pointer.hh index d0882c55bed..013e6b25200 100644 --- a/source/blender/blenlib/BLI_generic_pointer.hh +++ b/source/blender/blenlib/BLI_generic_pointer.hh @@ -100,7 +100,10 @@ class GPointer { GPointer(const CPPType &type, const void *data = nullptr) : type_(&type), data_(data) {} - template GPointer(T *data) : GPointer(&CPPType::get(), data) {} + template))> + GPointer(T *data) : GPointer(&CPPType::get(), data) + { + } operator bool() const {