MCPcopy Create free account
hub / github.com/VectorDB-NTU/RaBitQ-Library / Allocator

Class Allocator

include/rabitqlib/utils/memory.hpp:55–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53 void deallocate(T* ptr, [[maybe_unused]] std::size_t n) { std::free(ptr); }
54};
55
56template <typename T>
57struct Allocator {
58 public:
59 using value_type = T;
60
61 constexpr Allocator() noexcept = default;
62
63 template <typename U>
64 explicit constexpr Allocator(const Allocator<U>&) noexcept {}
65
66 [[nodiscard]] constexpr T* allocate(std::size_t n) { return ::new T[n]; }
67
68 constexpr void deallocate(T* ptr, [[maybe_unused]] size_t n) noexcept {
69 ::delete[] ptr;
70 }
71
72 // Intercept zero-argument construction to do default initialization.
73 template <typename U>
74 void construct(U* ptr) noexcept(std::is_nothrow_default_constructible_v<U>) {
75 ::new (static_cast<void*>(ptr)) U;
76 }
77};
78

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected