I'm having trouble understanding an error. I'm working with a straightforward map of vectors (keyed by strings and storing vectors of strings):
typedef std::map<std::string, std::vector<std::string> > TRouteMarkets;
The following code (stripped down),
void CFoo::Bar(const char* route, const char* market)
{
// ...
TRouteMarkets::key_type key(route);
TRouteMarkets::mapped_type mapped();
TRouteMarkets::value_type pair(key, mapped);
// ...
}
produces the following error:
"Foo.cc", line 518: Error: Could not find a match for std::pair<const std::string, std::vector<std::string>>::pair(const std::string, std::vector<std::string>()) needed in CFoo::Bar(const char*, const char*).
But removing the ()
from mapped, i.e.
TRouteMarkets::mapped_type mapped;
fixes the error. Why? Isn't mapped
an empty vector of strings in either case?