Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Latest commit

 

History

History
19 lines (15 loc) · 526 Bytes

for_each_n.md

File metadata and controls

19 lines (15 loc) · 526 Bytes

for_each_n

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_n(a.begin(), 2, Display()); // Will output, "3 2 "
      

Run Code