在Qt文档中我们读到:
bool QSharedPointer::operator! () const
Returns true if this object is null.
This function is suitable for use in if-constructs, like:
if (!sharedptr) { ... }
Run Code Online (Sandbox Code Playgroud)
和
bool QSharedPointer::isNull () const
Returns true if this object is holding a reference to a null pointer.
Run Code Online (Sandbox Code Playgroud)
这两个功能有什么区别?这很清楚什么是对空指针的引用,但这意味着什么
"如果对象为空"?
什么决定是否QSharedPointer 为空?这些功能如何对应QSharedPointer::data() != null?