One way I've used it in code

struct MapBy(T,string key) if (hasDeepMember!(T,key)) {
        alias key_t = DeepMemberType!(T,key);
        private const(T)[key_t] _map;

        bool has(key_t id) const nothrow {
                if ((id in _map) != null) return true;
                else return false;
        }

        void put(in ref T val) pure nothrow {
                auto id = val.Extract!key;
                _map[id] = val;
        }

        ref const(T) get(key_t id) const nothrow {
                assert(has(id));
                return _map[id];
        }
}
  • Template help Anonymous via Digitalmars-d-learn
    • Re: Template help Anonymous via Digitalmars-d-learn

Reply via email to