diff options
author | Chris Robinson <[email protected]> | 2022-03-24 16:12:23 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-03-24 16:12:23 -0700 |
commit | 88d5c47e3705fcc8978815442e80aa4205f29ad0 (patch) | |
tree | 23336d100d106876d1725ec1c5ee8553eabbaf81 | |
parent | b168482ea3f5bfb0df4dd043934a87f3132f96c9 (diff) |
Simplify a couple offsetof statements
-rw-r--r-- | common/almalloc.h | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/common/almalloc.h b/common/almalloc.h index 70a400c4..1e43acca 100644 --- a/common/almalloc.h +++ b/common/almalloc.h @@ -50,8 +50,8 @@ enum FamCount : size_t { }; #define DEF_FAM_NEWDEL(T, FamMem) \ static constexpr size_t Sizeof(size_t count) noexcept \ { \ - return std::max<size_t>(sizeof(T), \ - decltype(FamMem)::Sizeof(count, offsetof(T, FamMem))); \ + return std::max(decltype(FamMem)::Sizeof(count, offsetof(T, FamMem)), \ + sizeof(T)); \ } \ \ void *operator new(size_t /*size*/, FamCount count) \ @@ -188,10 +188,7 @@ struct FlexArrayStorage { }; static constexpr size_t Sizeof(size_t count, size_t base=0u) noexcept - { - return std::max<size_t>(offsetof(FlexArrayStorage, mArray) + sizeof(T)*count, - sizeof(FlexArrayStorage)) + base; - } + { return std::max(offsetof(FlexArrayStorage,mArray[count]), sizeof(FlexArrayStorage)) + base; } FlexArrayStorage(size_t size) : mSize{size} { al::uninitialized_default_construct_n(mArray, mSize); } @@ -210,10 +207,7 @@ struct FlexArrayStorage<T,alignment,false> { }; static constexpr size_t Sizeof(size_t count, size_t base) noexcept - { - return std::max<size_t>(offsetof(FlexArrayStorage, mArray) + sizeof(T)*count, - sizeof(FlexArrayStorage)) + base; - } + { return std::max(offsetof(FlexArrayStorage,mArray[count]), sizeof(FlexArrayStorage)) + base; } FlexArrayStorage(size_t size) : mSize{size} { al::uninitialized_default_construct_n(mArray, mSize); } |