I find myself often building lookup tables for conversion or mapping of one piece of data to another. Common conversions include* converting from one string to a different string (e.g. text translation),* converting from an enum to a descriptive string* converting from a string to an enum* converting from a string to a function or functorThe key aspect of these lookup tables is that they are static. If the table is reasonably large, say 7-10 items, I ensure that the table is presorted and use lower_bounds() to search the table.Some uses have started using map_list_of() to initialize the map. My inner optimizer finds this disturbing as inherently static information is being allocated dynamically in order to due to the lookup.I believe it would be more intuitive if there was a map like interface to the lookup table. The implementation would use the static nature of the data to its advantage. In particular the implementation would not require the data to be copied, re-allocated, etc.I've been searching the boost libraries, but have not been able to find something like this.Thank you for your suggestions.…Duane
// you might find it easiest to use a typedef... typedef static_map<char const *, SomeEnum> HelloMap; HelloMap::table_entry_type helloTable[] = { // must be sorted! { "hello", E_HELLO }, { "world", E_WORLD }, // ... and many more... }; HelloMap helloMap = helloTable; // ie if you are replacing map<> based code: SomeEnum STLLikeLookup(char const * inputString) { HelloMpa::const_iterator it = helloMap.find(inputString); if (it != helloMap.end()) { return it->second; } return E_INVALID; } // or simply: SomeEnum doLookup(char const * inputString) { return helloMap.find_value_or(inputString, E_INVALID); }