I've encountered this in Visual C++ applications
extern map<string, rpcfn_type> mapCallTable;
or
map<string, string>
What does it mean? Not the map thing, but the
<string, string>
part
I've encountered this in Visual C++ applications
extern map<string, rpcfn_type> mapCallTable;
or
map<string, string>
What does it mean? Not the map thing, but the
<string, string>
part
Those are template parameters; map
is a class template, and it's not complete until you tell it the types it will be working with. The first is the type of the key, and the second is the type of the data that will be stored via the key.
std::map
is a template. You use it to create a type that has a key and some data associated with that key. The angle brackets is where you specify those two types, so (for example), map<string, string>
is defining a type that uses one string as the key, and has another string associated with the first one.
One that's perhaps easier to follow would something like:
struct person {
string name;
string email_address;
phone_number home;
phone_number mobile;
};
map<string, person> people;
This let's me (for example) use a nickname as the key to look up the name, email address, phone numbers, etc. for a person.
You can't take the <string, string>
part separately because it's a modifier to map
.
map
is a template type, and <string, string>
refers to the types it uses. map<string, string>
means a map
whose key type is string
and whose value type is also string
.