<div dir="ltr">Yep, I'll ask for the explanation - at least at Google there's been some pushback on adding such a general purpose construct to the core library on the premise that there's often/usually a better design. Equally I've certainly seen some places it felt kind of right, for sure.</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Aug 30, 2018 at 9:07 PM Zachary Turner via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">zturner created this revision.<br>
zturner added reviewers: rnk, chandlerc, timshen, dblaikie.<br>
Herald added subscribers: dexonsmith, mgorny.<br>
<br>
This might be controversial, but this class is essentially a `variant<unique_ptr<T>, T&>`.  I can go into great detail about why I need this, but it's a huge wall of text, so unless anyone asks, I'll spare you the details.  The idea, however, is simple.  You can construct this class with a `unique_ptr<T>` or with a `T&`.  In the former case, the class owns the object, in the latter it doesn't.  Aside from that, it's a simple smart pointer with all the overloaded operators, structors, and other functionality you'd expect.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D51525" rel="noreferrer" target="_blank">https://reviews.llvm.org/D51525</a><br>
<br>
Files:<br>
  llvm/include/llvm/ADT/OwnedOrBorrowed.h<br>
  llvm/unittests/ADT/CMakeLists.txt<br>
  llvm/unittests/ADT/OwnedOrBorrowedTest.cpp<br>
<br>
</blockquote></div>