1#ifndef UVW_UNDERLYING_TYPE_INCLUDE_H
2#define UVW_UNDERLYING_TYPE_INCLUDE_H
16template<
typename T,
typename U>
18 template<
typename,
typename>
22 struct ConstructorAccess {
23 explicit ConstructorAccess(
int) {}
26 template<
typename R = U>
28 return reinterpret_cast<R *
>(&resource);
31 template<
typename R = U>
32 auto get()
const noexcept {
33 return reinterpret_cast<const R *
>(&resource);
36 template<
typename R,
typename... P>
38 return reinterpret_cast<R *
>(&other.resource);
42 explicit UnderlyingType(ConstructorAccess, std::shared_ptr<Loop> ref) noexcept
43 : pLoop{std::move(ref)}, resource{} {}
49 static_assert(std::is_base_of_v<UnderlyingType<T, U>, T>);
60 template<
typename... Args>
61 static std::shared_ptr<T>
create(Args &&...args) {
62 return std::make_shared<T>(ConstructorAccess{0}, std::forward<Args>(args)...);
88 const U *
raw() const noexcept {
112 std::shared_ptr<Loop> pLoop;
Wrapper class for underlying types.
Loop & loop() const noexcept
Gets the loop from which the resource was originated.
const U * raw() const noexcept
Gets the underlying raw data structure.
static std::shared_ptr< T > create(Args &&...args)
Creates a new resource of the given type.
U * raw() noexcept
Gets the underlying raw data structure.