| 160 | } |
| 161 | |
| 162 | size_type erase(const key_type& key) |
| 163 | { |
| 164 | for (auto it = this->begin(); it != this->end(); ++it) |
| 165 | { |
| 166 | if (m_compare(it->first, key)) |
| 167 | { |
| 168 | // Since we cannot move const Keys, re-construct them in place |
| 169 | for (auto next = it; ++next != this->end(); ++it) |
| 170 | { |
| 171 | it->~value_type(); // Destroy but keep allocation |
| 172 | new (&*it) value_type{std::move(*next)}; |
| 173 | } |
| 174 | Container::pop_back(); |
| 175 | return 1; |
| 176 | } |
| 177 | } |
| 178 | return 0; |
| 179 | } |
| 180 | |
| 181 | template<class KeyType, detail::enable_if_t< |
| 182 | detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value, int> = 0> |