In my project several STL headers are used in different files. I read that, putting all these headers into a single header and using that header in my files will allow compilers to precompile the header which may lead into faster compile time.
If I understood it correctly, I need to write like the following.
// stl.hpp
#include <string>
#include <algorithm>
#include <vector>
Now include stl.hpp in all the files that needs access to STL. Is this correct?
Few of my files will be using only functionality from vector header file. But if I follow the above method, it will include unnecessary headers. Will this make any problem? Is there any code generated if I include a header file and not used anything from that?
Any help would be great!
C++ Templates - The complete guidesays, it does. I am not sure though.stl.hppis probably a misnomer. Whether<string>is part of the STL is at least debatable. (Note: The STL was a container/iterator/algorithm library, developed by Alexander Stepanov. It was incorporated into what was, until then, the draft C++ standard library, delaying the standardization of C++98 for about one year. While doing so, the language and the rest of the library was extended and the STL was changed, so that it all would fit together better. Among others,std::basic_stringgot a container interface, templates where extended, and the STL adopted to use the extended templates.)