As a long-time C++ developer, this is absolutely spot on. One change you might wish to make:
If having std::find is forcing you into defining an operator==() that you didn't otherwise want, you might want to look at std::find_if, which takes a UnaryPredicate - basically a functor accepting a single value. Conveniently, this can be a lambda.
It achieves the same thing (and, likely, with the same CPU instructions), but you've kept the required definition of equality for this purpose next to the point of use, instead of defining it globally.
As a long-time C++ developer, this is absolutely spot on. One change you might wish to make:
If having
std::find
is forcing you into defining anoperator==()
that you didn't otherwise want, you might want to look atstd::find_if
, which takes a UnaryPredicate - basically a functor accepting a single value. Conveniently, this can be a lambda.So you'd do:
It achieves the same thing (and, likely, with the same CPU instructions), but you've kept the required definition of equality for this purpose next to the point of use, instead of defining it globally.
Ah, perfect! That does make sense, I'll probably refactor.
Typo: t.row == other.col