Creating lambda expressions with multiple inputs - C++ STL

C++ examples for STL:Lambda

Description

Creating lambda expressions with multiple inputs

Demo Code

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

void CompareRanges(vector<int>& vect, int values[])
{
    auto Result =
        equal(vect.begin(), vect.end(), values,
              [](int x, int y){return x==y;});

    cout.setf(ios::boolalpha);//from  w ww.j a  v  a2  s  .  c  o m
    cout << "The values are equal: " << Result << endl;
}

int main()
{
    vector<int> myV;
    myV.push_back(1);
    myV.push_back(2);
    myV.push_back(3);
    myV.push_back(4);

    int MyInts[] = {1, 2, 3, 4};

    CompareRanges(myV, MyInts);
}

Result


Related Tutorials