|
Boost Users : |
From: Duane Murphy (duanemurphy_at_[hidden])
Date: 2002-01-14 16:58:53
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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net