forked from OSchip/llvm-project
Fix LWG Issue 2141: common_type trait produces reference types
llvm-svn: 192142
This commit is contained in:
parent
b66ae3f34f
commit
db78c7049e
|
@ -719,6 +719,31 @@ template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents
|
|||
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_type;
|
|||
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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue