void put(const K& k, U v) { if (!v) impl.erase(k); else impl.insert(k, std::move(v)); }
void put(const K& k, V v) { if (v == V()) impl.erase(k); else impl.insert(k, std::move(v)); }
void insert(const K& k, V v) { // As far as I can tell, this is the simplest way to // implement move-only insert-with-replacement. iterator it = impl.lower_bound(k); // invariant: if it is valid, it->first >= k if (it != impl.end() && it->first == k) it->second = std::move(v); else it = impl.insert(std::pair<K, V>(std::move(k), std::move(v))).first; return (void)&it->second; }