mirror of
https://github.com/hyprwm/hyprutils.git
synced 2025-12-20 04:40:08 +01:00
signal: check for trivially copyable
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.
This commit is contained in:
parent
1c527b30fe
commit
30d86801f6
1 changed files with 4 additions and 1 deletions
|
|
@ -26,10 +26,13 @@ namespace Hyprutils {
|
|||
template <typename... Args>
|
||||
class CSignalT : public CSignalBase {
|
||||
template <typename T>
|
||||
using RefArg = std::conditional_t<std::is_reference_v<T> || std::is_arithmetic_v<T>, T, const T&>;
|
||||
using RefArg = std::conditional_t<std::is_trivially_copyable_v<T>, T, const T&>;
|
||||
|
||||
public:
|
||||
void emit(RefArg<Args>... args) {
|
||||
if (m_vListeners.empty() && m_vStaticListeners.empty())
|
||||
return;
|
||||
|
||||
if constexpr (sizeof...(Args) == 0)
|
||||
emitInternal(nullptr);
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue