Example #1
0
File: db.hpp Project: mrktj/tmwa
 void put(const K& k, U v)
 {
     if (!v)
         impl.erase(k);
     else
         impl.insert(k, std::move(v));
 }
Example #2
0
File: db.hpp Project: mrktj/tmwa
 void put(const K& k, V v)
 {
     if (v == V())
         impl.erase(k);
     else
         impl.insert(k, std::move(v));
 }
Example #3
0
File: db.hpp Project: mrktj/tmwa
    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;

    }