If T has an explicit conversion constructor, there is different behavior between emplace_back
and push_back
.
struct X
{
int val;
X() :val() {}
explicit X(int v) :val(v) {}
};
int main()
{
std::vector<X> v;
v.push_back(123); // this fails
v.emplace_back(123); // this is okay
}
Making the change you suggest would mean that push_back
would be legal in that instance, and I suppose that was not desired behavior. I don’t know if this is the reason, but it’s the only thing I can come up with.