Suppose I have a vector A = {1 0 1 1 0 0 0 1 0} . Now I want to get the indices of all occurrences of 0 returned as another vector B
template< class InputIt, class T> std::vector<int> IndicesOf(InputIt first, InputIt last, const T& value) { }
Here is the start:
std::vector<int>::iterator iter = std::find_if(A.begin(), A.end(), 0); B = std::distance(A.begin(), iter);
Hum source share