1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-30 13:24:10 +01:00

[util] Don't use if constexpr

Fixes compilation on GCC 6.3.
This commit is contained in:
Philip Rebohle 2019-05-15 03:18:23 +02:00
parent b3f61936d2
commit 192310d481
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99

View File

@ -18,6 +18,26 @@ namespace dxvk {
return object;
}
/**
* \brief Ref count methods for public references
*/
template<typename T, bool Public>
struct ComRef_ {
static void incRef(T* ptr) { ptr->AddRef(); }
static void decRef(T* ptr) { ptr->Release(); }
};
/**
* \brief Ref count methods for private references
*/
template<typename T>
struct ComRef_<T, false> {
static void incRef(T* ptr) { ptr->AddRefPrivate(); }
static void decRef(T* ptr) { ptr->ReleasePrivate(); }
};
/**
* \brief COM pointer
@ -27,7 +47,7 @@ namespace dxvk {
*/
template<typename T, bool Public = true>
class Com {
using ComRef = ComRef_<T, Public>;
public:
Com() { }
@ -107,21 +127,13 @@ namespace dxvk {
T* m_ptr = nullptr;
void incRef() const {
if (m_ptr != nullptr) {
if constexpr (Public)
m_ptr->AddRef();
else
m_ptr->AddRefPrivate();
}
if (m_ptr != nullptr)
ComRef::incRef(m_ptr);
}
void decRef() const {
if (m_ptr != nullptr) {
if constexpr (Public)
m_ptr->Release();
else
m_ptr->ReleasePrivate();
}
if (m_ptr != nullptr)
ComRef::decRef(m_ptr);
}
};