Closed jdf98 closed 5 years ago
The implementation of "emplace", in the general case, needs to move elements (if a value is emplaced in the middle). Passing an end() iterator is a runtime feature, so it's impossible to know at compile time that no element needs to be moved (whereas in "emplace_back", code knows at compile time no element needs to be moved around). I'm closing this as an invalid bug report.
The following code fails to compile, because it tries to move
X
instead of constructing it in-place. Note that usingemplace_back
is fine. Tested on godbolt.org with no additional compiler options on: