From bd5f7828683cd4306c7709a4183d0f84a789401e Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 10 Apr 2017 22:51:07 +0000 Subject: [PATCH] Fix PR#32606: std::decay mishandles abominable function types llvm-svn: 299894 --- libcxx/include/type_traits | 21 ++++++++++++++++----- .../meta/meta.trans/meta.trans.other/decay.pass.cpp | 6 ++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index 277a9fb..ec158fc 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -1272,11 +1272,13 @@ template using remove_all_extents_t = typename remove_all_extents<_T // decay -template -struct _LIBCPP_TEMPLATE_VIS decay -{ -private: - typedef typename remove_reference<_Tp>::type _Up; +template +struct __decay { + typedef typename remove_cv<_Up>::type type; +}; + +template +struct __decay<_Up, true> { public: typedef typename conditional < @@ -1291,6 +1293,15 @@ public: >::type type; }; +template +struct _LIBCPP_TEMPLATE_VIS decay +{ +private: + typedef typename remove_reference<_Tp>::type _Up; +public: + typedef typename __decay<_Up, __is_referenceable<_Up>::value>::type type; +}; + #if _LIBCPP_STD_VER > 11 template using decay_t = typename decay<_Tp>::type; #endif diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp index bcd8398..4f45a03 100644 --- a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp @@ -33,4 +33,10 @@ int main() test_decay(); test_decay(); test_decay(); +#if TEST_STD_VER > 11 + test_decay(); + test_decay(); + test_decay(); + test_decay(); +#endif } -- 2.7.4