example:
struct S { int i = 0; bool operator < (const S& rhs) const { return i < rhs.i; } } s; std::set<S> set1, set2; auto [it, inserted] = set1.emplace(std::move(s)); if (!inserted) { set2.insert(std::move(s)); }
Not sure about this one. According to https://en.cppreference.com/w/cpp/container/set/emplace, an element might be constructed (move-constructed in this case) even if no insertion takes place.
Log in to post a comment.
example:
Not sure about this one. According to https://en.cppreference.com/w/cpp/container/set/emplace, an element might be constructed (move-constructed in this case) even if no insertion takes place.