diff options
author | Howard Hinnant <hhinnant@apple.com> | 2012-02-28 19:47:38 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2012-02-28 19:47:38 +0000 |
commit | 9bb1429f202175497d27e9d1364869a21e3d47c6 (patch) | |
tree | 43ef5621a5ec14f803fefcb4be2b333e9d8d35d3 | |
parent | 0bd3913d9607b273b239a3ddb5199bc38b818658 (diff) | |
download | bcm5719-llvm-9bb1429f202175497d27e9d1364869a21e3d47c6.tar.gz bcm5719-llvm-9bb1429f202175497d27e9d1364869a21e3d47c6.zip |
Reduce the number of move constructions when constructing a std::function. This fixes http://llvm.org/bugs/show_bug.cgi?id=12105.
llvm-svn: 151652
-rw-r--r-- | libcxx/include/functional | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/libcxx/include/functional b/libcxx/include/functional index f941df261fe..884a5777351 100644 --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -989,9 +989,23 @@ class __func<_Fp, _Alloc, _Rp(_ArgTypes...)> __compressed_pair<_Fp, _Alloc> __f_; public: _LIBCPP_INLINE_VISIBILITY - explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {} + explicit __func(_Fp&& __f) + : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), + _VSTD::forward_as_tuple()) {} _LIBCPP_INLINE_VISIBILITY - explicit __func(_Fp __f, _Alloc __a) : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} + explicit __func(const _Fp& __f, const _Alloc& __a) + : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), + _VSTD::forward_as_tuple(__a)) {} + + _LIBCPP_INLINE_VISIBILITY + explicit __func(const _Fp& __f, _Alloc&& __a) + : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), + _VSTD::forward_as_tuple(_VSTD::move(__a))) {} + + _LIBCPP_INLINE_VISIBILITY + explicit __func(_Fp&& __f, _Alloc&& __a) + : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), + _VSTD::forward_as_tuple(_VSTD::move(__a))) {} virtual __base<_Rp(_ArgTypes...)>* __clone() const; virtual void __clone(__base<_Rp(_ArgTypes...)>*) const; virtual void destroy() _NOEXCEPT; |