Advertisement
Da_Gamer

C# to C++ lambda

Feb 29th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.34 KB | None | 0 0
  1. //C#
  2. List<int> elements = new List<int>() { 10, 20, 31, 40 };
  3. // ... Find index of first odd element.
  4. int oddIndex = elements.FindIndex(x => x % 2 != 0);
  5. Console.WriteLine(oddIndex);
  6.  
  7. //C++
  8. Vector<int> elements = { 10, 20, 31, 40 };
  9. int oddIndex = elements.findIndex(begin, end, [](int x) {return x % 2 != 0});
  10. cout << oddIndex << endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement