Maybe I missed something, but doesn't an std::map do this??
--m
Duane Murphy wrote: I have learned a lot about templates and library programming from reading
and using the Boost code. Recently I have been finding myself doing
something that I would call Static Maps. Basically I would like to use an
array of structs as if it were a map or associative array.
Does boost have anything like this or can anyone recommend something like
that?
Here is a simple example:
struct entry
{
const char* key;
const char* value;
};
const entry entries[] =
{
{ "one", "Hello" },
{ "two", "World" },
{ "three", "!" }
};
{
some_type the_map = make_static_map( entries );
const char* word = the_map[ "one" ];
}
This is a real poor example, but shows the idea. The struct could be any
types that are less-than comparable; maybe there is some special
arrangment of key and type. But the idea is there. I would like to be
able to lookup items in a static array of items using array notation
(other than numerically indexed).
For extra credit, the interface would be writeable also; aka a fixed
array space map.
Any idea? Comments? Suggestions?
..Duane
Info: http://www.boost.org
Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl
Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail.
[Non-text portions of this message have been removed]