Fix incorrect usage of std::is_assignable.

We want to check that we can assign to an lvalue here, not a prvalue.

llvm-svn: 324152
This commit is contained in:
Richard Smith 2018-02-02 22:29:54 +00:00
parent 9bbe8e68ed
commit 82aa6016a4
3 changed files with 12 additions and 12 deletions

View File

@ -39,16 +39,16 @@ static_assert(
// std::is_assignable and actually writing such an assignment.
#if !defined(_MSC_VER)
static_assert(
!std::is_assignable<ArrayRef<int *>, int *>::value,
!std::is_assignable<ArrayRef<int *>&, int *>::value,
"Assigning from single prvalue element");
static_assert(
!std::is_assignable<ArrayRef<int *>, int * &&>::value,
!std::is_assignable<ArrayRef<int *>&, int * &&>::value,
"Assigning from single xvalue element");
static_assert(
std::is_assignable<ArrayRef<int *>, int * &>::value,
std::is_assignable<ArrayRef<int *>&, int * &>::value,
"Assigning from single lvalue element");
static_assert(
!std::is_assignable<ArrayRef<int *>, std::initializer_list<int *>>::value,
!std::is_assignable<ArrayRef<int *>&, std::initializer_list<int *>>::value,
"Assigning from an initializer list");
#endif

View File

@ -40,22 +40,22 @@ std::ostream &operator<<(std::ostream &OS,
// std::is_assignable and actually writing such an assignment.
#if !defined(_MSC_VER)
static_assert(
!std::is_assignable<StringRef, std::string>::value,
!std::is_assignable<StringRef&, std::string>::value,
"Assigning from prvalue std::string");
static_assert(
!std::is_assignable<StringRef, std::string &&>::value,
!std::is_assignable<StringRef&, std::string &&>::value,
"Assigning from xvalue std::string");
static_assert(
std::is_assignable<StringRef, std::string &>::value,
std::is_assignable<StringRef&, std::string &>::value,
"Assigning from lvalue std::string");
static_assert(
std::is_assignable<StringRef, const char *>::value,
std::is_assignable<StringRef&, const char *>::value,
"Assigning from prvalue C string");
static_assert(
std::is_assignable<StringRef, const char * &&>::value,
std::is_assignable<StringRef&, const char * &&>::value,
"Assigning from xvalue C string");
static_assert(
std::is_assignable<StringRef, const char * &>::value,
std::is_assignable<StringRef&, const char * &>::value,
"Assigning from lvalue C string");
#endif

View File

@ -128,13 +128,13 @@ static_assert(
// ErrorOr<int*> x(nullptr);
// ErrorOr<std::unique_ptr<int>> y;
// y = x; // invalid conversion
static_assert(!std::is_assignable<ErrorOr<std::unique_ptr<int>>,
static_assert(!std::is_assignable<ErrorOr<std::unique_ptr<int>>&,
const ErrorOr<int *> &>::value,
"do not invoke explicit ctors in assignment");
// ErrorOr<std::unique_ptr<int>> x;
// x = ErrorOr<int*>(nullptr); // invalid conversion
static_assert(!std::is_assignable<ErrorOr<std::unique_ptr<int>>,
static_assert(!std::is_assignable<ErrorOr<std::unique_ptr<int>>&,
ErrorOr<int *> &&>::value,
"do not invoke explicit ctors in assignment");
} // end anon namespace