diff options
Diffstat (limited to 'include/cru/common')
-rw-r--r-- | include/cru/common/event.hpp | 11 | ||||
-rw-r--r-- | include/cru/common/format.hpp | 4 |
2 files changed, 8 insertions, 7 deletions
diff --git a/include/cru/common/event.hpp b/include/cru/common/event.hpp index 763f8378..6228d867 100644 --- a/include/cru/common/event.hpp +++ b/include/cru/common/event.hpp @@ -22,7 +22,7 @@ class Event { : resolver_(resolver), token_(token) {} EventHandlerRevokerImpl(const EventHandlerRevokerImpl& other) = default; EventHandlerRevokerImpl(EventHandlerRevokerImpl&& other) = default; - EventHandlerRevokerImpl& operator=(EventHandlerRevokerImpl&& other) = + EventHandlerRevokerImpl& operator=(const EventHandlerRevokerImpl& other) = default; EventHandlerRevokerImpl& operator=(EventHandlerRevokerImpl&& other) = default; @@ -31,7 +31,7 @@ class Event { void operator()() { const auto true_resolver = resolver_.lock(); if (true_resolver) { - true_resolver()->RemoveHandler(token_); + (*true_resolver)()->RemoveHandler(token_); } } @@ -63,10 +63,11 @@ class Event { return EventHandlerRevoker(EventHandlerRevokerImpl(event_resolver_, token)); } - template <typename... Args> - EventHandlerRevoker AddHandler(Args&& args...) { + template <typename Arg> + EventHandlerRevoker AddHandler(Arg&& handler) { + static_assert(std::is_invocable_v<Arg, TArgs...>, "Handler not invocable."); const auto token = current_token_++; - handlers_.emplace(token, EventHandler(std::forward<Args>(args)...)); + handlers_.emplace(token, EventHandler(std::forward<Arg>(handler))); return EventHandlerRevoker(EventHandlerRevokerImpl(event_resolver_, token)); } diff --git a/include/cru/common/format.hpp b/include/cru/common/format.hpp index 1fb6863a..f085635a 100644 --- a/include/cru/common/format.hpp +++ b/include/cru/common/format.hpp @@ -83,7 +83,7 @@ inline std::string_view FormatToString(const std::string& string, } inline std::wstring_view FormatToString(const std::wstring_view& string, - details::TypeTag<String>) { + details::TypeTag<std::wstring>) { return string; } @@ -93,7 +93,7 @@ inline std::string_view FormatToString(const std::string_view& string, } inline std::wstring_view FormatToString(const wchar_t* string, - details::TypeTag<String>) { + details::TypeTag<std::wstring>) { return std::wstring_view(string); } |