for (auto row_it = other.data.begin(); row_it != other.data.end(); ++row_it)
{
// code
}
}
Is this one of the situations where using auto is necessary? I see most websites have used auto. My second question is what's auto deduced to ? Can I write it myself too ?
auto it's some compile time thing when type deducing automatically
It is not necessary, but this is one of the cases when auto is approved in most coding standards (even in those that avoid using auto). Basically because the real type can be quite verbose. You can replace it with the real type, which is an iterator type of your container. E.g. if data is std::vector<int> then the type will likely be std::vector<int>::iterator
Thanks. (However the iterator must be const : std::vector<int>::const_iterator)
Yeah, that's why "likely" :D
Lol i didn't notice it.
Обсуждают сегодня