From 4463087223983c40a6d67beab0513fba7cdb7538 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 16 Dec 2020 15:59:58 +0100 Subject: BLI: remove implicit casts between some span types Casting pointers from one type to another does change the value of the pointer in some cases. Therefore, casting a span that contains pointers of one type to a span that contains pointers of another type, is not generally safe. In practice, this issue mainly comes up when dealing with classes that have a vtable. There are some special cases that are still allowed. For example, adding const to the pointer does not change the address. Also, casting to a void pointer is fine. In cases where implicit conversion is disabled, but one is sure that the cast is valid, an explicit call of `span.cast()` can be used. --- source/blender/blenlib/BLI_vector.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenlib/BLI_vector.hh') diff --git a/source/blender/blenlib/BLI_vector.hh b/source/blender/blenlib/BLI_vector.hh index 053dcb6faea..fe6d54ae9e5 100644 --- a/source/blender/blenlib/BLI_vector.hh +++ b/source/blender/blenlib/BLI_vector.hh @@ -315,13 +315,13 @@ class Vector { return MutableSpan(begin_, this->size()); } - template> * = nullptr> + template> * = nullptr> operator Span() const { return Span(begin_, this->size()); } - template> * = nullptr> + template> * = nullptr> operator MutableSpan() { return MutableSpan(begin_, this->size()); -- cgit v1.2.3