auto lambda = [] (auto x, auto y) {return (x + y); } //等同於 struct unnamed_lambda { template <typename T,typename U> auto operator()(T x, U y) const { return (x+y); } }; auto lambda = unnamed_lambda();
若是一個函數有多個返回路徑,那麼每一個返回路徑返回的值須要具備相同的類型。ios
auto f(int i) { if ( i < 0 ) return -1; else return 2.0 //編譯會報錯 }
class [[deprecated]] flaky { }; [[deprecated("Consider using something other than cranky")]] int cranky() { return 0; } int main() { flaky f; return cranky(); }
其餘ide
二進制常量之前綴0b(或0B)開頭,二進制數字緊隨其後。函數
單引號字符做爲數字分隔符,一百萬能夠是:1’000’000.00 或者 1’0’00’0’00.00spa
#include <iostream> int main() { int val = 0b11110000; std::cout << "Output mask: " << 0b1000'0001'1000'0000 << "\n"; std::cout << "Proposed salary: $" << 300'000.00 << "\n"; return 0; }