You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by achristianson <gi...@git.apache.org> on 2018/07/02 09:11:28 UTC
[GitHub] nifi-minifi-cpp issue #359: MINIFICPP-515 Use emplace_back instead of push_b...
Github user achristianson commented on the issue:
https://github.com/apache/nifi-minifi-cpp/pull/359
@phrocker I read through the blog post.
The high level objective of this PR is to achieve the "copy free" state. The push_back( T&& value ) is what we want.
"in general push_back of already constructed objects with a move constructor should be fine"
It would copy, because the string is still valid after we add it (this would be "Case B" from the article):
"Case B is not affected (it still copies), and that's good, because we want to print s1 to cout below, so we want that data there."
"Case G" is the fit here, since the strings would still be valid. We need std::move to say that we're done with the string in this scope and it's OK for it to go into arbitrary post-move state.
I'll update to call push_back( T&& value ) which should be copy-free and is appropriate because we're not constructing an object.
---