aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-12-15 22:13:36 -0800
committerChris Robinson <[email protected]>2023-12-15 22:13:36 -0800
commitbfd9323d4a1253dc32be5720e769d22b40712135 (patch)
tree20eb0d29f0a222ab0c8d1b6519a7cebb1cfac6c7
parentf1c5b1a4345c48cb498570dca6a11c4947aa88bc (diff)
Mark constructors noexcept as needed
-rw-r--r--common/flexarray.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/common/flexarray.h b/common/flexarray.h
index ad15d554..9b6fcc63 100644
--- a/common/flexarray.h
+++ b/common/flexarray.h
@@ -20,7 +20,9 @@ struct FlexArrayStorage {
static constexpr size_t Sizeof(size_t count, size_t base=0u) noexcept
{ return sizeof(FlexArrayStorage) + sizeof(T)*count + base; }
- FlexArrayStorage(size_t size) : mData{::new(static_cast<void*>(this+1)) T[size], size} { }
+ FlexArrayStorage(size_t size) noexcept(std::is_nothrow_constructible_v<T>)
+ : mData{::new(static_cast<void*>(this+1)) T[size], size}
+ { }
~FlexArrayStorage() = default;
FlexArrayStorage(const FlexArrayStorage&) = delete;
@@ -34,7 +36,9 @@ struct FlexArrayStorage<T,alignment,false> {
static constexpr size_t Sizeof(size_t count, size_t base=0u) noexcept
{ return sizeof(FlexArrayStorage) + sizeof(T)*count + base; }
- FlexArrayStorage(size_t size) : mData{::new(static_cast<void*>(this+1)) T[size], size} { }
+ FlexArrayStorage(size_t size) noexcept(std::is_nothrow_constructible_v<T>)
+ : mData{::new(static_cast<void*>(this+1)) T[size], size}
+ { }
~FlexArrayStorage() { std::destroy(mData.begin(), mData.end()); }
FlexArrayStorage(const FlexArrayStorage&) = delete;
@@ -83,7 +87,9 @@ struct FlexArray {
throw std::bad_alloc();
}
- FlexArray(index_type size) noexcept(noexcept(Storage_t_{size})) : mStore{size} { }
+ FlexArray(index_type size) noexcept(std::is_nothrow_constructible_v<Storage_t_>)
+ : mStore{size}
+ { }
~FlexArray() = default;
[[nodiscard]] auto size() const noexcept -> index_type { return mStore.mData.size(); }