map


    template <class k, class t>
        struct map : public set<key_value<k, t>>
    {
        map() {}

        map(std::initializer_list<std::pair<k, t>> l)
        {
            for (std::pair<k, t> _t : l) insert(_t.first, _t.second);
        }

        void insert(const k& key, const t& data) { set<key_value<k, t>>::insert(key_value<k, t>(key, data)); }

        void erase(const k& key) { set<key_value<k, t>>::erase(key_value<k, t>(key)); }

        const t& operator[](const k& key) const
        {
            set_iterator < key_value<k, t>> i = find(key_value<k, t>(key));
            return (*i).value;
        }

        struct reference
        {
            map* m;
            const k* key;

            reference(map& map_set, const k& key_set)
                : m(&map_set), key(&key_set) {}

            reference& operator=(const t& value)
            {
                m->insert(*key, value);
                return *this;
            }

            operator t& () const
            {
                set_iterator < key_value<k, t>> i = m->find(key_value<k, t>(*key));
                return (*i).value;
            }
        };

        reference operator[](const k& key) { return reference(*this, key); }

        map& operator>>(const k& key) { erase(key); return *this; }

        t* locate(const k& key) const { key_value<k, t>* kv = locate(key_value(key));  if (kv) return &(kv->value); else return 0; }

        bool contains(const k& key) { return contains(key_value<k, t>(key)); }
    };