[ox/preloader] Cleanup

This commit is contained in:
2023-02-25 22:25:14 -06:00
parent 1767821161
commit 317e714373
3 changed files with 19 additions and 10 deletions

View File

@@ -21,11 +21,12 @@ struct NativePlatSpec {
template<typename T>
[[nodiscard]]
static constexpr auto alignOf(const T &v) noexcept {
static constexpr std::size_t alignOf(const T &v) noexcept {
if constexpr(ox::is_integral_v<T>) {
return alignof(T);
} else if constexpr(ox::is_pointer_v<T>) {
return PtrAlign;
PtrType p = 0;
return alignOf(p);
} else {
AlignmentCatcher<NativePlatSpec> c;
oxAssert(model(c.interface(), &v), "Could not get alignment for type");
@@ -41,11 +42,17 @@ struct NativePlatSpec {
template<typename PlatSpec, typename T>
[[nodiscard]]
constexpr std::size_t alignOf(const T &t) noexcept {
return PlatSpec::alignOf(t);
constexpr std::size_t alignOf(const T &v) noexcept {
if constexpr(ox::is_integral_v<T>) {
return alignof(T);
} else if constexpr(ox::is_pointer_v<T>) {
typename PlatSpec::PtrType p = 0;
return PlatSpec::alignOf(p);
} else {
AlignmentCatcher<NativePlatSpec> c;
oxAssert(model(c.interface(), &v), "Could not get alignment for type");
return c.biggestAlignment;
}
}
template<typename PlatSpec, typename T>
constexpr auto alignOf_v = alignOf<PlatSpec>(static_cast<T*>(nullptr));
}