mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 10:07:41 +08:00
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:
@@ -1272,11 +1272,13 @@ template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_T
|
||||
|
||||
// decay
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS decay
|
||||
{
|
||||
private:
|
||||
typedef typename remove_reference<_Tp>::type _Up;
|
||||
template <class _Up, bool>
|
||||
struct __decay {
|
||||
typedef typename remove_cv<_Up>::type type;
|
||||
};
|
||||
|
||||
template <class _Up>
|
||||
struct __decay<_Up, true> {
|
||||
public:
|
||||
typedef typename conditional
|
||||
<
|
||||
@@ -1291,6 +1293,15 @@ public:
|
||||
>::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
|
||||
template <class _Tp> using decay_t = typename decay<_Tp>::type;
|
||||
#endif
|
||||
|
@@ -33,4 +33,10 @@ int main()
|
||||
test_decay<int[3], int*>();
|
||||
test_decay<const int[3], const int*>();
|
||||
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
|
||||
}
|
||||
|
Reference in New Issue
Block a user