push: 直接将元素append进数据结构。只允许一个argument。对于stack<pair<int, char>>
的情况,应该在argument处使用constructor: stack.push(std::make_pair(3, 'a'))
,以保证只有一个argument。
emplace: 将元素放进数据结构,同时call constructor,允许多个argument,相当于简化了上述必须在argument处所做的处理: stack.emplace(3, 'a')
即可。
https://stackoverflow.com/questions/4303513/push-back-vs-emplace-back
In addition to what visitor said :
The function void emplace_back(Type&& _Val) provided by MSCV10 is non conforming and redundant, because as you noted it is strictly equivalent to push_back(Type&& _Val).