[llvm-dev] preferred way to return expected values
Alexander Shaposhnikov via llvm-dev
llvm-dev at lists.llvm.org
Sat Sep 26 15:17:20 PDT 2020
Hello everyone!
It looks like in the LLVM codebase (including subprojects) there are some
inconsistencies
in how values are returned from functions with the following (or similar)
signature:
Expected<std::vector<int>> createVector() {
std::vector<int> V;
...
}
It would be interesting to find out your opinion on this.
After some investigation I have found https://reviews.llvm.org/D70963 and
https://reviews.llvm.org/D43322 which have some additional context
regarding
the problem. The aforementioned diffs (and the comments on them) contain a
lot of
details and the history of the problem (whether one should use the cast or
not).
If I am not mistaken a part of the problem is that compilers' behaviors
have changed over time, and e.g. the latest versions would use a move
constructor while the older ones could use a copy constructor. So the
question is where we stand at the moment / what is the recommended approach
for the new code.
Many thanks in advance,
Alexander Shaposhnikov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200926/1e5bff04/attachment.html>
More information about the llvm-dev
mailing list