diff --git a/src/uvw/check.hpp b/src/uvw/check.hpp index 8b66bf31..34d9fb0e 100644 --- a/src/uvw/check.hpp +++ b/src/uvw/check.hpp @@ -31,8 +31,8 @@ public: } void start(std::function cb) noexcept { - using UVCB = UVCallback; - auto func = UVCB::get(this); + using UVCB = UVCallback; + auto func = UVCB::get<&Check::startCallback>(this); startCb = std::move(cb); auto err = uv_check_start(get(), func); diff --git a/src/uvw/resource.hpp b/src/uvw/resource.hpp index ea286236..b72fc5c7 100644 --- a/src/uvw/resource.hpp +++ b/src/uvw/resource.hpp @@ -19,24 +19,24 @@ template class Resource; -template +template struct UVCallback { - template + template static auto get(T *res); private: - template + template static void proto(Args... args); }; template class Resource: public std::enable_shared_from_this { - template + template friend struct UVCallback; static Resource* closeCallback(uv_handle_t* h) { - auto ptr = static_cast*>(h->data); + auto *ptr = static_cast*>(h->data); ptr->closeCb(UVWError{}); return ptr; } @@ -72,8 +72,8 @@ public: bool referenced() const noexcept { return !(uv_has_ref(get()) == 0); } void close(std::function cb) noexcept { - using UVCB = UVCallback; - auto func = UVCB::get, &closeCallback>(this); + using UVCB = UVCallback, uv_handle_t*>; + auto func = UVCB::template get<&Resource::closeCallback>(this); closeCb = std::move(cb); uv_close(get(), func); } @@ -86,19 +86,19 @@ private: }; -template -template -void UVCallback::proto(Args... args) { +template +template +void UVCallback::proto(Args... args) { T *res = F(std::forward(args)...); res->ref = nullptr; } -template -template -auto UVCallback::get(T *res) { +template +template +auto UVCallback::get(T *res) { res->template get()->data = res; res->ref = res->shared_from_this(); - return &proto; + return &UVCallback::proto; } diff --git a/src/uvw/timer.hpp b/src/uvw/timer.hpp index 353fcf8d..8b3189a0 100644 --- a/src/uvw/timer.hpp +++ b/src/uvw/timer.hpp @@ -35,8 +35,8 @@ public: } void start(const Time &timeout, const Time &rep, std::function cb) noexcept { - using UVCB = UVCallback; - auto func = UVCB::get(this); + using UVCB = UVCallback; + auto func = UVCB::get<&Timer::startCallback>(this); startCb = std::move(cb); auto err = uv_timer_start(get(), func, timeout.count(), rep.count());