Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-06-27 14:28:26 +0300
committerJacques Lucke <jacques@blender.org>2020-06-27 14:28:46 +0300
commit235015910133aaa50f8398680357af4a92e12778 (patch)
tree98756bfb123234bf68c3d5546e63668813f408c8 /source
parent563670ff9e7421abc87095dab78e89ef23499253 (diff)
Cleanup: make it easier to check if a CPPType is a specific compile time type
Diffstat (limited to 'source')
-rw-r--r--source/blender/functions/FN_array_spans.hh2
-rw-r--r--source/blender/functions/FN_cpp_type.hh5
-rw-r--r--source/blender/functions/FN_generic_vector_array.hh2
-rw-r--r--source/blender/functions/FN_spans.hh6
4 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/functions/FN_array_spans.hh b/source/blender/functions/FN_array_spans.hh
index fac2ef42c9d..acd3e921b50 100644
--- a/source/blender/functions/FN_array_spans.hh
+++ b/source/blender/functions/FN_array_spans.hh
@@ -184,7 +184,7 @@ class GVArraySpan : public VArraySpanBase<void> {
template<typename T> VArraySpan<T> typed() const
{
- BLI_assert(CPPType::get<T>() == *m_type);
+ BLI_assert(m_type->is<T>());
return VArraySpan<T>(*this);
}
diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh
index e44ce858b74..706ff85bdf3 100644
--- a/source/blender/functions/FN_cpp_type.hh
+++ b/source/blender/functions/FN_cpp_type.hh
@@ -483,6 +483,11 @@ class CPPType {
template<typename T> static const CPPType &get();
+ template<typename T> bool is() const
+ {
+ return this == &CPPType::get<T>();
+ }
+
private:
uint m_size;
uint m_alignment;
diff --git a/source/blender/functions/FN_generic_vector_array.hh b/source/blender/functions/FN_generic_vector_array.hh
index 1c8f74f2abe..6be1b68da4d 100644
--- a/source/blender/functions/FN_generic_vector_array.hh
+++ b/source/blender/functions/FN_generic_vector_array.hh
@@ -167,7 +167,7 @@ template<typename T> class GVectorArrayRef {
public:
GVectorArrayRef(GVectorArray &vector_array) : m_vector_array(&vector_array)
{
- BLI_assert(vector_array.m_type == CPPType::get<T>());
+ BLI_assert(vector_array.m_type.is<T>());
}
void append(uint index, const T &value)
diff --git a/source/blender/functions/FN_spans.hh b/source/blender/functions/FN_spans.hh
index d3497c05eb9..b4607527fb5 100644
--- a/source/blender/functions/FN_spans.hh
+++ b/source/blender/functions/FN_spans.hh
@@ -100,7 +100,7 @@ class GSpan {
template<typename T> Span<T> typed() const
{
- BLI_assert(CPPType::get<T>() == *m_type);
+ BLI_assert(m_type->is<T>());
return Span<T>((const T *)m_buffer, m_size);
}
};
@@ -166,7 +166,7 @@ class GMutableSpan {
template<typename T> MutableSpan<T> typed()
{
- BLI_assert(CPPType::get<T>() == *m_type);
+ BLI_assert(m_type->is<T>());
return MutableSpan<T>((T *)m_buffer, m_size);
}
};
@@ -372,7 +372,7 @@ class GVSpan : public VSpanBase<void> {
template<typename T> VSpan<T> typed() const
{
- BLI_assert(CPPType::get<T>() == *m_type);
+ BLI_assert(m_type->is<T>());
return VSpan<T>(*this);
}