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:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user