Skip to content

Commit 6b75318

Browse files
committed
fix const
1 parent 541ad68 commit 6b75318

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

include/beman/inplace_vector/inplace_vector.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ template <typename T, std::size_t Capacity>
7777
struct inplace_vector_bytes_based_storage {
7878
alignas(T) std::array<std::byte, Capacity * sizeof(T)> elems;
7979

80-
T *begin() { return std::launder(reinterpret_cast<const T *>(elems.data())); }
80+
T *begin() { return std::launder(reinterpret_cast<T *>(elems.data())); }
8181
const T *begin() const {
8282
return std::launder(reinterpret_cast<const T *>(elems.data()));
8383
}
@@ -605,7 +605,8 @@ class inplace_vector : public inplace_vector_base<T, Capacity> {
605605
#else
606606
// Note: placement-new may not be constexpr friendly
607607
// Avoiding placement-new may allow inplace_vector to be constexpr friendly
608-
auto final = ::new (end()) T(std::forward<Args>(args)...);
608+
// cast to void* here to adapt to a const T
609+
auto final = ::new ((void *)end()) T(std::forward<Args>(args)...);
609610
#endif
610611
this->change_size(1);
611612
return *final;

tests/beman/inplace_vector/inplace_vector.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using namespace beman::inplace_vector;
77
struct NonTrivial {
88
int z = 5;
99

10-
bool operator==(NonTrivial const &other) { return this->z == other.z; }
10+
bool operator==(NonTrivial const &other) const { return this->z == other.z; }
1111
};
1212
static_assert(!std::is_trivial_v<NonTrivial>);
1313

0 commit comments

Comments
 (0)