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-12-20 12:46:25 +0300
committerJacques Lucke <jacques@blender.org>2021-12-20 12:46:43 +0300
commitdeb3d566a5ab3ee20e9e41bdb4835cd0f11928ed (patch)
tree7e5d52ce10e43caaab1eba2126dc4be90bf12b69 /source/blender/blenlib
parentffd1a7d8c81c65e75c8a0baf45d84375149d5387 (diff)
BLI: fix Vector.prepend declaration
Using `&&` there was a typo. With `&&` the `prepend` method could not be called with a const reference as argument.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_vector.hh2
-rw-r--r--source/blender/blenlib/tests/BLI_vector_test.cc11
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};