Because flat_map and flat_multimap maintain an invariant over the containers they own, the implicitly generated move constructor and move assignment operator are not sufficient to guarantee that the moved-from flat_map and flat_multimap is in a valid but unspecified state.
Proposed change:
Spell out the operations that are allowed on a moved-from flat_map and flat_multimap and require that the underlying containers also support those operations in their moved-from state as well.
Those operations should be destruction, copy construction, move construction, copy assignment and move assignment.
The following should be valid code:
void A(vector<flat_map<KeyContainer, MappedContainer>& v) {
assert(!v.empty());
auto fm = std::move(v.front());
v.resize(v.capacity() + 1);
}
Because flat_map and flat_multimap maintain an invariant over the containers they own, the implicitly generated move constructor and move assignment operator are not sufficient to guarantee that the moved-from flat_map and flat_multimap is in a valid but unspecified state.
Proposed change:
Spell out the operations that are allowed on a moved-from flat_map and flat_multimap and require that the underlying containers also support those operations in their moved-from state as well.
Those operations should be destruction, copy construction, move construction, copy assignment and move assignment.
The following should be valid code: