diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index 55fc7109efae..b6430fbbc9a6 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -719,6 +719,31 @@ template struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents template using remove_all_extents_t = typename remove_all_extents<_Tp>::type; #endif +// decay + +template +struct _LIBCPP_TYPE_VIS_ONLY decay +{ +private: + typedef typename remove_reference<_Tp>::type _Up; +public: + typedef typename conditional + < + is_array<_Up>::value, + typename remove_extent<_Up>::type*, + typename conditional + < + is_function<_Up>::value, + typename add_pointer<_Up>::type, + typename remove_cv<_Up>::type + >::type + >::type type; +}; + +#if _LIBCPP_STD_VER > 11 +template using decay_t = typename decay<_Tp>::type; +#endif + // is_abstract namespace __is_abstract_imp @@ -1356,7 +1381,7 @@ template struct common_type; template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp> { - typedef _Tp type; + typedef typename decay<_Tp>::type type; }; template @@ -1367,7 +1392,7 @@ private: static _Up&& __u(); static bool __f(); public: - typedef typename remove_reference::type type; + typedef typename decay::type type; }; template @@ -1546,29 +1571,6 @@ public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -template -struct _LIBCPP_TYPE_VIS_ONLY decay -{ -private: - typedef typename remove_reference<_Tp>::type _Up; -public: - typedef typename conditional - < - is_array<_Up>::value, - typename remove_extent<_Up>::type*, - typename conditional - < - is_function<_Up>::value, - typename add_pointer<_Up>::type, - typename remove_cv<_Up>::type - >::type - >::type type; -}; - -#if _LIBCPP_STD_VER > 11 -template using decay_t = typename decay<_Tp>::type; -#endif - #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template diff --git a/libcxx/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp b/libcxx/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp index 7f01e4ba0a75..91bf7e7654e0 100644 --- a/libcxx/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp +++ b/libcxx/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp @@ -18,10 +18,24 @@ int main() static_assert((std::is_same::type, int>::value), ""); static_assert((std::is_same::type, char>::value), ""); #if _LIBCPP_STD_VER > 11 - static_assert((std::is_same, int>::value), ""); + static_assert((std::is_same, int>::value), ""); static_assert((std::is_same, char>::value), ""); #endif + static_assert((std::is_same::type, int>::value), ""); + static_assert((std::is_same::type, int>::value), ""); + static_assert((std::is_same::type, int>::value), ""); + static_assert((std::is_same::type, int>::value), ""); + + static_assert((std::is_same::type, int>::value), ""); + static_assert((std::is_same::type, int>::value), ""); + + static_assert((std::is_same::type, long>::value), ""); + static_assert((std::is_same::type, long>::value), ""); + static_assert((std::is_same::type, long>::value), ""); + static_assert((std::is_same::type, long>::value), ""); + static_assert((std::is_same::type, long>::value), ""); + static_assert((std::is_same::type, double>::value), ""); static_assert((std::is_same::type, int>::value), ""); #if _LIBCPP_STD_VER > 11 diff --git a/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp b/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp index 547c346cd61d..d65882378fc4 100644 --- a/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp +++ b/libcxx/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp @@ -19,8 +19,8 @@ void test_is_trivially_copyable() { static_assert( std::is_trivially_copyable::value, ""); static_assert( std::is_trivially_copyable::value, ""); - static_assert( std::is_trivially_copyable::value, ""); - static_assert( std::is_trivially_copyable::value, ""); + static_assert(!std::is_trivially_copyable::value, ""); + static_assert(!std::is_trivially_copyable::value, ""); } template diff --git a/libcxx/www/cxx1y_status.html b/libcxx/www/cxx1y_status.html index 4d38b74b95e9..fa08395272b7 100644 --- a/libcxx/www/cxx1y_status.html +++ b/libcxx/www/cxx1y_status.html @@ -184,7 +184,7 @@ 2231DR 704 removes complexity guarantee for clear()BristolComplete 2235Undefined behavior without proper requirements on basic_string constructorsBristolComplete - 2141common_type trait produces reference typesChicago + 2141common_type trait produces reference typesChicagoComplete 2235Undefined behavior without proper requirements on basic_string constructorsChicago 2246unique_ptr assignment effects w.r.t. deleterChicago 2247Type traits and std::nullptr_tChicagoComplete