forked from qt-creator/qt-creator
Make every operator bool() explicit
operator bool() is a trap, but with explicit it's far safer, and we can use that now. Change-Id: I4e58631c94e87c00256c3ab3cff4fd2c5f632713 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
@@ -33,7 +33,7 @@ public:
|
|||||||
~FullySpecifiedType();
|
~FullySpecifiedType();
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
operator bool() const;
|
explicit operator bool() const;
|
||||||
|
|
||||||
Type *type() const;
|
Type *type() const;
|
||||||
void setType(Type *type);
|
void setType(Type *type);
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ public:
|
|||||||
trivial.utf16charOffset = last->utf16charOffset;
|
trivial.utf16charOffset = last->utf16charOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline operator bool() const
|
inline explicit operator bool() const
|
||||||
{ return first != last; }
|
{ return first != last; }
|
||||||
|
|
||||||
inline bool isValid() const
|
inline bool isValid() const
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator bool() const { return isValid(); }
|
explicit operator bool() const { return isValid(); }
|
||||||
|
|
||||||
const Type *type;
|
const Type *type;
|
||||||
bool isConstant;
|
bool isConstant;
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
, tryQmlDump(false), qmlDumpHasRelocatableFlag(true)
|
, tryQmlDump(false), qmlDumpHasRelocatableFlag(true)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
operator bool() const
|
explicit operator bool() const
|
||||||
{ return ! project.isNull(); }
|
{ return ! project.isNull(); }
|
||||||
|
|
||||||
bool isValid() const
|
bool isValid() const
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
inline IInterface *operator->() const { return m_instance; }
|
inline IInterface *operator->() const { return m_instance; }
|
||||||
inline IInterface *data() const { return m_instance; }
|
inline IInterface *data() const { return m_instance; }
|
||||||
inline bool isNull() const { return m_instance == 0; }
|
inline bool isNull() const { return m_instance == 0; }
|
||||||
inline operator bool() const { return !isNull(); }
|
explicit inline operator bool() const { return !isNull(); }
|
||||||
inline HRESULT hr() const { return m_hr; }
|
inline HRESULT hr() const { return m_hr; }
|
||||||
|
|
||||||
// This is for creating a IDebugClient from scratch. Not matches by a constructor,
|
// This is for creating a IDebugClient from scratch. Not matches by a constructor,
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public:
|
|||||||
explicit SymbolGroupValue(SymbolGroupNode *node, const SymbolGroupValueContext &c);
|
explicit SymbolGroupValue(SymbolGroupNode *node, const SymbolGroupValueContext &c);
|
||||||
SymbolGroupValue();
|
SymbolGroupValue();
|
||||||
|
|
||||||
operator bool() const { return isValid(); }
|
explicit operator bool() const { return isValid(); }
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
// Access children by name or index (0-based)
|
// Access children by name or index (0-based)
|
||||||
|
|||||||
@@ -511,7 +511,7 @@ public:
|
|||||||
ExtensionSystem::PluginManager::addObject(watch);
|
ExtensionSystem::PluginManager::addObject(watch);
|
||||||
}
|
}
|
||||||
|
|
||||||
operator bool() { return m_watched; }
|
explicit operator bool() { return m_watched; }
|
||||||
bool operator !() { return !m_watched; }
|
bool operator !() { return !m_watched; }
|
||||||
T &operator*() { return *m_watched; }
|
T &operator*() { return *m_watched; }
|
||||||
T *operator->() { return m_watched; }
|
T *operator->() { return m_watched; }
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace Internal {
|
|||||||
class EditorData
|
class EditorData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
operator bool() const { return formWindowEditor != 0; }
|
explicit operator bool() const { return formWindowEditor != 0; }
|
||||||
|
|
||||||
FormWindowEditor *formWindowEditor = nullptr;
|
FormWindowEditor *formWindowEditor = nullptr;
|
||||||
SharedTools::WidgetHost *widgetHost = nullptr;
|
SharedTools::WidgetHost *widgetHost = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user