class TestClass { public: TestClass(string s) { } };
When there is a TestClass, I understand the difference between emplace and insert (mount constructions in place while inserting copies)
set<TestClass> test_set; test_set.insert(TestClass("d")); test_set.emplace("d");
However, if there is already a TestClass object, how do they differ in terms of mechanism and preliminary work?
set<TestClass> test_set; TestClass tc("e"); test_set.insert(tc); test_set.emplace(tc);
source share