minor changes

This commit is contained in:
Michele Caini 2016-07-27 18:09:08 +02:00
parent e39410607a
commit ea93560c7c
3 changed files with 9 additions and 3 deletions

View File

@ -34,6 +34,9 @@ struct Event: BaseEvent {
struct ErrorEvent: Event<ErrorEvent> {
explicit ErrorEvent(int code = 0) noexcept: ec(code) { }
template<typename U, typename = std::enable_if_t<std::is_convertible<U, int>::value>>
explicit ErrorEvent(U val) noexcept: ec{static_cast<int>(val)} { }
const char * what() const noexcept { return uv_strerror(ec); }
int code() const noexcept { return ec; }

View File

@ -30,9 +30,7 @@ class TTY final: public Stream<TTY, uv_tty_t> {
explicit TTY(std::shared_ptr<Loop> ref,
FileHandle desc,
bool readable)
: Stream{std::move(ref)},
fd{static_cast<FileHandle::Type>(desc)},
rw{readable}
: Stream{std::move(ref)}, fd{desc}, rw{readable}
{ }
public:

View File

@ -47,7 +47,12 @@ private:
template<typename T>
struct UVTypeWrapper {
using Type = T;
template<typename U, typename = std::enable_if_t<std::is_convertible<U, T>::value>>
constexpr UVTypeWrapper(U val): value{static_cast<T>(val)} { }
constexpr UVTypeWrapper(Type val): value{val} { }
constexpr operator Type() const noexcept { return value; }
private:
const Type value;