This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Avoid #include <functional> in other headers


The <functional> header is pretty large, especially in C++17 mode
because the searchers include <vector> and <unordered_map>. This
tweaks other headers to avoid including it unnecessarily.

We could reduce things much further by splitting std::function and
std::reference_wrapper into their own headers, which I'm working on.
This kind of internal refactoring helps counteract the fact that the
library keep growing with each new standard revision so the headers
are larger and larger.

Any time we reduce interdepencies within the library headers we cause
compilation errors for some user code, but the fix is just to add the
missing headers. I'll mention this in the GCC 7 porting-to doc nearer
the release.

	* include/bits/shared_ptr_base.h: Include <functional>.
	[!__cpp_rtti]: Do not include <typeinfo>.
	* include/experimental/array: Do not include <functional>.
	* include/experimental/memory: Include <bits/functional_hash.h>
	instead of <functional>.
	* include/experimental/propagate_const: Include <bits/stl_function.h>,
	<bits/functional_hash.h>, and <bits/move.h> instead of <functional>.
	* include/experimental/tuple: Do not include <functional>.
	* include/std/future: Include <functional>.
	* include/std/memory: Do not include <functional>.
	* include/std/mutex: [_GLIBCXX_HAVE_TLS]: Likewise.
	* testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc: Add
	missing includes.
	* testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc: Likewise.
	* testsuite/20_util/specialized_algorithms/memory_management_tools/
	1.cc: Likewise.
	* testsuite/30_threads/call_once/60497.cc: Likewise.
	* testsuite/30_threads/lock/2.cc: Likewise.
	* testsuite/30_threads/thread/native_handle/cancel.cc: Likewise.
	* testsuite/experimental/algorithm/sample.cc: Likewise.
	* testsuite/experimental/array/make_array.cc: Likewise.
	* testsuite/experimental/array/neg.cc: Likewise. Adjust dg-error line.
	* testsuite/experimental/propagate_const/assignment/move_neg.cc:
	Adjust dg-error lines.
	* testsuite/experimental/propagate_const/cons/move_neg.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements2.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements3.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements4.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements5.cc: Likewise.

Tested powerpc64le-linux (without PCH), committed to trunk.


Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]