2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-09-22 10:09:06 +00:00

Add QPDFObjectHandle::operator bool

This commit is contained in:
m-holger 2024-06-17 16:29:34 +01:00 committed by m-holger
parent bcf56e5333
commit 5a33c75b98
2 changed files with 20 additions and 0 deletions

View File

@ -295,6 +295,11 @@ class QPDFObjectHandle
QPDF_DLL
QPDFObjectHandle& operator=(QPDFObjectHandle const&) = default;
// Return true if the QPDFObjectHandle is initialized. This allows object handles to be used in
// if statements with initializer.
QPDF_DLL
explicit inline operator bool() const noexcept;
QPDF_DLL
inline bool isInitialized() const;
@ -1634,5 +1639,10 @@ QPDFObjectHandle::isInitialized() const
return obj != nullptr;
}
inline QPDFObjectHandle::operator bool() const noexcept
{
return static_cast<bool>(obj);
}
#endif // QPDF_FUTURE
#endif // QPDFOBJECTHANDLE_HH

View File

@ -295,6 +295,11 @@ class QPDFObjectHandle
QPDF_DLL
QPDFObjectHandle& operator=(QPDFObjectHandle&&) = default;
// Return true if the QPDFObjectHandle is initialized. This allows object handles to be used in
// if statements with initializer.
QPDF_DLL
explicit inline operator bool() const noexcept;
QPDF_DLL
inline bool isInitialized() const noexcept;
@ -1634,4 +1639,9 @@ QPDFObjectHandle::isInitialized() const noexcept
return obj != nullptr;
}
inline QPDFObjectHandle::operator bool() const noexcept
{
return static_cast<bool>(obj);
}
#endif // QPDFOBJECTHANDLE_FUTURE_HH