diff --git a/src/uvw/underlying_type.hpp b/src/uvw/underlying_type.hpp index b2d8756a..c8ec2e89 100644 --- a/src/uvw/underlying_type.hpp +++ b/src/uvw/underlying_type.hpp @@ -17,6 +17,9 @@ namespace uvw { */ template class UnderlyingType { + template + friend class UnderlyingType; + protected: struct ConstructorAccess { explicit ConstructorAccess(int) {} }; @@ -34,12 +37,22 @@ protected: return reinterpret_cast(&resource); } + template + auto get(UnderlyingType &other) noexcept { + return reinterpret_cast(&other.resource); + } + template auto get() const noexcept { static_assert(not std::is_same::value, "!"); return reinterpret_cast(&resource); } + template + auto get(const UnderlyingType &other) const noexcept { + return reinterpret_cast(&other.resource); + } + public: explicit UnderlyingType(ConstructorAccess, std::shared_ptr ref) noexcept : pLoop{std::move(ref)}, resource{}