From ed3e40c22d3bc0ea2dca4e0967588e7edf80b859 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 10 Oct 2021 11:29:00 -0700 Subject: Add more noexcept --- common/almalloc.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'common/almalloc.h') diff --git a/common/almalloc.h b/common/almalloc.h index 6bcbdce8..62c6c6d9 100644 --- a/common/almalloc.h +++ b/common/almalloc.h @@ -97,9 +97,9 @@ struct allocator { void deallocate(T *p, std::size_t) noexcept { al_free(p); } }; template -bool operator==(const allocator&, const allocator&) noexcept { return true; } +constexpr bool operator==(const allocator&, const allocator&) noexcept { return true; } template -bool operator!=(const allocator&, const allocator&) noexcept { return false; } +constexpr bool operator!=(const allocator&, const allocator&) noexcept { return false; } template [[gnu::assume_aligned(alignment)]] constexpr T* assume_aligned(T *ptr) noexcept { return ptr; } @@ -156,6 +156,7 @@ destroy_n(T first, N count) noexcept(noexcept(al::destroy_at(std::addressof(*fir template inline std::enable_if_t::value,T> uninitialized_default_construct_n(T first, N count) + noexcept(std::is_nothrow_default_constructible::value_type>::value) { using ValueT = typename std::iterator_traits::value_type; T current{first}; @@ -180,10 +181,7 @@ uninitialized_default_construct_n(T first, N count) * trivially destructible. */ template::value> -struct FlexArrayStorage; - -template -struct FlexArrayStorage { +struct FlexArrayStorage { const size_t mSize; union { char mDummy; @@ -196,7 +194,8 @@ struct FlexArrayStorage { sizeof(FlexArrayStorage)) + base; } - FlexArrayStorage(size_t size) : mSize{size} + FlexArrayStorage(size_t size) noexcept(std::is_nothrow_default_constructible::value) + : mSize{size} { al::uninitialized_default_construct_n(mArray, mSize); } ~FlexArrayStorage() = default; @@ -218,7 +217,8 @@ struct FlexArrayStorage { sizeof(FlexArrayStorage)) + base; } - FlexArrayStorage(size_t size) : mSize{size} + FlexArrayStorage(size_t size) noexcept(std::is_nothrow_default_constructible::value) + : mSize{size} { al::uninitialized_default_construct_n(mArray, mSize); } ~FlexArrayStorage() { al::destroy_n(mArray, mSize); } -- cgit v1.2.3