<algorithm> includes <limits> or why is it compiled?
#include <algorithm> int main() { std::numeric_limits<__int64>::min(); } <algorithm> includes <limits> or why is it compiled?
#include <algorithm> int main() { std::numeric_limits<__int64>::min(); } I will try to answer in more detail what has already been said in the commentary on the question.
Indeed, the Language Standard does not specify which header files may include others. At the same time, due to the vastness of the library, the presence of interconnections between the individual components, of course, cannot be avoided.
However, it is worth bearing in mind that every function, variable, etc. (in general, to any name) some header file (or even several) is associated. It is this header file that should be connected via #include in order to avoid the appearance of compilation errors when porting code to another compiler, or even a different version of the same compiler.
For example, the following code:
#include <iostream> //#include <functional> int main() { std::function<void(void)> f; } compiled to clang , but not compiled to gcc . If you include <functional> explicitly, the code should be compiled in any compiler. In particular, it begins to gather in gcc .
Source: https://ru.stackoverflow.com/questions/500615/
All Articles