diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2010-08-11 16:55:33 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2010-08-11 16:55:33 +0000 |
commit | 4c7aaebf4ddfac97a1c24373b0eb15ff8477fee7 (patch) | |
tree | 6517ed2811fbb0ecfc106613557b0588feba0aae /libstdc++-v3/include | |
parent | be94d007e60d246a60e90be3233d92d08b06d684 (diff) | |
download | gcc-4c7aaebf4ddfac97a1c24373b0eb15ff8477fee7.zip gcc-4c7aaebf4ddfac97a1c24373b0eb15ff8477fee7.tar.gz gcc-4c7aaebf4ddfac97a1c24373b0eb15ff8477fee7.tar.bz2 |
move.h (forward): Reinstate the N2835 version.
2010-08-11 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/move.h (forward): Reinstate the N2835 version.
From-SVN: r163101
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/bits/move.h | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/libstdc++-v3/include/bits/move.h b/libstdc++-v3/include/bits/move.h index d5243d2..9329cb4 100644 --- a/libstdc++-v3/include/bits/move.h +++ b/libstdc++-v3/include/bits/move.h @@ -51,16 +51,29 @@ _GLIBCXX_END_NAMESPACE _GLIBCXX_BEGIN_NAMESPACE(std) - /// forward - template<typename _Tp, typename _Up> - inline typename - enable_if<((std::is_convertible< - typename std::remove_reference<_Up>::type*, - typename std::remove_reference<_Tp>::type*>::value) - && (!std::is_lvalue_reference<_Tp>::value - || std::is_lvalue_reference<_Up>::value)), _Tp&&>::type - forward(_Up&& __u) - { return static_cast<_Tp&&>(__u); } + /// forward (as per N2835) + /// Forward lvalues as rvalues. + template<typename _Tp> + inline typename enable_if<!is_lvalue_reference<_Tp>::value, _Tp&&>::type + forward(typename std::common_type<_Tp>::type& __t) + { return static_cast<_Tp&&>(__t); } + + /// Forward rvalues as rvalues. + template<typename _Tp> + inline typename enable_if<!is_lvalue_reference<_Tp>::value, _Tp&&>::type + forward(typename std::common_type<_Tp>::type&& __t) + { return static_cast<_Tp&&>(__t); } + + // Forward lvalues as lvalues. + template<typename _Tp> + inline typename enable_if<is_lvalue_reference<_Tp>::value, _Tp>::type + forward(typename std::common_type<_Tp>::type __t) + { return __t; } + + // Prevent forwarding rvalues as const lvalues. + template<typename _Tp> + inline typename enable_if<is_lvalue_reference<_Tp>::value, _Tp>::type + forward(typename std::remove_reference<_Tp>::type&& __t) = delete; /** * @brief Move a value. |