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:
authorJacques Lucke <jacques@blender.org>2021-03-17 17:26:17 +0300
committerJacques Lucke <jacques@blender.org>2021-03-17 17:27:31 +0300
commitbf620020f135eab149b6327b79de8b378d99be7e (patch)
tree9b1fe60a60faa277e3abbd4a95d729b1cf29723c /source/blender/blenlib/tests
parent256da1c4b97224bc93b4d685896fabc9399639c5 (diff)
BLI: improve implicit conversions of spans
Some conversions that should work did not work before. For example, `MutableSpan<int *> -> MutableSpan<const int *>`.
Diffstat (limited to 'source/blender/blenlib/tests')
-rw-r--r--source/blender/blenlib/tests/BLI_span_test.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/blenlib/tests/BLI_span_test.cc b/source/blender/blenlib/tests/BLI_span_test.cc
index 002c97b0c7d..f611529b47e 100644
--- a/source/blender/blenlib/tests/BLI_span_test.cc
+++ b/source/blender/blenlib/tests/BLI_span_test.cc
@@ -392,4 +392,16 @@ TEST(span, Constexpr)
EXPECT_EQ(span.slice(1, 2).size(), 2);
}
+TEST(span, ImplicitConversions)
+{
+ BLI_STATIC_ASSERT((std::is_convertible_v<MutableSpan<int>, Span<int>>), "");
+ BLI_STATIC_ASSERT((std::is_convertible_v<Span<int *>, Span<const int *>>), "");
+ BLI_STATIC_ASSERT((std::is_convertible_v<MutableSpan<int *>, Span<int *>>), "");
+ BLI_STATIC_ASSERT((std::is_convertible_v<MutableSpan<int *>, Span<const int *>>), "");
+ BLI_STATIC_ASSERT((std::is_convertible_v<MutableSpan<int *>, MutableSpan<const int *>>), "");
+ BLI_STATIC_ASSERT((!std::is_convertible_v<MutableSpan<const int *>, MutableSpan<int *>>), "");
+ BLI_STATIC_ASSERT((!std::is_convertible_v<Span<const int *>, Span<int *>>), "");
+ BLI_STATIC_ASSERT((!std::is_convertible_v<Span<int *>, MutableSpan<const int *>>), "");
+}
+
} // namespace blender::tests