Horje
std distance Code 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




Cpp

Related
int main() { Code Example int main() { Code Example
insert element in array c++ Code Example insert element in array c++ Code Example
what is a variable in cpp Code Example what is a variable in cpp Code Example
c++ colored output Code Example c++ colored output Code Example
priority queue c++ Code Example priority queue c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10