From a post about using strings as an indexing mechanism:
"David Abrahams"
Since all are known at compile time I'm sure it must be easy to do this. I'm pretty sure when someone shows me the obvious solution I will be very embarrassed, but until then I can do this with a std::map at runtime, but not at compile time. I'm pretty sure the parameter library is a good -- if not perfect -- match for your problem. Since I've pointed at it twice now, if you're not embarrassed yet, I'll stop pushing ;-)
I too am quite interested in this process of compile time indexing. Let me think out loud (visibly?). Question at the bottom. I have often used this pattern of access for a vector of a known size (contrived example): enum TabIndices { PERSON_TAB, ADDRESS_TAB, EMPLOYER_TAB, TAB_COUNT }; Window windows[TAB_COUNT]; ... display_window( TabIndices tab_index ) { windows[tab_index].display(); for( int i = 0; i < (int)TAB_COUNT; ++i ) { if( i != (int)tab_index ) windows[i].hide(); } } ... display_window( PERSON_TAB ); Let me have go at converting this to use the parameter keyword system for indexing by using an ArgumentPack. BOOST_PARAMETER_KEYWORD(tag, PERSON_WINDOW) BOOST_PARAMETER_KEYWORD(tag, ADDRESS_WINDOW) BOOST_PARAMETER_KEYWORD(tag, EMPLOYER_WINDOW)XXXX windows( ( PERSON_WINDOW = Window(), ADDRESS_WINDOW = Window(), EMPLOYER_WINDOW = Window() ) ); ... template<class keyword> display_window( keyword tab_index) { windows[tab_index].display(); for( YYYY ) { if( *iterator != tab_index ) windows[iterator].hide(); } } ... display_window( PERSON_TAB ); My two immediate problems are how to declare the type of the ArgumentPack that would actually hold the window objects. (XXXX) And secondly, how to iterate over the windows at runtime. (YYYY). I guess the main thrust of the question is "Does the parameters library support runtime enumeration?" or should I be looking at MPL? Neil