1. NULL -> nullptr
2. auto和decltype
3. {}初始化列表
4. typedef -> using
5. 范围for
6. std::function 函数包装器
需要使用头文件 #include <functional>
7. std::bind
//查找集合中大于5且小于等于10的元素个数
auto f = std::bind(std::logical_and<bool>(),
std::bind(std::greater<int>(), std::placeholders::_1, 5),
std::bind(std::lesss_equal<int>(), std::placeholders::_1, 10));
int count = std::count_if(coll.begin(), coll.end(), f);
8. lambda
int count = std::count_if(coll.begin(), coll.end(), [](int x){return x > 5 && x < 10;});
本文详细介绍了C++11标准中引入的一些关键新特性,包括nullptr的使用、auto和decltype关键字、初始化列表、using替代typedef、范围for循环、std::function的应用、std::bind的高级用法以及lambda表达式的简洁实现方式。
17万+

被折叠的 条评论
为什么被折叠?



