[meta] Declare bool conversion operators as explicit

Non-explicit conversion operators in general can participate in very
surprising conversion chains. Explicit bool operator is a good place to
start with, because even with explicit they do get automatic contextual
conversion in a lot of places, e.g., if conditions.
This commit is contained in:
Tatsuyuki Ishi 2024-01-27 12:42:40 +09:00
parent b9c30a8e91
commit 646549e343
7 changed files with 10 additions and 10 deletions

View File

@ -81,7 +81,7 @@ namespace dxvk {
D3D9Memory (D3D9Memory&& other);
D3D9Memory& operator = (D3D9Memory&& other);
operator bool() const { return m_chunk != nullptr; }
explicit operator bool() const { return m_chunk != nullptr; }
void Map();
void Unmap();
@ -139,7 +139,7 @@ namespace dxvk {
D3D9Memory (D3D9Memory&& other);
D3D9Memory& operator = (D3D9Memory&& other);
operator bool() const { return m_ptr != nullptr; }
explicit operator bool() const { return m_ptr != nullptr; }
void Map() {}
void Unmap() {}

View File

@ -195,7 +195,7 @@ namespace dxvk {
const T* operator & () const { ensure(); return m_data.get(); }
T* operator & () { ensure(); return m_data.get(); }
operator bool() { return m_data != nullptr; }
explicit operator bool() const { return m_data != nullptr; }
operator T() { ensure(); return *m_data; }
void ensure() const { if (!m_data) m_data = std::make_unique<T>(); }
@ -213,7 +213,7 @@ namespace dxvk {
T& operator=(const T& x) { m_data = x; return m_data; }
operator bool() { return true; }
explicit operator bool() const { return true; }
operator T() { return m_data; }
const T* operator -> () const { return &m_data; }

View File

@ -196,7 +196,7 @@ namespace dxvk {
return out;
}
operator bool () const {
explicit operator bool () const {
return m_mask != 0;
}

View File

@ -350,7 +350,7 @@ namespace dxvk {
return m_chunk;
}
operator bool () const {
explicit operator bool () const {
return m_chunk != nullptr;
}

View File

@ -61,7 +61,7 @@ namespace dxvk {
* provided by the extension can be used.
* \returns \c true if the extension is enabled
*/
operator bool () const {
explicit operator bool () const {
return m_revision != 0;
}

View File

@ -158,7 +158,7 @@ namespace dxvk {
* \returns \c true if this slice points to actual device
* memory, and \c false if it is undefined.
*/
operator bool () const {
explicit operator bool () const {
return m_memory != VK_NULL_HANDLE;
}

View File

@ -239,7 +239,7 @@ namespace dxvk {
return m_page != other.m_page;
}
operator bool () const {
explicit operator bool () const {
return m_page != nullptr;
}
@ -341,7 +341,7 @@ namespace dxvk {
* \brief Checks whether page table is defined
* \returns \c true if the page table is defined
*/
operator bool () const {
explicit operator bool () const {
return m_buffer || m_image;
}