<div dir="ltr">Hello everyone!<div><div><div>It looks like in the LLVM codebase (including subprojects) there are some inconsistencies <br><div>in how values are returned from functions with the following (or similar) signature:</div><div>    Expected<std::vector<int>> createVector() {</div><div>        std::vector<int> V;</div><div>        ... </div><div>    }</div><div>It would be interesting to find out your opinion on this.</div><div>After some investigation I have found <a href="https://reviews.llvm.org/D70963">https://reviews.llvm.org/D70963</a> and <a href="https://reviews.llvm.org/D43322">https://reviews.llvm.org/D43322</a> which have some additional context regarding </div></div><div>the problem. The aforementioned diffs (and the comments on them) contain a lot of</div></div></div><div>details and the history of the problem (whether one should use the cast or not).</div><div>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.</div><div><br></div><div>Many thanks in advance,</div><div>Alexander Shaposhnikov</div><div><br></div></div>