一、操作步骤:
工程文件 => Build Settings(All) => Apple LLVM 6.1 Language - C++
C++ Language Dialect: C++11 [-std=c++11]
C++ Standard Library: libc++ (LLVM C++ standard library with C++11 support)
二、测试代码(可编译通过即可):
void whatValue(int&& val) {
printf("R-Value: %d\n", val);
}
void whatValue(const int& val) {
printf("L-Value: %d\n", val);
}
void testRValue(int&& i) {
whatValue(i);
whatValue(std::move(i)); // g++ 不支持 std::move<int>(i); 这种写法
}
constexpr int getCstExpr() {
return 888;
}
void testFor11() {
int arrInt[5] = {1, 2, 3, 4, 5};
for (int& item : arrInt) {
item *= 2;
}
}
voi