lundi 3 décembre 2018

How to use std::for_each over std::array<> and apply lambda function on each element?

I want to combine these three features together

  • std::for_each
  • std::array
  • lambda function

into one example using C++11.

 std::for_each(arr, arr + sizeof(arr) / sizeof(int), [&](int x) { std::cout<<x<<" ";});

How to convert that code to operate over std::array ?

Aucun commentaire:

Enregistrer un commentaire