forked from OSchip/llvm-project
Make std::is_assignable tolerate references to incomplete types.
llvm-svn: 276599
This commit is contained in:
parent
189f88ca35
commit
79586dca74
|
@ -2036,26 +2036,15 @@ template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
|
|||
|
||||
template <class _Tp, class _Arg>
|
||||
typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
__is_assignable_test(_Tp&&, _Arg&&);
|
||||
#else
|
||||
__is_assignable_test(_Tp, _Arg&);
|
||||
#endif
|
||||
__is_assignable_test(int);
|
||||
|
||||
template <class, class>
|
||||
false_type __is_assignable_test(...);
|
||||
|
||||
template <class _Arg>
|
||||
false_type
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
__is_assignable_test(__any, _Arg&&);
|
||||
#else
|
||||
__is_assignable_test(__any, _Arg&);
|
||||
#endif
|
||||
|
||||
template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
|
||||
struct __is_assignable_imp
|
||||
: public common_type
|
||||
<
|
||||
decltype(_VSTD::__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
|
||||
>::type {};
|
||||
: public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
|
||||
|
||||
template <class _Tp, class _Arg>
|
||||
struct __is_assignable_imp<_Tp, _Arg, true>
|
||||
|
|
|
@ -43,7 +43,7 @@ void test_is_not_assignable()
|
|||
|
||||
struct D;
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if TEST_STD_VER >= 11
|
||||
struct C
|
||||
{
|
||||
template <class U>
|
||||
|
@ -59,6 +59,8 @@ struct E
|
|||
template <typename T>
|
||||
struct X { T t; };
|
||||
|
||||
struct Incomplete;
|
||||
|
||||
int main()
|
||||
{
|
||||
test_is_assignable<int&, int&> ();
|
||||
|
@ -67,7 +69,7 @@ int main()
|
|||
test_is_assignable<B, A> ();
|
||||
test_is_assignable<void*&, void*> ();
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
#if TEST_STD_VER >= 11
|
||||
test_is_assignable<E, int> ();
|
||||
|
||||
test_is_not_assignable<int, int&> ();
|
||||
|
@ -80,4 +82,5 @@ int main()
|
|||
|
||||
// pointer to incomplete template type
|
||||
test_is_assignable<X<D>*&, X<D>*> ();
|
||||
test_is_not_assignable<Incomplete&, Incomplete const&>();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue