On 29/06/16 21:43 +0200, François Dumont wrote:
As asked here is now a patch to only fix the robustness issue. The consequence is that it is reverting the latest optimization as, without smart algo, we always need to do a copy to protect against insertion of values contained in the vector as shown by new tests.
I don't understand. There is no problem with insert(), only with emplace(), so why do both get worse? Also, the problem is with emplacing from an lvalue, so why do the number of operations change for test02 and test03, which are for xvalues and rvalues? I haven't analyzed your patch, but the results seem wrong. We should not have to do any more work to insert rvalues. What am I missing?
diff --git a/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert_vs_emplace.cc b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert_vs_emplace.cc index 39a3f03..8bd72b7 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert_vs_emplace.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert_vs_emplace.cc @@ -149,7 +149,7 @@ test01() void test02() { - const X::special expected{ 0, 0, 0, 0, 1, 3 }; + const X::special expected{ 0, 1, 0, 0, 2, 3 }; X::special ins, emp; { std::vector<X> v; @@ -187,7 +187,7 @@ test02() void test03() { - const X::special expected{ 1, 1, 0, 0, 1, 3 }; + const X::special expected{ 1, 2, 0, 0, 2, 3 }; X::special ins, emp; { std::vector<X> v;