使用C++11
2015-09-21 20:03
357 查看
1. NULL -> nullptr
2. auto和decltype
3. {}初始化列表
4. typedef -> using
5. 范围for
6. std::function 函数包装器
需要使用头文件 #include <functional>
7. std::bind
//查找集合中大于5且小于等于10的元素个数
8. lambda
int count = std::count_if(coll.begin(), coll.end(), [](int x){return x > 5 && x < 10;});
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;});
相关文章推荐
- 在 Qt4 中使用 C++11
- centos安装devtoolset-3支持gcc 4.9.2
- 使用eclipse编译含有C++11特性的代码
- eclipse支持c++11
- C++11可变参数函数与for循环
- vs2013 编译c++是发现惊天bug
- 简单性能测试函数模板
- 关于C++现状的一些思考
- 用C++11优化矩阵运算的空间和时间效率
- 浅析构造函数之默认构造函数
- c++中返回数组的函数
- C++函数重载的几个问题
- C++11 现代C++风格的新元素
- c++11 lambda表达式浅谈
- C++11之“move”语意
- C++11之Lambda表达式
- C++11特性乱弹
- 掀起C++ 11的神秘面纱(1)
- 掀起C++ 11的神秘面纱(2)
- Pascal's Triangle II