您的位置:首页 > 编程语言 > C语言/C++

使用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的元素个数

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