Iostream, when all of the files it includes, the files that those include, and so on and so forth, adds up to about 3000 lines.
Consider the hello world program, which needs no more functionality than to print something to the screen:
#include <iostream> //+3000 lines right there.
int main()
{
std::cout << "Hello, World!";
return 0;
}
this should be a very simple piece of code, but iostream adds 3000+ lines to a marginal piece of code. So, are these 3000+ lines of code really needed to simply display a single line to the screen, and if not, do they create a less efficient program than if I simply copied the relevant lines into the code?
If you worry about the size of
<iostream>when all you want is print a line of text, try<cstdio>andstd::puts().(Seriously, why do people use
printf()orcoutwhen the much simpler and quickerputs()fits the bill perfectly? It even appends an appropriate line feed automatically…)In a serious application, the size and compile time of
<iostream>won’t be significant. (Plus, as others already noted, the linker won’t link in what isn’t used.)Edit: I just realized I didn’t really answer the question. No, not all the 3000 lines are really required to print the line of code, but you’ll find it next to impossible to find “the few lines” required to produce your line of output, as I/O library source tends to be heavily interdependent. And aside from increasing compile times a bit, they don’t harm – your code does not get any less efficient as the “fluff” is dropped at linker stage.