diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2017-09-18 12:40:10 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2017-09-18 12:40:10 +0100 |
commit | ec26ff5a012428ed864b679c7c171e2e7d917f76 (patch) | |
tree | 1ace52416e236fdd4f9678af0adb7f6003930acf /libstdc++-v3/include | |
parent | ba2c915e3d80d1a2fc231935f8bdcd1c7930a5f8 (diff) | |
download | gcc-ec26ff5a012428ed864b679c7c171e2e7d917f76.zip gcc-ec26ff5a012428ed864b679c7c171e2e7d917f76.tar.gz gcc-ec26ff5a012428ed864b679c7c171e2e7d917f76.tar.bz2 |
PR libstdc++/71187 reimplement declval without add_rvalue_reference
PR libstdc++/71187
* include/std/type_traits (__declval): New function to deduce return
type of declval.
(__declval_protector::_delegate): Remove.
(declval): Use __declval instead of add_rvalue_reference and
__declval_protector::__delegate.
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error
lineno.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
Likewise.
From-SVN: r252922
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/std/type_traits | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index f021c42..15b0d92 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -754,15 +754,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Destructible and constructible type properties. - template<typename> - struct add_rvalue_reference; - /** * @brief Utility to simplify expressions used in unevaluated operands * @ingroup utilities */ + + template<typename _Tp, typename _Up = _Tp&&> + _Up + __declval(int); + + template<typename _Tp> + _Tp + __declval(long); + template<typename _Tp> - typename add_rvalue_reference<_Tp>::type declval() noexcept; + auto declval() noexcept -> decltype(__declval<_Tp>(0)); template<typename, unsigned = 0> struct extent; @@ -2079,16 +2085,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __declval_protector { static const bool __stop = false; - static typename add_rvalue_reference<_Tp>::type __delegate(); }; template<typename _Tp> - inline typename add_rvalue_reference<_Tp>::type - declval() noexcept + auto declval() noexcept -> decltype(__declval<_Tp>(0)) { static_assert(__declval_protector<_Tp>::__stop, "declval() must not be used!"); - return __declval_protector<_Tp>::__delegate(); + return __declval<_Tp>(0); } /// result_of |