mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd::allocator: Fix fixed allocator template name conflicts.
This commit is contained in:
parent
2914487aad
commit
2d2e708264
1 changed files with 33 additions and 20 deletions
|
@ -111,22 +111,22 @@ struct ircd::allocator::state
|
||||||
/// template as we are here.
|
/// template as we are here.
|
||||||
///
|
///
|
||||||
template<class T,
|
template<class T,
|
||||||
size_t max>
|
size_t MAX>
|
||||||
struct ircd::allocator::fixed
|
struct ircd::allocator::fixed
|
||||||
:state
|
:state
|
||||||
{
|
{
|
||||||
struct allocator;
|
struct allocator;
|
||||||
using value = std::aligned_storage<sizeof(T), alignof(T)>;
|
using value = std::aligned_storage<sizeof(T), alignof(T)>;
|
||||||
|
|
||||||
std::array<word_t, max / 8> avail {{0}};
|
std::array<word_t, MAX / 8> avail {{0}};
|
||||||
std::array<typename value::type, max> buf;
|
std::array<typename value::type, MAX> buf;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
allocator operator()();
|
allocator operator()();
|
||||||
operator allocator();
|
operator allocator();
|
||||||
|
|
||||||
fixed()
|
fixed()
|
||||||
:state{max, avail.data()}
|
:state{MAX, avail.data()}
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -139,8 +139,8 @@ struct ircd::allocator::fixed
|
||||||
/// at its construction.
|
/// at its construction.
|
||||||
///
|
///
|
||||||
template<class T,
|
template<class T,
|
||||||
size_t size>
|
size_t SIZE>
|
||||||
struct ircd::allocator::fixed<T, size>::allocator
|
struct ircd::allocator::fixed<T, SIZE>::allocator
|
||||||
{
|
{
|
||||||
using value_type = T;
|
using value_type = T;
|
||||||
using pointer = T *;
|
using pointer = T *;
|
||||||
|
@ -153,14 +153,25 @@ struct ircd::allocator::fixed<T, size>::allocator
|
||||||
fixed *s;
|
fixed *s;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template<class U, size_t S> struct rebind
|
template<class U> struct rebind
|
||||||
{
|
{
|
||||||
using other = typename fixed<U, S>::allocator;
|
using other = typename fixed<U, SIZE>::allocator;
|
||||||
};
|
};
|
||||||
|
|
||||||
size_type max_size() const { return size; }
|
size_type max_size() const
|
||||||
auto address(reference x) const { return &x; }
|
{
|
||||||
auto address(const_reference x) const { return &x; }
|
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)
|
pointer allocate(const size_type &n, const const_pointer &hint = nullptr)
|
||||||
{
|
{
|
||||||
|
@ -175,10 +186,12 @@ struct ircd::allocator::fixed<T, size>::allocator
|
||||||
s->state::deallocate(p - base, n);
|
s->state::deallocate(p - base, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class U, size_t S>
|
template<class U, size_t OTHER_SIZE>
|
||||||
allocator(const typename fixed<U, S>::allocator &) noexcept
|
allocator(const typename fixed<U, OTHER_SIZE>::allocator &) noexcept
|
||||||
:s{reinterpret_cast<fixed *>(s.s)}
|
:s{reinterpret_cast<fixed<T, SIZE> *>(s.s)}
|
||||||
{}
|
{
|
||||||
|
static_assert(OTHER_SIZE == SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
allocator(fixed &s) noexcept
|
allocator(fixed &s) noexcept
|
||||||
:s{&s}
|
:s{&s}
|
||||||
|
@ -199,16 +212,16 @@ struct ircd::allocator::fixed<T, size>::allocator
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T,
|
template<class T,
|
||||||
size_t size>
|
size_t SIZE>
|
||||||
typename ircd::allocator::fixed<T, size>::allocator
|
typename ircd::allocator::fixed<T, SIZE>::allocator
|
||||||
ircd::allocator::fixed<T, size>::operator()()
|
ircd::allocator::fixed<T, SIZE>::operator()()
|
||||||
{
|
{
|
||||||
return { *this };
|
return { *this };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T,
|
template<class T,
|
||||||
size_t size>
|
size_t SIZE>
|
||||||
ircd::allocator::fixed<T, size>::operator
|
ircd::allocator::fixed<T, SIZE>::operator
|
||||||
allocator()
|
allocator()
|
||||||
{
|
{
|
||||||
return { *this };
|
return { *this };
|
||||||
|
|
Loading…
Reference in a new issue