aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/darwin.c
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2021-08-26 14:01:36 +0100
committerJonathan Wakely <jwakely@redhat.com>2021-08-27 00:12:54 +0100
commitd38d26be33aba5d4c12429478375a47c474124d2 (patch)
treec771210d2741aae1783e86489d3211d55bfa592a /gcc/config/darwin.c
parent8cf428bfd3ca967b3d135e311d3e391998a39335 (diff)
downloadgcc-d38d26be33aba5d4c12429478375a47c474124d2.zip
gcc-d38d26be33aba5d4c12429478375a47c474124d2.tar.gz
gcc-d38d26be33aba5d4c12429478375a47c474124d2.tar.bz2
libstdc++: Avoid a move in std::function construction (LWG 2447)
This makes the std::function constructor use perfect forwarding, to avoid an unnecessary move-construction of the target. This means we need to rewrite the _Function_base::_Base_manager::_M_init_functor function to use a forwarding reference, and so can reuse it for the clone operation. Also simplify the SFINAE constraints on the constructor, by combining the !is_same_v<remove_cvref_t<F>, function> constraint into the _Callable trait. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/bits/std_function.h (_function_base::_Base_manager): Replace _M_init_functor with a function template using a forwarding reference, and a pair of _M_create function templates. Reuse _M_create for the clone operation. (function::_Decay_t): New alias template. (function::_Callable): Simplify by using _Decay. (function::function(F)): Change parameter to forwarding reference, as per LWG 2447. Add noexcept-specifier. Simplify constraints. (function::operator=(F&&)): Add noexcept-specifier. * testsuite/20_util/function/cons/lwg2774.cc: New test. * testsuite/20_util/function/cons/noexcept.cc: New test.
Diffstat (limited to 'gcc/config/darwin.c')
0 files changed, 0 insertions, 0 deletions