diff options
Diffstat (limited to 'source/blender/blenlib/BLI_span.hh')
-rw-r--r-- | source/blender/blenlib/BLI_span.hh | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/source/blender/blenlib/BLI_span.hh b/source/blender/blenlib/BLI_span.hh index 92d3124e01d..57ef9ce9eb6 100644 --- a/source/blender/blenlib/BLI_span.hh +++ b/source/blender/blenlib/BLI_span.hh @@ -100,6 +100,11 @@ template<typename T> class Span { { } + template<typename U, typename std::enable_if_t<is_convertible_pointer_v<U, T>> * = nullptr> + Span(const U *start, uint size) : start_((const T *)start), size_(size) + { + } + /** * Reference an initializer_list. Note that the data in the initializer_list is only valid until * the expression containing it is fully computed. @@ -128,9 +133,8 @@ template<typename T> class Span { * Span<T *> -> Span<const T *> * Span<Derived *> -> Span<Base *> */ - template<typename U, - typename std::enable_if<std::is_convertible<U *, T>::value>::type * = nullptr> - Span(Span<U *> array) : Span((T *)array.data(), array.size()) + template<typename U, typename std::enable_if_t<is_convertible_pointer_v<U, T>> * = nullptr> + Span(Span<U> array) : start_((T *)array.data()), size_(array.size()) { } @@ -436,21 +440,6 @@ template<typename T> class MutableSpan { { } - /** - * Reference an initializer_list. Note that the data in the initializer_list is only valid until - * the expression containing it is fully computed. - * - * Do: - * call_function_with_array({1, 2, 3, 4}); - * - * Don't: - * MutableSpan<int> span = {1, 2, 3, 4}; - * call_function_with_array(span); - */ - MutableSpan(std::initializer_list<T> &list) : MutableSpan(list.begin(), list.size()) - { - } - MutableSpan(std::vector<T> &vector) : MutableSpan(vector.data(), vector.size()) { } @@ -607,14 +596,6 @@ template<typename T> class MutableSpan { }; /** - * Shorthand to make use of automatic template parameter deduction. - */ -template<typename T> Span<T> ref_c_array(const T *array, uint size) -{ - return Span<T>(array, size); -} - -/** * Utilities to check that arrays have the same size in debug builds. */ template<typename T1, typename T2> void assert_same_size(const T1 &v1, const T2 &v2) |