[ox/std] Rework itoa
This commit is contained in:
11
deps/ox/src/ox/std/vector.hpp
vendored
11
deps/ox/src/ox/std/vector.hpp
vendored
@@ -30,7 +30,6 @@ struct VectorAllocator {
|
||||
static_assert(alignof(AllocAlias<T>) == alignof(T));
|
||||
private:
|
||||
ox::Array<AllocAlias<T>, Size> m_data = {};
|
||||
Allocator m_allocator;
|
||||
protected:
|
||||
constexpr VectorAllocator() noexcept = default;
|
||||
constexpr VectorAllocator(const VectorAllocator&) noexcept = default;
|
||||
@@ -39,7 +38,7 @@ struct VectorAllocator {
|
||||
constexpr void allocate(T **items, std::size_t cap) noexcept {
|
||||
// small vector optimization cannot be done it constexpr, but it doesn't really matter in constexpr
|
||||
if (std::is_constant_evaluated() || cap > Size) {
|
||||
*items = m_allocator.allocate(cap);
|
||||
*items = Allocator{}.allocate(cap);
|
||||
} else {
|
||||
*items = reinterpret_cast<T*>(m_data.data());
|
||||
}
|
||||
@@ -87,7 +86,7 @@ struct VectorAllocator {
|
||||
// small vector optimization cannot be done it constexpr, but it doesn't really matter in constexpr
|
||||
if (std::is_constant_evaluated()) {
|
||||
if (items && static_cast<void*>(items) != static_cast<void*>(m_data.data())) {
|
||||
m_allocator.deallocate(items, cap);
|
||||
Allocator{}.deallocate(items, cap);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,15 +95,13 @@ struct VectorAllocator {
|
||||
|
||||
template<typename T, typename Allocator>
|
||||
struct VectorAllocator<T, Allocator, 0> {
|
||||
private:
|
||||
Allocator m_allocator;
|
||||
protected:
|
||||
constexpr VectorAllocator() noexcept = default;
|
||||
constexpr VectorAllocator(const VectorAllocator&) noexcept = default;
|
||||
constexpr VectorAllocator(VectorAllocator&&) noexcept = default;
|
||||
|
||||
constexpr void allocate(T **items, std::size_t cap) noexcept {
|
||||
*items = m_allocator.allocate(cap);
|
||||
*items = Allocator{}.allocate(cap);
|
||||
}
|
||||
|
||||
[[maybe_unused]]
|
||||
@@ -121,7 +118,7 @@ struct VectorAllocator<T, Allocator, 0> {
|
||||
|
||||
constexpr void deallocate(T *items, std::size_t cap) noexcept {
|
||||
if (items) {
|
||||
m_allocator.deallocate(items, cap);
|
||||
Allocator{}.deallocate(items, cap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user