Talk:Straddling checkerboard: Difference between revisions

→‎Min/max: Leave it in, for portablility
(→‎Min/max: Leave it in, for portablility)
Line 43:
::: In C and C++, removing headers and seeing if it compiles is ''never'' a good way to determine if a header is needed. It is very likely that your compiler's version of some other header you included (or some header it included, etc.) happen to have included <algorithm>, but it is possible that some other implementation of those same headers won't. To make your code portable you should always make sure to include the right headers for all the functions you use, from the language standard. min and max are defined in the <algorithm> header in section 25 (Algorithms library) of the C++ standard. Otherwise, what header do you think it's defined in? --[[User:Spoon!|Spoon!]] 20:02, 9 June 2011 (UTC)
:::: I don't really know where they're getting included. It works with both the major compilers, but it's fine to leave it as long as there's a reason. [[User:MagiMaster|MagiMaster]] 01:22, 10 June 2011 (UTC)
:::::For the record, in GCC, the file that defines min&max (stl_algobase.h) is included not only by algorithm.h, but also (at some level of #include depth) by any of the other headers being used: iostream, string, or map. I suspect that such under-the-cover inclusion would be the case in many compilers.
:::::After some thought, I agree with Spoon!. Since I have had trouble compiling the (never tested on GCC) C++ solutions of some other tasks, I encourage portable code. In this case, that means leaving the #include of algorithm intact, even though we do not know of a compiler that actually explicitly needs that header. --[[User:Util|Util]] 16:15, 11 June 2011 (UTC)
 
==Rename?==
256

edits