#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
using namespace std;
int main()
{
vector<int> v = {1,2,3,4,6,4,5};
// Get index of element from iterator
int index = distance(v.begin(), find(v.begin(), v.end(), 4));
cout << index;
}
int valueIndex = std::distance(
yourArray,
std::find(
yourArray,
yourArray + sizeof(yourArray) / sizeof(yourArray[0]),
yourValueToFind));
#include <iostream>
using namespace std;
Code Example |
---|
Cpp :: ue4 float to fstring |
Cpp :: convert unsigned long to string c++ |
Cpp :: c++ vector push if not exist |
Cpp :: break in c++ |
Cpp :: for loop c++ |
Cpp :: cpp get last element of vector |
Cpp :: std vector c++ |
Cpp :: continue statement in c++ program |
Cpp :: c++ thread incide class |
Cpp :: overload of << c++ |
Cpp :: push local branch to another remote branch |
Cpp :: log in c++ |
Cpp :: cpp vs c# |
Cpp :: detect cycle in an undirected graph |
Cpp :: c++ vector of class objects |
Cpp :: unordered_set to vector |
Cpp :: c++ check if string is isogram |
Cpp :: iterate over map c++ |
Cpp :: no template named vector in namespace std |
Cpp :: sum of a matrix c++ |
Cpp :: length of number c++ |
Cpp :: c++ multiple inheritance |
Cpp :: convert char to int c++ |
Cpp :: how to create a file in c++ |
Cpp :: define vector with size and value c++ |
Cpp :: vector size |
Cpp :: il2cpp stuck unity |
Cpp :: find text in string c++ true false |
Cpp :: Lambda capture as const cpp |
Cpp :: c++ regex count number of matches |