diff options
author | Chris Robinson <[email protected]> | 2021-10-10 11:29:00 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-10-14 12:44:05 -0700 |
commit | ed3e40c22d3bc0ea2dca4e0967588e7edf80b859 (patch) | |
tree | e491eefd3770f5e51683b5e5072de6c29e46a9d1 /common/almalloc.h | |
parent | 8305973e7a5f0ee7624b826b79cf449593f4e0ae (diff) |
Add more noexcept
Diffstat (limited to 'common/almalloc.h')
-rw-r--r-- | common/almalloc.h | 16 |
1 files changed, 8 insertions, 8 deletions
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<typename T, std::size_t N, typename U, std::size_t M> -bool operator==(const allocator<T,N>&, const allocator<U,M>&) noexcept { return true; } +constexpr bool operator==(const allocator<T,N>&, const allocator<U,M>&) noexcept { return true; } template<typename T, std::size_t N, typename U, std::size_t M> -bool operator!=(const allocator<T,N>&, const allocator<U,M>&) noexcept { return false; } +constexpr bool operator!=(const allocator<T,N>&, const allocator<U,M>&) noexcept { return false; } template<size_t alignment, typename T> [[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<typename T, typename N> inline std::enable_if_t<std::is_integral<N>::value,T> uninitialized_default_construct_n(T first, N count) + noexcept(std::is_nothrow_default_constructible<typename std::iterator_traits<T>::value_type>::value) { using ValueT = typename std::iterator_traits<T>::value_type; T current{first}; @@ -180,10 +181,7 @@ uninitialized_default_construct_n(T first, N count) * trivially destructible. */ template<typename T, size_t alignment, bool = std::is_trivially_destructible<T>::value> -struct FlexArrayStorage; - -template<typename T, size_t alignment> -struct FlexArrayStorage<T,alignment,true> { +struct FlexArrayStorage { const size_t mSize; union { char mDummy; @@ -196,7 +194,8 @@ struct FlexArrayStorage<T,alignment,true> { sizeof(FlexArrayStorage)) + base; } - FlexArrayStorage(size_t size) : mSize{size} + FlexArrayStorage(size_t size) noexcept(std::is_nothrow_default_constructible<T>::value) + : mSize{size} { al::uninitialized_default_construct_n(mArray, mSize); } ~FlexArrayStorage() = default; @@ -218,7 +217,8 @@ struct FlexArrayStorage<T,alignment,false> { sizeof(FlexArrayStorage)) + base; } - FlexArrayStorage(size_t size) : mSize{size} + FlexArrayStorage(size_t size) noexcept(std::is_nothrow_default_constructible<T>::value) + : mSize{size} { al::uninitialized_default_construct_n(mArray, mSize); } ~FlexArrayStorage() { al::destroy_n(mArray, mSize); } |