1 #ifndef UVW_UNDERLYING_TYPE_INCLUDE_H
2 #define UVW_UNDERLYING_TYPE_INCLUDE_H
19 template<
typename T,
typename U>
21 template<
typename,
typename>
25 struct ConstructorAccess {
explicit ConstructorAccess(
int) {} };
27 template<
typename R = U>
29 return reinterpret_cast<R *
>(&resource);
32 template<
typename R = U>
33 auto get()
const noexcept {
34 return reinterpret_cast<const R *
>(&resource);
37 template<
typename R,
typename... P>
39 return reinterpret_cast<R *
>(&other.resource);
43 explicit UnderlyingType(ConstructorAccess, std::shared_ptr<Loop> ref) noexcept
44 : pLoop{std::move(ref)}, resource{}
62 template<
typename... Args>
63 static std::shared_ptr<T>
create(Args&&... args) {
64 return std::make_shared<T>(ConstructorAccess{0}, std::forward<Args>(args)...);
71 Loop &
loop() const noexcept {
return *pLoop; }
88 const U *
raw() const noexcept {
112 std::shared_ptr<Loop> pLoop;
Wrapper class for underlying types.
U * raw() noexcept
Gets the underlying raw data structure.
static std::shared_ptr< T > create(Args &&... args)
Creates a new resource of the given type.
Loop & loop() const noexcept
Gets the loop from which the resource was originated.
const U * raw() const noexcept
Gets the underlying raw data structure.