Author: marshall Date: Sun Nov 12 19:59:22 2017 New Revision: 318011 URL: http://llvm.org/viewvc/llvm-project?rev=318011&view=rev Log: Implement P0550R2: Transformation Trait remove_cvref
Added: libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/remove_cvref.pass.cpp Modified: libcxx/trunk/include/type_traits libcxx/trunk/www/cxx2a_status.html Modified: libcxx/trunk/include/type_traits URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=318011&r1=318010&r2=318011&view=diff ============================================================================== --- libcxx/trunk/include/type_traits (original) +++ libcxx/trunk/include/type_traits Sun Nov 12 19:59:22 2017 @@ -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; @@ -203,6 +204,8 @@ namespace std 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> using enable_if_t = typename enable_if<b,T>::type; // C++14 @@ -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(...); Added: libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/remove_cvref.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/remove_cvref.pass.cpp?rev=318011&view=auto ============================================================================== --- libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/remove_cvref.pass.cpp (added) +++ libcxx/trunk/test/std/utilities/meta/meta.trans/meta.trans.other/remove_cvref.pass.cpp Sun Nov 12 19:59:22 2017 @@ -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) &&>(); +} Modified: libcxx/trunk/www/cxx2a_status.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx2a_status.html?rev=318011&r1=318010&r2=318011&view=diff ============================================================================== --- libcxx/trunk/www/cxx2a_status.html (original) +++ libcxx/trunk/www/cxx2a_status.html Sun Nov 12 19:59:22 2017 @@ -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> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits