Std::distance Include Code Example


Example: std distance

// Calculates the number of elements between first and last.  #include <iterator>     									// std::distance #include <vector>     										// std::vector #include <algorithm>   							// Just if you use std::find  vector<int> arr = {2,5,3,8,1}; int size = std::distance(arr.begin(), arr.end()); 			// 5  auto it = std::find(arr.begin(), arr.end(), 8); int position = std::distance(arr.begin(), it); 				// 3

Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?