Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 530 Bytes

for_each.md

File metadata and controls

19 lines (15 loc) · 530 Bytes

for_each

Description : Applies the given Function Object f to each element of the container in range [first, last)

Example :

       class Display {
        public: 
            void operator() (int i){ 
            std::cout << i << " ";
            }
       };
       
      std::vector<int> a{3,2,3,9};
      // Applying the function object Display to each element of a 
      std::for_each(a.begin(), a.end(), Display()); // Will output, 3 2 3 9
      

Run Code