I want to understand how to use emplace()
method in unordered_map
I have two functions foo1 and foo2, did I understand correctly that I don't have extra copy only in foo2? How can I check it?
My code
struct A {
void foo1(const std::string& s) {
cnt.emplace(s, 1);
}
void foo2(std::string&& s) {
cnt.emplace(s, 1);
}
std::unordered_map<std::string, int> cnt;
};
int main() {
A a;
a.foo1("AAAA");
a.foo2("AAAA");
}