Except that doesn't always mean what you think it means. If you originally did:
unsigned i = 0;
then the type of i is unsigned (obviously); but if you change that to auto as above, then the type of i becomes int because 0 is an int literal. If you want it to stay unsigned, then you have to be explicit:
auto i = 0u;
You have the same problem for short, long, long long, and their unsigned variants.
for (std::vector<int> row : matrix) {
This is incorrect. In the "older standards" (C++03 and earlier), range-based for loops weren't a thing yet. (Even if they were, it's still incorrect since you're missing ::const_iterator.) Range-based for loops were addd to C++ at the same time as auto in C++11, so your "older standards" code should have been:
for (std::vector<int>::const_itererator i = maxtrix.begin(); i != matrix.end(); ++i ) {
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Except that doesn't always mean what you think it means. If you originally did:
then the type of
i
isunsigned
(obviously); but if you change that toauto
as above, then the type ofi
becomesint
because0
is anint
literal. If you want it to stayunsigned
, then you have to be explicit:You have the same problem for
short
,long
,long long
, and their unsigned variants.This is incorrect. In the "older standards" (C++03 and earlier), range-based
for
loops weren't a thing yet. (Even if they were, it's still incorrect since you're missing::const_iterator
.) Range-basedfor
loops were addd to C++ at the same time asauto
in C++11, so your "older standards" code should have been: