Boost::lambda

来源:互联网 发布:电脑windows什么意思 编辑:程序博客网 时间:2024/04/30 01:31

google了很久终于找到一篇我能读懂的lambda文章了,见传送门:http://club.topsage.com/thread-2276569-1-1.html

例:采用lambda编写一个找出字符串中大写字母的程序

#include<iostream>#include<algorithm>#include<string>#include<cctype>#include<boost/lambda/lambda.hpp>#include<boost/lambda/if.hpp>using namespace std;using namespace boost::lambda;int main(){    string s("Hello World!");    for_each(s.begin(),s.end(),if_then(_1>64&&_1<91,cout<<_1<<" "));    cout<<endl;    return 0;}

程序输出:

H W

原创粉丝点击