[PATCH] Avoid unnecessary inclusion of <stdexcept> header

Jonathan Wakely jwakely@redhat.com
Thu Jun 6 15:38:00 GMT 2019


This can greatly reduce the amount of preprocessed code that is included
by other headers, because <stdexcept> depends on <string> which is huge.

	* include/std/array: Do not include <stdexcept>.
	* include/std/optional: Include <exception> and
	<bits/exception_defines.h> instead of <stdexcept>.

Preprocessed line counts for C++17 mode:

       <tuple> <memory> <map>
Before   25774    32453 31616
After     9925    23194 19062

Tested x86_64-linux, committed to trunk.

Once we have a gcc-10/porting_to.html page I'll note this change
there, because code relying on std::string and std::allocator being
defined by transitive includes will need to include the right headers.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 3721 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20190606/086c67cb/attachment.bin>


More information about the Libstdc++ mailing list