From 269963f90fa882869c3a33c8c9ecba41351cb27d Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 9 Apr 2018 17:45:54 +0000 Subject: Make pdfium::span<> be based off of UnownedPtr<>. Because we can get the lifetime check for free if we do this. This requires adding some "constexpr/noexcept" to UnownedPtr to make the types line up with what span.h requires. Change-Id: I45918f8723122082036eed959f769644ab4c509f Reviewed-on: https://pdfium-review.googlesource.com/29672 Commit-Queue: Tom Sepez Reviewed-by: dsinclair --- core/fxcrt/unowned_ptr.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'core') diff --git a/core/fxcrt/unowned_ptr.h b/core/fxcrt/unowned_ptr.h index b1c9c66b3e..0e3bf9e09b 100644 --- a/core/fxcrt/unowned_ptr.h +++ b/core/fxcrt/unowned_ptr.h @@ -40,25 +40,25 @@ namespace fxcrt { template class UnownedPtr { public: - UnownedPtr() = default; - UnownedPtr(const UnownedPtr& that) : UnownedPtr(that.Get()) {} + constexpr UnownedPtr() noexcept = default; + constexpr UnownedPtr(const UnownedPtr& that) noexcept = default; template - explicit UnownedPtr(U* pObj) : m_pObj(pObj) {} + explicit constexpr UnownedPtr(U* pObj) noexcept : m_pObj(pObj) {} // Deliberately implicit to allow returning nullptrs. // NOLINTNEXTLINE(runtime/explicit) - UnownedPtr(std::nullptr_t ptr) {} + constexpr UnownedPtr(std::nullptr_t ptr) noexcept {} ~UnownedPtr() { ProbeForLowSeverityLifetimeIssue(); } - UnownedPtr& operator=(T* that) { + UnownedPtr& operator=(T* that) noexcept { ProbeForLowSeverityLifetimeIssue(); m_pObj = that; return *this; } - UnownedPtr& operator=(const UnownedPtr& that) { + UnownedPtr& operator=(const UnownedPtr& that) noexcept { ProbeForLowSeverityLifetimeIssue(); if (*this != that) m_pObj = that.Get(); @@ -81,7 +81,7 @@ class UnownedPtr { return !(*this == that); } - T* Get() const { return m_pObj; } + T* Get() const noexcept { return m_pObj; } T* Release() { ProbeForLowSeverityLifetimeIssue(); -- cgit v1.2.3