#include<iostream>
#include<boost/lambda/lambda.hpp>
#include<boost/lambda/if.hpp>
#include<boost/lambda/bind.hpp>
#include<vector>
using namespace std;
int main()
{
using namespace boost::lambda;
std::vector<int> vec;
vec.push_back(1);
vec.push_back(2);
vec.push_back(3);
vec.push_back(4);
std::for_each(
vec.begin(),
vec.end(),
if_(_1<=2)
[
std::cout<<_1<<'\n'
]
.else_
[
std::cout<<constant("Skip.\n")
]
);
std::for_each(
vec.begin(),
vec.end(),
if_then_else(
_1<=2,
std::cout<<_1<<'\n',
std::cout<<constant("Skip\n")
)
);
return 0;
}
这里展示了一个典型的if else语句
其实还有其它的语句,好好看吧,绝对期待