David White wrote:
Construct a size_t:

if(i->second.side() == size_t(player_number_)) {
As pointed out to me by Rusty, this function-style syntax is actually semantically the same as a C-style cast for builtin types. For years I had thought it was similar to a static_cast, because my copy of "The C++ Programming Language" by Stroustrup said so -- but an errata to the book clarifies that the notations (T)a and T(a) are equivalent when T is a builtin type.

Because of this, I would ask that we prefer static_cast, since it offers better type safety, though I do acknowledge it's rather ugly and am happy to leave a little room for coder discretion.

Thanks to Rusty for pointing this out.

David

Reply via email to