Skip to content

Commit 5ac060b

Browse files
authored
signal: check for trivially copyable (#95)
use is_trivially_copyable instead because is_arithmetic_v exludes small POD structs, enums, and certain trivially copyable types. also add a if guard in emit if we have no listeners, no point emitting.
1 parent 1c527b3 commit 5ac060b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

include/hyprutils/signal/Signal.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ namespace Hyprutils {
2626
template <typename... Args>
2727
class CSignalT : public CSignalBase {
2828
template <typename T>
29-
using RefArg = std::conditional_t<std::is_reference_v<T> || std::is_arithmetic_v<T>, T, const T&>;
29+
using RefArg = std::conditional_t<std::is_trivially_copyable_v<T>, T, const T&>;
3030

3131
public:
3232
void emit(RefArg<Args>... args) {
33+
if (m_vListeners.empty() && m_vStaticListeners.empty())
34+
return;
35+
3336
if constexpr (sizeof...(Args) == 0)
3437
emitInternal(nullptr);
3538
else {

0 commit comments

Comments
 (0)