How to build a compile-time key/value store?
I have a problem where I need to map an integer at compile time to another integer. Basically, I need the compile-time equivalent of std::map<int,int> . If a key is not found in the map, I'd like to return a default value. The interface I'd like to use: template<unsigned int default_value, unsigned int key0, unsigned int value0, unsigned int key1, unsigned int value1, ...> struct static_map { ... }; template<unsigned int key, typename StaticMap> struct lookup { static unsigned int value = ... }; lookup returns the value associated with key in the StaticMap . If key is not found, then default