Skip to content

Commit

Permalink
Merge pull request #130 from jac3km4/clang-compat
Browse files Browse the repository at this point in the history
fix: fix clang compat
  • Loading branch information
wopss authored Jun 10, 2024
2 parents bbe124a + 5aef0a2 commit 1249843
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion include/RED4ext/JobQueue-inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ RED4EXT_INLINE void RED4ext::JobQueue::Wait(const JobHandle& aJob)
unk10.Join(aJob);
}

RED4EXT_INLINE [[nodiscard]] RED4ext::JobHandle RED4ext::JobQueue::Capture()
[[nodiscard]] RED4EXT_INLINE RED4ext::JobHandle RED4ext::JobQueue::Capture()
{
using func_t = JobHandle* (*)(JobQueue*, JobHandle*);
static UniversalRelocFunc<func_t> func(Detail::AddressHashes::JobQueue_Capture);
Expand Down
108 changes: 54 additions & 54 deletions include/RED4ext/Memory/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,60 @@ concept IsNewCompatible = Detail::HasStaticAllocatorOrHook<T>;
template<typename T>
concept IsDeleteCompatible = Detail::HasAnyAllocatorOrHook<T> && Detail::IsSafeDestructible<T>;

/**
* @brief Gets the allocator instance of given type.
*
* @tparam T The allocator type.
* @return The allocator instance.
*/
template<typename T>
requires Detail::IsAllocator<T>
inline IAllocator* GetAllocator()
{
return T::Get();
}

/**
* @brief Gets the allocator associated with the type.
*
* @tparam T The object type.
* @return The allocator instance.
*/
template<typename T>
requires Detail::HasStaticAllocatorOrHook<T>
inline IAllocator* GetAllocator()
{
if constexpr (Detail::AllocatorHook<T>::value)
{
return Detail::AllocatorHook<T>::Get();
}
else
{
return GetAllocator<Detail::ResolveAllocatorType<T>>();
}
}

/**
* @brief Gets the allocator associated with the object.
*
* @tparam T The object type.
* @param aInstance The object pointer.
* @return The allocator instance.
*/
template<typename T>
requires Detail::HasAnyAllocatorOrHook<T>
inline IAllocator* GetAllocator(T* aInstance)
{
if constexpr (Detail::HasDynamicAllocator<T>)
{
return aInstance->GetAllocator();
}
else
{
return GetAllocator<T>();
}
}

/**
* @brief Creates a new object using the appropriate allocator.
* The object type must define a scoped type `AllocatorType`.
Expand Down Expand Up @@ -129,58 +183,4 @@ inline void Delete(IAllocator* aAllocator, T* aInstance)
aInstance->~T();
aAllocator->Free(aInstance);
}

/**
* @brief Gets the allocator instance of given type.
*
* @tparam T The allocator type.
* @return The allocator instance.
*/
template<typename T>
requires Detail::IsAllocator<T>
inline IAllocator* GetAllocator()
{
return T::Get();
}

/**
* @brief Gets the allocator associated with the type.
*
* @tparam T The object type.
* @return The allocator instance.
*/
template<typename T>
requires Detail::HasStaticAllocatorOrHook<T>
inline IAllocator* GetAllocator()
{
if constexpr (Detail::AllocatorHook<T>::value)
{
return Detail::AllocatorHook<T>::Get();
}
else
{
return GetAllocator<Detail::ResolveAllocatorType<T>>();
}
}

/**
* @brief Gets the allocator associated with the object.
*
* @tparam T The object type.
* @param aInstance The object pointer.
* @return The allocator instance.
*/
template<typename T>
requires Detail::HasAnyAllocatorOrHook<T>
inline IAllocator* GetAllocator(T* aInstance)
{
if constexpr (Detail::HasDynamicAllocator<T>)
{
return aInstance->GetAllocator();
}
else
{
return GetAllocator<T>();
}
}
} // namespace RED4ext::Memory

0 comments on commit 1249843

Please sign in to comment.