摘要: 到了C++11最激动人心的特性了:匿名函数:lambda表达式假设你有一个vector v, 想知道里面大于4的数有多少个。for循环谁都会写,但是STL提供了现成算法count_if,不用可惜。C++03时代,我们会这样写:#include #include #include using namespace std;bool gt4(int x){ return x>4;}struct GT4{ bool operator()(int x){ return x>4; }};int main(){ vector v; 很多v.push_back(...... 阅读全文
posted @ 2013-11-22 21:50 NPBool 阅读(4116) 评论(3) 推荐(0) 编辑