Talk:cpp/container/map/merge
From cppreference.com
[edit] Self-merge?
This page doesn't say anything about the behavior of `m.merge(m);`. Is it UB? Is it NOp? BenFrantzDale (talk) 06:28, 9 September 2020 (PDT)
- As said in the preamble:
- "If there is an element in *this with key equivalent to the key of an element from source, then that element is not extracted from source."
- In fact this is also a guard against self-merging since source(*this) and destination(*this) have equivalent (the same!) keys. Thus, nothing (bad) happens in case of m.merge(m).
- --Space Mission (talk) 17:29, 9 September 2020 (PDT)