c++ 11
Lambda expressions
1 | // []() -> T {} |
作为predict1
2std::vector<int> s = {1, 2, 3, 5};
std::cout << std::all_of(s.begin(), s.end(), [](int x) { return x > 0;}) << "\n"; // 1
range-based for loop
1 | // for( range_declaration: range_expression) loop statement |
functor
A functor (or function object) is a C++ class that acts like a function. Functors are called using the same old function call syntax. To create a functor, we create a object that overloads the operator().
1 | // C++ program to demonstrate working of |
unique_ptr
每一个unique_ptr
与一个raw_ptr
绑定,当unique_ptr
out of scope, 会释放raw_ptr
分配的内存
特点
- 无法
copy
或者assign
,只能在unique_ptr
之间用std::move
进行移动
1 |
|