diff --git a/include/ircd/allocator.h b/include/ircd/allocator.h index 31e4bf490..48c12c12f 100644 --- a/include/ircd/allocator.h +++ b/include/ircd/allocator.h @@ -111,22 +111,22 @@ struct ircd::allocator::state /// template as we are here. /// template + size_t MAX> struct ircd::allocator::fixed :state { struct allocator; using value = std::aligned_storage; - std::array avail {{0}}; - std::array buf; + std::array avail {{0}}; + std::array buf; public: allocator operator()(); operator allocator(); fixed() - :state{max, avail.data()} + :state{MAX, avail.data()} {} }; @@ -139,8 +139,8 @@ struct ircd::allocator::fixed /// at its construction. /// template -struct ircd::allocator::fixed::allocator + size_t SIZE> +struct ircd::allocator::fixed::allocator { using value_type = T; using pointer = T *; @@ -153,14 +153,25 @@ struct ircd::allocator::fixed::allocator fixed *s; public: - template struct rebind + template struct rebind { - using other = typename fixed::allocator; + using other = typename fixed::allocator; }; - size_type max_size() const { return size; } - auto address(reference x) const { return &x; } - auto address(const_reference x) const { return &x; } + size_type max_size() const + { + return SIZE; + } + + auto address(reference x) const + { + return &x; + } + + auto address(const_reference x) const + { + return &x; + } pointer allocate(const size_type &n, const const_pointer &hint = nullptr) { @@ -175,10 +186,12 @@ struct ircd::allocator::fixed::allocator s->state::deallocate(p - base, n); } - template - allocator(const typename fixed::allocator &) noexcept - :s{reinterpret_cast(s.s)} - {} + template + allocator(const typename fixed::allocator &) noexcept + :s{reinterpret_cast *>(s.s)} + { + static_assert(OTHER_SIZE == SIZE); + } allocator(fixed &s) noexcept :s{&s} @@ -199,16 +212,16 @@ struct ircd::allocator::fixed::allocator }; template -typename ircd::allocator::fixed::allocator -ircd::allocator::fixed::operator()() + size_t SIZE> +typename ircd::allocator::fixed::allocator +ircd::allocator::fixed::operator()() { return { *this }; } template -ircd::allocator::fixed::operator + size_t SIZE> +ircd::allocator::fixed::operator allocator() { return { *this };