[libcxx] r192142 - Fix LWG Issue 2141: common_type trait produces reference types
Marshall Clow
mclow.lists at gmail.com
Mon Oct 7 16:43:33 PDT 2013
Author: marshall
Date: Mon Oct 7 18:43:33 2013
New Revision: 192142
URL: http://llvm.org/viewvc/llvm-project?rev=192142&view=rev
Log:
Fix LWG Issue 2141: common_type trait produces reference types
Modified:
libcxx/trunk/include/type_traits
libcxx/trunk/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp
libcxx/trunk/www/cxx1y_status.html
Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=192142&r1=192141&r2=192142&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Mon Oct 7 18:43:33 2013
@@ -719,6 +719,31 @@ template <class _Tp, size_t _Np> struct
template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
#endif
+// decay
+
+template <class _Tp>
+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 <class _Tp> using decay_t = typename decay<_Tp>::type;
+#endif
+
// is_abstract
namespace __is_abstract_imp
@@ -1356,7 +1381,7 @@ template <class ..._Tp> struct common_ty
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp>
{
- typedef _Tp type;
+ typedef typename decay<_Tp>::type type;
};
template <class _Tp, class _Up>
@@ -1367,7 +1392,7 @@ private:
static _Up&& __u();
static bool __f();
public:
- typedef typename remove_reference<decltype(__f() ? __t() : __u())>::type type;
+ typedef typename decay<decltype(__f() ? __t() : __u())>::type type;
};
template <class _Tp, class _Up, class ..._Vp>
@@ -1546,29 +1571,6 @@ public:
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-template <class _Tp>
-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 <class _Tp> using decay_t = typename decay<_Tp>::type;
-#endif
-
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Tp>
Modified: libcxx/trunk/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp?rev=192142&r1=192141&r2=192142&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp Mon Oct 7 18:43:33 2013
@@ -18,10 +18,24 @@ int main()
static_assert((std::is_same<std::common_type<int>::type, int>::value), "");
static_assert((std::is_same<std::common_type<char>::type, char>::value), "");
#if _LIBCPP_STD_VER > 11
- static_assert((std::is_same<std::common_type_t<int>, int>::value), "");
+ static_assert((std::is_same<std::common_type_t<int>, int>::value), "");
static_assert((std::is_same<std::common_type_t<char>, char>::value), "");
#endif
+ static_assert((std::is_same<std::common_type< int>::type, int>::value), "");
+ static_assert((std::is_same<std::common_type<const int>::type, int>::value), "");
+ static_assert((std::is_same<std::common_type< volatile int>::type, int>::value), "");
+ static_assert((std::is_same<std::common_type<const volatile int>::type, int>::value), "");
+
+ static_assert((std::is_same<std::common_type<int, int>::type, int>::value), "");
+ static_assert((std::is_same<std::common_type<int, const int>::type, int>::value), "");
+
+ static_assert((std::is_same<std::common_type<long, const int>::type, long>::value), "");
+ static_assert((std::is_same<std::common_type<const long, int>::type, long>::value), "");
+ static_assert((std::is_same<std::common_type<long, volatile int>::type, long>::value), "");
+ static_assert((std::is_same<std::common_type<volatile long, int>::type, long>::value), "");
+ static_assert((std::is_same<std::common_type<const long, const int>::type, long>::value), "");
+
static_assert((std::is_same<std::common_type<double, char>::type, double>::value), "");
static_assert((std::is_same<std::common_type<short, char>::type, int>::value), "");
#if _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp?rev=192142&r1=192141&r2=192142&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp Mon Oct 7 18:43:33 2013
@@ -19,8 +19,8 @@ void test_is_trivially_copyable()
{
static_assert( std::is_trivially_copyable<T>::value, "");
static_assert( std::is_trivially_copyable<const T>::value, "");
- static_assert( std::is_trivially_copyable<volatile T>::value, "");
- static_assert( std::is_trivially_copyable<const volatile T>::value, "");
+ static_assert(!std::is_trivially_copyable<volatile T>::value, "");
+ static_assert(!std::is_trivially_copyable<const volatile T>::value, "");
}
template <class T>
Modified: libcxx/trunk/www/cxx1y_status.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1y_status.html?rev=192142&r1=192141&r2=192142&view=diff
==============================================================================
--- libcxx/trunk/www/cxx1y_status.html (original)
+++ libcxx/trunk/www/cxx1y_status.html Mon Oct 7 18:43:33 2013
@@ -184,7 +184,7 @@
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2231">2231</a></td><td>DR 704 removes complexity guarantee for clear()</td><td>Bristol</td><td>Complete</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2235">2235</a></td><td>Undefined behavior without proper requirements on basic_string constructors</td><td>Bristol</td><td>Complete</td></tr>
<tr><td></td><td></td><td></td><td></td></tr>
- <tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2141">2141</a></td><td>common_type trait produces reference types</td><td>Chicago</td><td></td></tr>
+ <tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2141">2141</a></td><td>common_type trait produces reference types</td><td>Chicago</td><td>Complete</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2235">2235</a></td><td>Undefined behavior without proper requirements on basic_string constructors</td><td>Chicago</td><td></td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2246">2246</a></td><td>unique_ptr assignment effects w.r.t. deleter</td><td>Chicago</td><td></td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2247">2247</a></td><td>Type traits and std::nullptr_t</td><td>Chicago</td><td>Complete</td></tr>
More information about the cfe-commits
mailing list