diff --git a/src/uvw/event.hpp b/src/uvw/event.hpp index 7ae29444..300e186b 100644 --- a/src/uvw/event.hpp +++ b/src/uvw/event.hpp @@ -34,6 +34,9 @@ struct Event: BaseEvent { struct ErrorEvent: Event { explicit ErrorEvent(int code = 0) noexcept: ec(code) { } + template::value>> + explicit ErrorEvent(U val) noexcept: ec{static_cast(val)} { } + const char * what() const noexcept { return uv_strerror(ec); } int code() const noexcept { return ec; } diff --git a/src/uvw/tty.hpp b/src/uvw/tty.hpp index c1e2102a..636e006a 100644 --- a/src/uvw/tty.hpp +++ b/src/uvw/tty.hpp @@ -30,9 +30,7 @@ class TTY final: public Stream { explicit TTY(std::shared_ptr ref, FileHandle desc, bool readable) - : Stream{std::move(ref)}, - fd{static_cast(desc)}, - rw{readable} + : Stream{std::move(ref)}, fd{desc}, rw{readable} { } public: diff --git a/src/uvw/util.hpp b/src/uvw/util.hpp index c8a7cfde..db2b69d6 100644 --- a/src/uvw/util.hpp +++ b/src/uvw/util.hpp @@ -47,7 +47,12 @@ private: template struct UVTypeWrapper { using Type = T; + + template::value>> + constexpr UVTypeWrapper(U val): value{static_cast(val)} { } + constexpr UVTypeWrapper(Type val): value{val} { } + constexpr operator Type() const noexcept { return value; } private: const Type value;