Skip to content

Commit

Permalink
[Support] Fix ErrorOr equality operator.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237970 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Bigcheese committed May 21, 2015
1 parent 56409de commit b86942c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/llvm/Support/ErrorOr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions unittests/Support/ErrorOrTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit b86942c

Please sign in to comment.