mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-07 16:54:14 +01:00
[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:
parent
afc6aa70fb
commit
e2a46a347d
@ -81,7 +81,7 @@ namespace dxvk {
|
|||||||
D3D9Memory (D3D9Memory&& other);
|
D3D9Memory (D3D9Memory&& other);
|
||||||
D3D9Memory& operator = (D3D9Memory&& other);
|
D3D9Memory& operator = (D3D9Memory&& other);
|
||||||
|
|
||||||
operator bool() const { return m_chunk != nullptr; }
|
explicit operator bool() const { return m_chunk != nullptr; }
|
||||||
|
|
||||||
void Map();
|
void Map();
|
||||||
void Unmap();
|
void Unmap();
|
||||||
@ -139,7 +139,7 @@ namespace dxvk {
|
|||||||
D3D9Memory (D3D9Memory&& other);
|
D3D9Memory (D3D9Memory&& other);
|
||||||
D3D9Memory& operator = (D3D9Memory&& other);
|
D3D9Memory& operator = (D3D9Memory&& other);
|
||||||
|
|
||||||
operator bool() const { return m_ptr != nullptr; }
|
explicit operator bool() const { return m_ptr != nullptr; }
|
||||||
|
|
||||||
void Map() {}
|
void Map() {}
|
||||||
void Unmap() {}
|
void Unmap() {}
|
||||||
|
@ -195,7 +195,7 @@ namespace dxvk {
|
|||||||
const T* operator & () const { ensure(); return m_data.get(); }
|
const T* operator & () const { ensure(); return m_data.get(); }
|
||||||
T* operator & () { 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; }
|
operator T() { ensure(); return *m_data; }
|
||||||
|
|
||||||
void ensure() const { if (!m_data) m_data = std::make_unique<T>(); }
|
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; }
|
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; }
|
operator T() { return m_data; }
|
||||||
|
|
||||||
const T* operator -> () const { return &m_data; }
|
const T* operator -> () const { return &m_data; }
|
||||||
|
@ -196,7 +196,7 @@ namespace dxvk {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator bool () const {
|
explicit operator bool () const {
|
||||||
return m_mask != 0;
|
return m_mask != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ namespace dxvk {
|
|||||||
return m_chunk;
|
return m_chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator bool () const {
|
explicit operator bool () const {
|
||||||
return m_chunk != nullptr;
|
return m_chunk != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ namespace dxvk {
|
|||||||
* provided by the extension can be used.
|
* provided by the extension can be used.
|
||||||
* \returns \c true if the extension is enabled
|
* \returns \c true if the extension is enabled
|
||||||
*/
|
*/
|
||||||
operator bool () const {
|
explicit operator bool () const {
|
||||||
return m_revision != 0;
|
return m_revision != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ namespace dxvk {
|
|||||||
* \returns \c true if this slice points to actual device
|
* \returns \c true if this slice points to actual device
|
||||||
* memory, and \c false if it is undefined.
|
* memory, and \c false if it is undefined.
|
||||||
*/
|
*/
|
||||||
operator bool () const {
|
explicit operator bool () const {
|
||||||
return m_memory != VK_NULL_HANDLE;
|
return m_memory != VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ namespace dxvk {
|
|||||||
return m_page != other.m_page;
|
return m_page != other.m_page;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator bool () const {
|
explicit operator bool () const {
|
||||||
return m_page != nullptr;
|
return m_page != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,7 +341,7 @@ namespace dxvk {
|
|||||||
* \brief Checks whether page table is defined
|
* \brief Checks whether page table is defined
|
||||||
* \returns \c true if the 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;
|
return m_buffer || m_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user