Skip to content

Commit

Permalink
[inplace_vector] remove constexpr, see if that fixes GCC
Browse files Browse the repository at this point in the history
  • Loading branch information
Quuxplusone committed Dec 4, 2023
1 parent a7f8e03 commit 91d2f0b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions include/sg14/inplace_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,25 @@ struct SG14_INPLACE_VECTOR_TRIVIALLY_RELOCATABLE_IF(std::is_trivially_relocatabl
constexpr void set_size_(size_t n) { size_ = n; }

constexpr explicit ipvbase() noexcept {}
constexpr ipvbase(const ipvbase& rhs)
ipvbase(const ipvbase& rhs)
noexcept(std::is_nothrow_copy_constructible_v<T>)
{
if constexpr (std::is_trivially_copy_constructible_v<T>) {
std::memmove(this, std::addressof(rhs), sizeof(ipvbase));
std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase));
} else {
std::uninitialized_copy_n(rhs.data_, rhs.size_, data_);
size_ = rhs.size_;
}
}
constexpr ipvbase(ipvbase&& rhs)
ipvbase(ipvbase&& rhs)
noexcept(std::is_nothrow_move_constructible_v<T>
#if defined(__cpp_lib_trivially_relocatable)
|| std::is_trivially_relocatable_v<T>
#endif // __cpp_lib_trivially_relocatable
)
{
if constexpr (std::is_trivially_move_constructible_v<T>) {
std::memmove(this, std::addressof(rhs), sizeof(ipvbase));
std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase));
#if defined(__cpp_lib_trivially_relocatable)
} else if constexpr (std::is_trivially_relocatable_v<T>) {
std::uninitialized_relocate_n(rhs.data_, rhs.size_, data_);
Expand All @@ -123,11 +123,11 @@ struct SG14_INPLACE_VECTOR_TRIVIALLY_RELOCATABLE_IF(std::is_trivially_relocatabl
size_ = rhs.size_;
}
}
constexpr void operator=(const ipvbase& rhs)
void operator=(const ipvbase& rhs)
noexcept(std::is_nothrow_copy_constructible_v<T> && std::is_nothrow_copy_assignable_v<T>)
{
if constexpr (std::is_trivially_copy_constructible_v<T> && std::is_trivially_copy_assignable_v<T> && std::is_trivially_destructible_v<T>) {
std::memmove(this, std::addressof(rhs), sizeof(ipvbase));
std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase));
} else if (this == std::addressof(rhs)) {
// do nothing
} else if (rhs.size_ <= size_) {
Expand All @@ -140,11 +140,11 @@ struct SG14_INPLACE_VECTOR_TRIVIALLY_RELOCATABLE_IF(std::is_trivially_relocatabl
size_ = rhs.size_;
}
}
constexpr void operator=(ipvbase&& rhs)
void operator=(ipvbase&& rhs)
noexcept(std::is_nothrow_move_constructible_v<T> && std::is_nothrow_move_assignable_v<T>)
{
if constexpr (std::is_trivially_move_constructible_v<T> && std::is_trivially_move_assignable_v<T> && std::is_trivially_destructible_v<T>) {
std::memmove(this, std::addressof(rhs), sizeof(ipvbase));
std::memmove((void*)this, (const void*)std::addressof(rhs), sizeof(ipvbase));
} else if (this == std::addressof(rhs)) {
// do nothing
} else if (rhs.size_ <= size_) {
Expand All @@ -170,6 +170,7 @@ struct SG14_INPLACE_VECTOR_TRIVIALLY_RELOCATABLE_IF(std::is_trivially_relocatabl
ipvbase(ipvbase&&) requires std::is_trivially_move_constructible_v<T> = default;
ipvbase& operator=(const ipvbase&) requires std::is_trivially_copy_constructible_v<T> && std::is_trivially_copy_assignable_v<T> && std::is_trivially_destructible_v<T> = default;
ipvbase& operator=(ipvbase&&) requires std::is_trivially_move_constructible_v<T> && std::is_trivially_move_assignable_v<T> && std::is_trivially_destructible_v<T> = default;
~ipvbase() requires std::is_trivially_destructible_v<T> = default;
#endif // __cpp_concepts >= 202002L

#if __cplusplus >= 202002L
Expand Down

0 comments on commit 91d2f0b

Please sign in to comment.