C++ Lambda Expressions detection of return type by compiler
#include <iostream> #include <algorithm> #include <vector> using namespace std; void ProcessVector(vector<int>& vect) { vector<bool> Result; Result.resize(vect.size()); //from w ww. j a va2s . co m transform(vect.begin(), vect.end(), Result.begin(), [](int x){return x > 3;}); cout.setf(ios::boolalpha); for_each(Result.begin(), Result.end(), [](bool x){cout << x << endl;}); } int main() { vector<int> myV; myV.push_back(1); myV.push_back(2); myV.push_back(3); myV.push_back(4); ProcessVector(myV); }