Fix build for llvm 18
All checks were successful
Tests / Clang total: 1130, passed: 1130
Clang |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|0|0|0|0|:clap:
Tests / SIMD fallback total: 1130, passed: 1130
Tests / Release [gcc] total: 1130, passed: 1130
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|0|0|0|0|:clap:
Tests / Release [gcc,aarch64] total: 844, passed: 844
Tests / Coverage total: 848, passed: 848
weaselab/conflict-set/pipeline/head This commit looks good
All checks were successful
Tests / Clang total: 1130, passed: 1130
Clang |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|0|0|0|0|:clap:
Tests / SIMD fallback total: 1130, passed: 1130
Tests / Release [gcc] total: 1130, passed: 1130
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|0|0|0|0|:clap:
Tests / Release [gcc,aarch64] total: 844, passed: 844
Tests / Coverage total: 848, passed: 848
weaselab/conflict-set/pipeline/head This commit looks good
This commit is contained in:
@@ -2944,10 +2944,6 @@ Iterator firstGeq(Node *n, std::string_view key) {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace std {
|
|
||||||
void __throw_length_error(const char *) { __builtin_unreachable(); }
|
|
||||||
} // namespace std
|
|
||||||
|
|
||||||
#if SHOW_MEMORY
|
#if SHOW_MEMORY
|
||||||
|
|
||||||
int64_t nodeBytes = 0;
|
int64_t nodeBytes = 0;
|
||||||
|
63
Internal.h
63
Internal.h
@@ -255,10 +255,65 @@ template <class T> struct ArenaAlloc {
|
|||||||
void deallocate(T *, size_t) noexcept {}
|
void deallocate(T *, size_t) noexcept {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T> using Vector = std::vector<T, ArenaAlloc<T>>;
|
template <class T> struct Vector {
|
||||||
template <class T> auto vector(Arena &arena) {
|
static_assert(std::is_trivially_destructible_v<T>);
|
||||||
return Vector<T>(ArenaAlloc<T>(&arena));
|
static_assert(std::is_trivially_copyable_v<T>);
|
||||||
}
|
|
||||||
|
explicit Vector(Arena *arena)
|
||||||
|
: arena(arena), t(nullptr), size_(0), capacity(0) {}
|
||||||
|
|
||||||
|
void append(std::span<const T> slice) {
|
||||||
|
if (size_ + int(slice.size()) > capacity) {
|
||||||
|
grow(std::max<int>(size_ + slice.size(), capacity * 2));
|
||||||
|
}
|
||||||
|
if (slice.size() > 0) {
|
||||||
|
memcpy(const_cast<std::remove_const_t<T> *>(t) + size_, slice.data(),
|
||||||
|
slice.size() * sizeof(T));
|
||||||
|
}
|
||||||
|
size_ += slice.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void push_back(const T &t) { append(std::span<const T>(&t, 1)); }
|
||||||
|
|
||||||
|
T *begin() { return t; }
|
||||||
|
T *end() { return t + size_; }
|
||||||
|
T *data() { return t; }
|
||||||
|
T &back() {
|
||||||
|
assert(size_ > 0);
|
||||||
|
return t[size_ - 1];
|
||||||
|
}
|
||||||
|
T &operator[](int i) {
|
||||||
|
assert(i >= 0 && i < size_);
|
||||||
|
return t[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
void pop_back() {
|
||||||
|
assert(size_ > 0);
|
||||||
|
--size_;
|
||||||
|
}
|
||||||
|
|
||||||
|
int size() const { return size_; }
|
||||||
|
|
||||||
|
operator std::span<const T>() const { return std::span(t, size_); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void grow(int newCapacity) {
|
||||||
|
capacity = newCapacity;
|
||||||
|
auto old = std::span<const T>(*this);
|
||||||
|
t = (T *)new (std::align_val_t(alignof(T)), *arena)
|
||||||
|
uint8_t[capacity * sizeof(T)];
|
||||||
|
size_ = 0;
|
||||||
|
append(old);
|
||||||
|
}
|
||||||
|
|
||||||
|
Arena *arena;
|
||||||
|
T *t;
|
||||||
|
int size_;
|
||||||
|
int capacity;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T> auto vector(Arena &arena) { return Vector<T>(&arena); }
|
||||||
|
|
||||||
template <class T, class C> using Set = std::set<T, C, ArenaAlloc<T>>;
|
template <class T, class C> using Set = std::set<T, C, ArenaAlloc<T>>;
|
||||||
template <class T, class C = std::less<T>> auto set(Arena &arena) {
|
template <class T, class C = std::less<T>> auto set(Arena &arena) {
|
||||||
return Set<T, C>(ArenaAlloc<T>(&arena));
|
return Set<T, C>(ArenaAlloc<T>(&arena));
|
||||||
|
Reference in New Issue
Block a user