Apparently this got spam-filtered and didn't make it to the lists...
On 13/10/16 18:34 +0100, Jonathan Wakely wrote:
This splits the large (2200 lines) <functional> header into smaller
pieces, so there are separate headers for:
- std::less, std::equal_to etc. (already in their own header)
- std::__invoke (already in its own header)
- std::reference_wrapper (often used on its own, e.g. in <tuple>)
- std::function (using in <future> and <regex>)
Everything else (std::mem_fn, std::bind, std::not_fn, searchers) stays
in <functional>, because we don't actually need them elsewhere in the
library.
Code which doesn't need the whole of <functional> should include the
relevant <bits/*> header instead.
This means that we don't need to pull the whole of <functional> (and
<vector> and <unordered_map>) into <memory> just because shared_ptr
wants to use reference_wrapper in one place. This reduces <memory>
from 48kloc to 30kloc!
The patch is compressed because it's quite large, but it's mostly just
moving big blocks of code from <functional> into new headers.
Any objections?
* include/Makefile.am: Add <bits/refwrap.h> and <bits/std_function.h>.
Order alphabetically.
* include/Makefile.in: Regenerate.
* include/bits/refwrap.h: New header.
(_Maybe_get_result_type,_Weak_result_type_impl, _Weak_result_type)
(_Reference_wrapper_base_impl, _Reference_wrapper_base)
(reference_wrapper, ref, cref): Move here from <functional>.
* include/bits/shared_ptr_base.h: Include <bits/refwrap.h> and
<bits/stl_function.h> instead of <functional>.
* include/bits/std_function.h: New header.
(_Maybe_unary_or_binary_function, bad_function_call)
(__is_location_invariant, _Nocopy_types, _Any_data)
(_Simple_type_wrapper, _Function_base, _Function_handler, function):
Move here from <functional>.
* include/bits/unique_ptr.h: Include <bits/stl_function.h>.
* include/std/functional: Include new headers and move components to
them.
* include/std/future: Include <bits/std_function.h>.
* include/std/memory: Don't include <functional>.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust dg-error line.
* testsuite/20_util/default_delete/void_neg.cc: Likewise.
* testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc:
Include <functional>.
* testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc: Likewise.
* testsuite/20_util/specialized_algorithms/memory_management_tools/
1.cc: Include <vector>.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Adjust dg-error
lines.
* testsuite/20_util/unique_ptr/assign/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/cv_qual.cc: Likewise.
* testsuite/20_util/unique_ptr/modifiers/cv_qual.cc: Likewise.
* testsuite/30_threads/thread/native_handle/cancel.cc: Include
<functional>.