考虑以下三个语句:
std::map<int, std::string> foo;
std::map<int, std::string>::value_type;
decltype(foo)::value_type;
为什么最后一个不合法?我认为那decltype(foo)
将是一个运算符,产生std::map<int, std::string>
可从中提取的地图类型value_type
。
我正在使用MSVC2012。
GCC和Clang允许使用这种语法,您的编译器无法正确实现C ++ 11。
您可以执行以下操作:
std::map<int, std::string> foo;
std::map<int, std::string>::value_type;
using some_type = decltype(foo);
some_type::value_type;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句