I have a map[1] with compile-time keys so I can do all lookups at compile-time, but assign values at runtime. If I try to find a value given a non-existing key, I get a compilation error. The keys are strings that have been hashed using the fnv1a algorithm. Now I want to assign the key inside the value block, so I can use it for other purpose. Since I do not like to type the key twice,
#define MAKE_OPTION(option_map,key,description,argcount) \
option_map.get<Stringkey(key)>()={key,description,argcount}
Can this be done without a macro given that key is a const char*? I would really like constexpr parameter for this.
Notice that this map is not the std::map. The lookup method is actually a static template instantiated with the (hashed) key.
Aucun commentaire:
Enregistrer un commentaire