mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[Testing/Support] Remove the const_cast in TakeExpected
Summary: The const_cast in the "const" version of TakeExpected was quite dangerous, as the function does indeed modify the apparently const argument. I assume the reason the const overload was added was to make the function bind to xvalues(temporaries). That can be also achieved with rvalue references, so I use that instead. Using the ASSERT macros on const Expected objects will now become illegal, but I believe that is correct, as it is not actually possible to inspect the error stored in an Expected object without modifying it. Reviewers: zturner, chandlerc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34405 llvm-svn: 306001
This commit is contained in:
parent
df683d9665
commit
6694e4a6b1
@ -30,8 +30,8 @@ template <typename T> ExpectedHolder<T> TakeExpected(Expected<T> &Exp) {
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> ExpectedHolder<T> TakeExpected(const Expected<T> &Exp) {
|
template <typename T> ExpectedHolder<T> TakeExpected(Expected<T> &&Exp) {
|
||||||
return TakeExpected(const_cast<Expected<T> &>(Exp));
|
return TakeExpected(Exp);
|
||||||
}
|
}
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user