4 ms·
This is a bit like saying there is no '+'; Because if you put in return 1+2+3; And look at the assembly code, you will see that the compiler generated so
by RcouF1uZ4gsC 5y ago
This is a bit like saying there is no '+';
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).
- malkia 5y agoIs there more info to this, I remember this from Commmon Lisp (but details evade me) that the compiler can take benefit of certain specific functions and rely on them being... "open coded" - e.g. it can produce more efficient code by replacing these with something more suitable... http://www.sbcl.org/manual/#Open-Coding-and-Inline-Expansion http://www.sbcl.org/manual/#Open-Coding-and-Inline-Expansion https://www.thecodingforums.com/threads/what-is-the-meaning-of-the-term-open-coded-in-the-following-extract.541773 https://www.thecodingforums.com/threads/what-is-the-meaning-...
- talaketu 5y ago> more efficient code that does the same thing In this case, it produces a different result.
- Someone 5y agoCode that does #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.
- gpderetta 5y agoWell not really. The preprocessor is part of the compiler, so it only needs set a flag to tell the compiler proper to enable std::vector.
- dnautics 5y agoyeah but everyone knows that "there is no +"; It's an operator, and in C, anyways operators are special and expected to not necessarily do C-function-ey things, e.g, "take arguments of different types and add them successfully" not everyone is aware that C has "anointed functions" (including, I believe malloc) that the compiler is allowed to fiddle with.