【发布时间】:2016-08-16 06:06:43
【问题描述】:
class TestClass {
public:
TestClass(string s) {
}
};
当有TestClass时,我明白emplace和insert之间的区别(插入副本时emplace结构就位)
set<TestClass> test_set;
test_set.insert(TestClass("d"));
test_set.emplace("d");
但是,如果已经有 TestClass 对象,它们在机制和性能方面有何不同?
set<TestClass> test_set;
TestClass tc("e");
test_set.insert(tc);
test_set.emplace(tc);
【问题讨论】: