Make std::is_assignable tolerate references to incomplete types.

llvm-svn: 276599
This commit is contained in:
Eric Fiselier 2016-07-25 02:08:55 +00:00
parent 189f88ca35
commit 79586dca74
2 changed files with 10 additions and 18 deletions

View File

@ -2036,26 +2036,15 @@ template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
template <class _Tp, class _Arg> template <class _Tp, class _Arg>
typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __is_assignable_test(int);
__is_assignable_test(_Tp&&, _Arg&&);
#else template <class, class>
__is_assignable_test(_Tp, _Arg&); false_type __is_assignable_test(...);
#endif
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> template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
struct __is_assignable_imp struct __is_assignable_imp
: public common_type : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
<
decltype(_VSTD::__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
>::type {};
template <class _Tp, class _Arg> template <class _Tp, class _Arg>
struct __is_assignable_imp<_Tp, _Arg, true> struct __is_assignable_imp<_Tp, _Arg, true>

View File

@ -43,7 +43,7 @@ void test_is_not_assignable()
struct D; struct D;
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #if TEST_STD_VER >= 11
struct C struct C
{ {
template <class U> template <class U>
@ -59,6 +59,8 @@ struct E
template <typename T> template <typename T>
struct X { T t; }; struct X { T t; };
struct Incomplete;
int main() int main()
{ {
test_is_assignable<int&, int&> (); test_is_assignable<int&, int&> ();
@ -67,7 +69,7 @@ int main()
test_is_assignable<B, A> (); test_is_assignable<B, A> ();
test_is_assignable<void*&, void*> (); test_is_assignable<void*&, void*> ();
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #if TEST_STD_VER >= 11
test_is_assignable<E, int> (); test_is_assignable<E, int> ();
test_is_not_assignable<int, int&> (); test_is_not_assignable<int, int&> ();
@ -80,4 +82,5 @@ int main()
// pointer to incomplete template type // pointer to incomplete template type
test_is_assignable<X<D>*&, X<D>*> (); test_is_assignable<X<D>*&, X<D>*> ();
test_is_not_assignable<Incomplete&, Incomplete const&>();
} }