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
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/BLI_span.hh')
-rw-r--r--source/blender/blenlib/BLI_span.hh17
1 files changed, 7 insertions, 10 deletions
diff --git a/source/blender/blenlib/BLI_span.hh b/source/blender/blenlib/BLI_span.hh
index 81b86f647f6..165814cf23c 100644
--- a/source/blender/blenlib/BLI_span.hh
+++ b/source/blender/blenlib/BLI_span.hh
@@ -14,8 +14,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __BLI_SPAN_HH__
-#define __BLI_SPAN_HH__
+#pragma once
/** \file
* \ingroup bli
@@ -102,7 +101,7 @@ template<typename T> class Span {
}
template<typename U, typename std::enable_if_t<is_convertible_pointer_v<U, T>> * = nullptr>
- Span(const U *start, int64_t size) : data_((const T *)start), size_(size)
+ Span(const U *start, int64_t size) : data_(static_cast<const T *>(start)), size_(size)
{
BLI_assert(size >= 0);
}
@@ -118,11 +117,12 @@ template<typename T> class Span {
* Span<int> span = {1, 2, 3, 4};
* call_function_with_array(span);
*/
- Span(const std::initializer_list<T> &list) : Span(list.begin(), (int64_t)list.size())
+ Span(const std::initializer_list<T> &list)
+ : Span(list.begin(), static_cast<int64_t>(list.size()))
{
}
- Span(const std::vector<T> &vector) : Span(vector.data(), (int64_t)vector.size())
+ Span(const std::vector<T> &vector) : Span(vector.data(), static_cast<int64_t>(vector.size()))
{
}
@@ -133,10 +133,9 @@ template<typename T> class Span {
/**
* Support implicit conversions like the ones below:
* Span<T *> -> Span<const T *>
- * Span<Derived *> -> Span<Base *>
*/
template<typename U, typename std::enable_if_t<is_convertible_pointer_v<U, T>> * = nullptr>
- Span(Span<U> array) : data_((T *)array.data()), size_(array.size())
+ Span(Span<U> array) : data_(static_cast<const T *>(array.data())), size_(array.size())
{
}
@@ -374,7 +373,7 @@ template<typename T> class Span {
{
const int64_t index = this->first_index_try(search_value);
BLI_assert(index >= 0);
- return (int64_t)index;
+ return index;
}
/**
@@ -656,5 +655,3 @@ void assert_same_size(const T1 &v1, const T2 &v2, const T3 &v3)
}
} /* namespace blender */
-
-#endif /* __BLI_SPAN_HH__ */