C++ - 我使用哪个编译器来使自动 eq = [ ](..) 语法工作?
C++ - Which compiler do I use to get the auto eq = [ ](...) syntax to work?
我正在尝试运行此处答案中列出的矢量代码中元素的出现次数。
但是我在这个函数中遇到了编译错误:
auto h = [](const std::string* s) {
return std::hash<std::string>()(*s);
};
在[ ]
周围陈述Expected expression
.我知道这与编译器有关。 我正在使用Xcode 5.0.2
,所以我可以选择更改编译器(我认为)。
然后我收到另一个编译错误:
std::unordered_map<const std::string*, size_t, decltype(h), decltype(eq)> m(v.size(), h, eq);
说明m(v.size(), h, eq)
部分周围的C++ requires a specifier for all declarations
。
我应该确保Xcode
使用哪个编译器进行编译才能使此代码正常工作?
更新:
我可以谷歌搜索这种auto = [ ](...)
表示法的特定名称吗?
你知道考虑什么标准吗?
尝试强制到 C++11,以覆盖这些lambda
结构和unordered_map
.
相关文章:
- 1d 智能指针不适用于语法 (*)++
- QSqlquery prepare()和bindvalue()不工作
- C++ - 我使用哪个编译器来使自动 eq = [ ](..) 语法工作?
- boost :: Spirit :: Qi-与语法结构中的实例成员一起工作
- 在这个c++.h文件中,类中的vector需要工作语法
- C++程序中存在SQL查询语法错误,但可在MySQL工作台中使用
- C++语法谁呼吁一个代码块-简化工作
- 这个 SFINAE C++语法是如何工作的
- 在 CUDA 中初始化 dim3 变量,"dim3 dimGrid(numBlocks);"语法如何工作?
- std::p iecewise_construct语法是如何工作的
- qtDebug()语法是如何工作的
- C++这个语法是如何工作的
- 头文件在一个#include中工作正常,在另一个#include中导致语法错误
- c++ 11 for循环语法不能正常工作
- 这是如何做的,而语法工作
- 多重赋值(a = b) = c语法是如何工作的?
- Boost::spirit::qi::parse语法不能正常工作
- 使用push_back向vector添加对象工作正常,但使用访问器语法[]添加对象不工作
- Visual Studio 2013语法高亮显示停止工作
- 这个 typedef 语法是如何工作的..