[PATCH] D51525: [ADT] Add a new class OwnedOrBorrowed<T>
Zachary Turner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 30 21:07:03 PDT 2018
zturner created this revision.
zturner added reviewers: rnk, chandlerc, timshen, dblaikie.
Herald added subscribers: dexonsmith, mgorny.
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.
https://reviews.llvm.org/D51525
Files:
llvm/include/llvm/ADT/OwnedOrBorrowed.h
llvm/unittests/ADT/CMakeLists.txt
llvm/unittests/ADT/OwnedOrBorrowedTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51525.163462.patch
Type: text/x-patch
Size: 5781 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180831/0d84fa87/attachment.bin>
More information about the llvm-commits
mailing list