Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lldb/include/lldb/Utility/NonNullSharedPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ template <typename T> class NonNullSharedPtr : private std::shared_ptr<T> {
public:
NonNullSharedPtr(const std::shared_ptr<T> &t)
: Base(t ? t : std::make_shared<T>()) {
assert(t && "NonNullSharedPtr initialized from NULL shared_ptr");
assert(t && "NonNullSharedPtr constructed from nullptr");
}

NonNullSharedPtr(std::shared_ptr<T> &&t)
: Base(t ? std::move(t) : std::make_shared<T>()) {
// Can't assert on t as it's been moved-from.
NonNullSharedPtr(std::shared_ptr<T> &&t) : Base(std::move(t)) {
const auto b = static_cast<bool>(*this);
assert(b && "NonNullSharedPtr constructed from nullptr");
if (!b)
Base::operator=(std::make_shared<T>());
}

NonNullSharedPtr(const NonNullSharedPtr &other) : Base(other) {}
Expand Down
Loading