by RcouF1uZ4gsC · 5y ago · 0 comments
Because if you put in
return 1+2+3;
And look at the assembly code, you will see that the compiler generated something like return 6;
The compiler is allowed to take advantage of the standard to substitute in more efficient code that does the same thing.IIRC, for C++, it would actually be ok if std::vector was implemented completely as a compiler intrinsic with no actual header file. (No compiler I am aware of actually does it that way).
#include <vector>
must compile, so that header must exist (whether it is stored in a file is the implementer’s choice. AFAIK, the standard carefully avoids the use of the term ‘header file’)Also, I think code that doesn’t do that include must fail to compile when it tries to use std::vector. So, logically, that header must exist.
https://www.thecodingforums.com/threads/what-is-the-meaning-...
In this case, it produces a different result.