Implement P0550R2: Transformation Trait remove_cvref

llvm-svn: 318011
This commit is contained in:
Marshall Clow 2017-11-13 03:59:22 +00:00
parent 23493f3777
commit fbb0a5aa3f
3 changed files with 67 additions and 1 deletions

View File

@ -150,6 +150,7 @@ namespace std
template <size_t Len, size_t Align = most_stringent_alignment_requirement>
struct aligned_storage;
template <size_t Len, class... Types> struct aligned_union;
template <class T> struct remove_cvref; // C++20
template <class T> struct decay;
template <class... T> struct common_type;
@ -202,6 +203,8 @@ namespace std
using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
template <std::size_t Len, class... Types>
using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
template <class T>
using remove_cvref_t = typename remove_cvref<T>::type; // C++20
template <class T>
using decay_t = typename decay<T>::type; // C++14
template <bool b, class T=void>
@ -1141,6 +1144,17 @@ template <class _Tp, class _Up>
struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
typename __uncvref<_Up>::type> {};
#if _LIBCPP_STD_VER > 17
// aligned_union - same as __uncvref
template <class _Tp>
struct remove_cvref {
using type = remove_cv_t<remove_reference_t<_Tp>>;
};
template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
#endif
struct __any
{
__any(...);

View File

@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
// type_traits
// remove_cvref
#include <type_traits>
#include "test_macros.h"
template <class T, class U>
void test_remove_cvref()
{
static_assert((std::is_same<typename std::remove_cvref<T>::type, U>::value), "");
static_assert((std::is_same< std::remove_cvref_t<T>, U>::value), "");
}
int main()
{
test_remove_cvref<void, void>();
test_remove_cvref<int, int>();
test_remove_cvref<const int, int>();
test_remove_cvref<const volatile int, int>();
test_remove_cvref<volatile int, int>();
// Doesn't decay
test_remove_cvref<int[3], int[3]>();
test_remove_cvref<int const [3], int[3]>();
test_remove_cvref<int volatile [3], int[3]>();
test_remove_cvref<int const volatile [3], int[3]>();
test_remove_cvref<void(), void ()>();
test_remove_cvref<int &, int>();
test_remove_cvref<const int &, int>();
test_remove_cvref<const volatile int &, int>();
test_remove_cvref<volatile int &, int>();
test_remove_cvref<int*, int*>();
test_remove_cvref<int(int) const, int(int) const>();
test_remove_cvref<int(int) volatile, int(int) volatile>();
test_remove_cvref<int(int) &, int(int) &>();
test_remove_cvref<int(int) &&, int(int) &&>();
}

View File

@ -64,7 +64,7 @@
<tr><td><a href="https://wg21.link/P0415R1">P0415R1</a></td><td>LWG</td><td>Constexpr for <tt>std::complex</tt></td><td>Albuquerque</td><td></td><td></td></tr>
<tr><td><a href="https://wg21.link/P0439R0">P0439R0</a></td><td>LWG</td><td>Make <tt>std::memory_order</tt> a scoped enumeration</td><td>Albuquerque</td><td></td><td></td></tr>
<tr><td><a href="https://wg21.link/P0457R2">P0457R2</a></td><td>LWG</td><td>String Prefix and Suffix Checking</td><td>Albuquerque</td><td></td><td></td></tr>
<tr><td><a href="https://wg21.link/P0550R2">P0550R2</a></td><td>LWG</td><td>Transformation Trait <tt>remove_cvref</tt></td><td>Albuquerque</td><td></td><td></td></tr>
<tr><td><a href="https://wg21.link/P0550R2">P0550R2</a></td><td>LWG</td><td>Transformation Trait <tt>remove_cvref</tt></td><td>Albuquerque</td><td></td><td>Complete</td></tr>
<tr><td><a href="https://wg21.link/P0600R1">P0600R1</a></td><td>LWG</td><td>nodiscard in the Library</td><td>Albuquerque</td><td></td><td></td></tr>
<tr><td><a href="https://wg21.link/P0616R0">P0616R0</a></td><td>LWG</td><td>de-pessimize legacy <numeric> algorithms with std::move</td><td>Albuquerque</td><td></td><td></td></tr>
<tr><td><a href="https://wg21.link/P0653R2">P0653R2</a></td><td>LWG</td><td>Utility to convert a pointer to a raw pointer</td><td>Albuquerque</td><td></td><td></td></tr>