diff options
-rw-r--r-- | alc/backends/wasapi.cpp | 2 | ||||
-rw-r--r-- | common/comptr.h | 2 | ||||
-rw-r--r-- | common/intrusive_ptr.h | 2 | ||||
-rw-r--r-- | common/opthelpers.h | 14 |
4 files changed, 13 insertions, 7 deletions
diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp index 3d85e3e1..063fca98 100644 --- a/alc/backends/wasapi.cpp +++ b/alc/backends/wasapi.cpp @@ -463,7 +463,7 @@ struct WasapiProxy { const char *mParam; std::promise<HRESULT> mPromise; - operator bool() const noexcept { return mType != MsgType::QuitThread; } + explicit operator bool() const noexcept { return mType != MsgType::QuitThread; } }; static std::deque<Msg> mMsgQueue; static std::mutex mMsgQueueLock; diff --git a/common/comptr.h b/common/comptr.h index c238991a..ab9d4c53 100644 --- a/common/comptr.h +++ b/common/comptr.h @@ -49,7 +49,7 @@ public: return *this; } - operator bool() const noexcept { return mPtr != nullptr; } + explicit operator bool() const noexcept { return mPtr != nullptr; } T& operator*() const noexcept { return *mPtr; } T* operator->() const noexcept { return mPtr; } diff --git a/common/intrusive_ptr.h b/common/intrusive_ptr.h index cc82dea5..e1fc1f7b 100644 --- a/common/intrusive_ptr.h +++ b/common/intrusive_ptr.h @@ -74,7 +74,7 @@ public: return *this; } - operator bool() const noexcept { return mPtr != nullptr; } + explicit operator bool() const noexcept { return mPtr != nullptr; } T& operator*() const noexcept { return *mPtr; } T* operator->() const noexcept { return mPtr; } diff --git a/common/opthelpers.h b/common/opthelpers.h index 5e6f54cf..0b8b8210 100644 --- a/common/opthelpers.h +++ b/common/opthelpers.h @@ -12,16 +12,22 @@ * is not required to be true, but it can result in more optimal code for the * true path at the expense of a less optimal false path. */ -constexpr bool likely(bool expr) { return __builtin_expect(expr, true); } +template<typename T> +constexpr bool likely(T&& expr) noexcept +{ return __builtin_expect(static_cast<bool>(expr), true); } /* The opposite of likely(), optimizing for the case where the condition is * false. */ -constexpr bool unlikely(bool expr) { return __builtin_expect(expr, false); } +template<typename T> +constexpr bool unlikely(T&& expr) noexcept +{ return __builtin_expect(static_cast<bool>(expr), false); } #else -constexpr bool likely(bool expr) { return expr; } -constexpr bool unlikely(bool expr) { return expr; } +template<typename T> +constexpr bool likely(T&& expr) noexcept { return static_cast<bool>(expr); } +template<typename T> +constexpr bool unlikely(T&& expr) noexcept { return static_cast<bool>(expr); } #endif #define LIKELY(x) (likely(x)) #define UNLIKELY(x) (unlikely(x)) |