diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/BLI_vector.hh | 2 | ||||
-rw-r--r-- | source/blender/blenlib/tests/BLI_vector_test.cc | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_vector.hh b/source/blender/blenlib/BLI_vector.hh index d2b94a6d8ef..4ac48f259cf 100644 --- a/source/blender/blenlib/BLI_vector.hh +++ b/source/blender/blenlib/BLI_vector.hh @@ -637,7 +637,7 @@ class Vector { * Insert values at the beginning of the vector. The has to move all the other elements, so it * has a linear running time. */ - void prepend(const T &&value) + void prepend(const T &value) { this->insert(0, value); } diff --git a/source/blender/blenlib/tests/BLI_vector_test.cc b/source/blender/blenlib/tests/BLI_vector_test.cc index e8636168308..e9393a2b1e5 100644 --- a/source/blender/blenlib/tests/BLI_vector_test.cc +++ b/source/blender/blenlib/tests/BLI_vector_test.cc @@ -708,6 +708,17 @@ TEST(vector, Prepend) EXPECT_EQ_ARRAY(vec.data(), Span({7, 8, 1, 2, 3}).data(), 5); } +TEST(vector, PrependString) +{ + std::string s = "test"; + Vector<std::string> vec; + vec.prepend(s); + vec.prepend(std::move(s)); + EXPECT_EQ(vec.size(), 2); + EXPECT_EQ(vec[0], "test"); + EXPECT_EQ(vec[1], "test"); +} + TEST(vector, ReverseIterator) { Vector<int> vec = {4, 5, 6, 7}; |