vendredi 27 février 2015

C++ - Range based loops for iterators - Why is this complaining?

Essentially, I have a 2D Vector:



std::vector<std::vector<double> > vect = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
};


I pass this vector into a function using iterators:



template<typename Inverse>
void Diag(Inverse begin, Inverse end)
{
for(auto row : begin)
{
for(auto col : row)
{

}
}
}


I pass to the function like: Diag(std::begin(vect), std::end(vect))


But I keep getting complained at that there is no matching function, even though I have seen similar range based loops Here.


An example can be found Here


Aucun commentaire:

Enregistrer un commentaire