[Support] Fix ErrorOr equality operator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237970 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Michael J. Spencer 2015-05-21 23:15:00 +00:00
parent 56409de6c4
commit b86942cca4
2 changed files with 7 additions and 2 deletions

View File

@ -281,8 +281,8 @@ template <class T, class E>
typename std::enable_if<std::is_error_code_enum<E>::value ||
std::is_error_condition_enum<E>::value,
bool>::type
operator==(ErrorOr<T> &Err, E Code) {
return std::error_code(Err) == Code;
operator==(const ErrorOr<T> &Err, E Code) {
return Err.getError() == Code;
}
} // end namespace llvm

View File

@ -66,6 +66,11 @@ TEST(ErrorOr, Covariant) {
ErrorOr<std::unique_ptr<int>> b4(b3);
}
TEST(ErrorOr, Comparison) {
ErrorOr<int> x(std::errc::no_such_file_or_directory);
EXPECT_EQ(x, std::errc::no_such_file_or_directory);
}
// ErrorOr<int*> x(nullptr);
// ErrorOr<std::unique_ptr<int>> y = x; // invalid conversion
static_assert(