Is there any data structure (C++03, or Boost) can keep the insert order and capable of lookup by key. I am currently doing it in this way:
struct Foo {
vector<string> v; // keep the key order by insert time
map<string, string> m; // <key, value>
};
Foo foo;
foo.v.push_back("key1");
foo.m["key1"] = "value1";
foo.v.push_back("key2");
foo.m["key2"] = "value2";
With this, I can keep the order I want in the vector object, and still be able to quickly lookup with the map object. The downside is I have to maintain both the vector object and map object, which smells.