Fix PR#32606: std::decay mishandles abominable function types

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@299894 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2017-04-10 22:51:07 +00:00
parent 733ab2f9f0
commit c50c6b79c3
2 changed files with 22 additions and 5 deletions

View File

@@ -1272,11 +1272,13 @@ template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_T
// decay // decay
template <class _Tp> template <class _Up, bool>
struct _LIBCPP_TEMPLATE_VIS decay struct __decay {
{ typedef typename remove_cv<_Up>::type type;
private: };
typedef typename remove_reference<_Tp>::type _Up;
template <class _Up>
struct __decay<_Up, true> {
public: public:
typedef typename conditional typedef typename conditional
< <
@@ -1291,6 +1293,15 @@ public:
>::type type; >::type type;
}; };
template <class _Tp>
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 #if _LIBCPP_STD_VER > 11
template <class _Tp> using decay_t = typename decay<_Tp>::type; template <class _Tp> using decay_t = typename decay<_Tp>::type;
#endif #endif

View File

@@ -33,4 +33,10 @@ int main()
test_decay<int[3], int*>(); test_decay<int[3], int*>();
test_decay<const int[3], const int*>(); test_decay<const int[3], const int*>();
test_decay<void(), void (*)()>(); test_decay<void(), void (*)()>();
#if TEST_STD_VER > 11
test_decay<int(int) const, int(int) const>();
test_decay<int(int) volatile, int(int) volatile>();
test_decay<int(int) &, int(int) &>();
test_decay<int(int) &&, int(int) &&>();
#endif
} }