今更だけど、boost 初体験。
#include <iostream>
#include <algorithm>
#include <boost/lambda/lambda.hpp>
using namespace std;
using namespace boost::lambda;
int main()
{
int a[] = {1, 3, 3, 3, 4};
const int size = sizeof(a)/sizeof(int);
const int* i = find_if(&a[0], &a[size], _1 % 2 == 0);
if(i != a + size){
cout << "偶数あり" << endl;
}
else{
cout << "偶数なし" << endl;
}
return 0;
}
lambda がある。全然 C++ に見えないんだけど。一体どういう仕組みだ!?