const auto len = basic_fbstring<E, T, A, S>::traits_type::length(lhs);
if (rhs.capacity() >= len + rhs.size()) {
// Good, at least we don't need to reallocate
- return std::move(rhs.insert(rhs.begin(), lhs, lhs + len));
+ rhs.insert(rhs.begin(), lhs, lhs + len);
+ return rhs;
}
// Meh, no go. Do it by hand since we have len already.
basic_fbstring<E, T, A, S> result;
//
if (rhs.capacity() > rhs.size()) {
// Good, at least we don't need to reallocate
- return std::move(rhs.insert(rhs.begin(), lhs));
+ rhs.insert(rhs.begin(), lhs);
+ return rhs;
}
// Meh, no go. Forward to operator+(E, const&).
auto const& rhsC = rhs;
copy.push_back('b');
EXPECT_GE(copy.capacity(), 1);
}
+ { // D2813713
+ fbstring s1("a");
+ s1.reserve(8); // Trigger the optimized code path.
+ auto test1 = '\0' + std::move(s1);
+ EXPECT_EQ(2, test1.size());
+
+ fbstring s2(1, '\0');
+ s2.reserve(8);
+ auto test2 = "a" + std::move(s2);
+ EXPECT_EQ(2, test2.size());
+ }
}
TEST(FBString, findWithNpos) {