我无法理解错误。我正在与载体的直接映射工作(由字符串键控和存储串的矢量):为什么在初始化空向量时圆括号有所作用?
typedef std::map<std::string, std::vector<std::string> > TRouteMarkets;
下面的代码(剥离下来),
void CFoo::Bar(const char* route, const char* market)
{
// ...
TRouteMarkets::key_type key(route);
TRouteMarkets::mapped_type mapped();
TRouteMarkets::value_type pair(key, mapped);
// ...
}
产生以下错误:
"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*).
但除去()
从映射,即
TRouteMarkets::mapped_type mapped;
修复了错误。为什么?两种情况下,是不是mapped
是一个空字符串向量?
阅读[最令人头疼的解析](http://en.wikipedia.org/wiki/Most_vexing_parse)。 – 2013-04-26 14:37:51
我们真的需要一个自动检查器来解决烦恼的解析和家庭问题。我从问题标题中得到了一个很好的想法,它会经常出现(c: – 2013-04-26 14:49:34
这不是最令人头疼的解析方法 – hmjd 2013-04-26 14:50:50