C++ Lambda Expressions Creation with multiple inputs

Description

C++ Lambda Expressions Creation with multiple inputs

#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  ww w  .j a v  a 2 s .  c om*/
    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);
}



PreviousNext

Related