diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2018-05-09 14:28:11 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2018-05-09 14:28:11 +0100 |
commit | 88b1e41c2d9d2e9f5c0ae2d1a09da41d76184280 (patch) | |
tree | e898f8b7f1c15e8de320cf1d3b76ec85331873c8 /gcc | |
parent | a296d6d3bdd83a617e789641b828ff53f65a4ec6 (diff) | |
download | gcc-88b1e41c2d9d2e9f5c0ae2d1a09da41d76184280.zip gcc-88b1e41c2d9d2e9f5c0ae2d1a09da41d76184280.tar.gz gcc-88b1e41c2d9d2e9f5c0ae2d1a09da41d76184280.tar.bz2 |
Make std::function tolerate semantically non-CopyConstructible objects
To satisfy the CopyConstructible requirement a callable object stored in
a std::function must behave the same when copied from a const or
non-const source. If copying a non-const object doesn't produce an
equivalent copy then the behaviour is undefined. But we can make our
std::function more tolerant of such objects by ensuring we always copy
from a const lvalue.
Additionally use an if constexpr statement in the _M_get_pointer
function to avoid unnecessary instantiations in the discarded branch.
* include/bits/std_function.h (_Base_manager::_M_get_pointer):
Use constexpr if in C++17 mode.
(_Base_manager::_M_clone(_Any_data&, const _Any_data&, true_type)):
Copy from const object.
* testsuite/20_util/function/cons/non_copyconstructible.cc: New.
From-SVN: r260080
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions