Change buffer to use allocator traits
This commit is contained in:
parent
d9cba881ac
commit
31327248e0
@ -52,17 +52,16 @@ namespace rexy{
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
constexpr buffer(void);
|
constexpr buffer(void);
|
||||||
REXY_CPP20_CONSTEXPR buffer(const_pointer data, size_type length)noexcept(noexcept(this->allocate(0)));
|
REXY_CPP20_CONSTEXPR buffer(const_pointer data, size_type length)noexcept(is_nothrow_allocator_v<Allocator>);
|
||||||
template<class Iter>
|
template<class Iter>
|
||||||
REXY_CPP20_CONSTEXPR buffer(const Iter& start, const Iter& last);
|
REXY_CPP20_CONSTEXPR buffer(const Iter& start, const Iter& last);
|
||||||
REXY_CPP20_CONSTEXPR buffer(size_type cap)noexcept(noexcept(this->allocate(0)));
|
REXY_CPP20_CONSTEXPR buffer(size_type cap)noexcept(is_nothrow_allocator_v<Allocator>);
|
||||||
REXY_CPP20_CONSTEXPR buffer(const buffer& b)noexcept(noexcept(this->allocate(0)));
|
REXY_CPP20_CONSTEXPR buffer(const buffer& b)noexcept(is_nothrow_allocator_v<Allocator>);
|
||||||
constexpr buffer(buffer&& b)noexcept;
|
constexpr buffer(buffer&& b)noexcept;
|
||||||
REXY_CPP20_CONSTEXPR ~buffer(void)noexcept(noexcept(this->deallocate(nullptr, 0)));
|
REXY_CPP20_CONSTEXPR ~buffer(void)noexcept(is_nothrow_allocator_v<Allocator>);
|
||||||
|
|
||||||
REXY_CPP20_CONSTEXPR buffer& operator=(const buffer& b)
|
REXY_CPP20_CONSTEXPR buffer& operator=(const buffer& b)
|
||||||
noexcept(noexcept(this->allocate(0)) &&
|
noexcept(is_nothrow_allocator_v<Allocator>);
|
||||||
noexcept(this->deallocate(nullptr, 0)));
|
|
||||||
constexpr buffer& operator=(buffer&& b)noexcept;
|
constexpr buffer& operator=(buffer&& b)noexcept;
|
||||||
|
|
||||||
constexpr pointer data(void);
|
constexpr pointer data(void);
|
||||||
|
|||||||
@ -27,7 +27,7 @@ namespace rexy{
|
|||||||
template<class T, class Allocator>
|
template<class T, class Allocator>
|
||||||
constexpr buffer<T,Allocator>::buffer(void){}
|
constexpr buffer<T,Allocator>::buffer(void){}
|
||||||
template<class T, class Allocator>
|
template<class T, class Allocator>
|
||||||
REXY_CPP20_CONSTEXPR buffer<T,Allocator>::buffer(const_pointer data, size_type length)noexcept(noexcept(this->allocate(0))):
|
REXY_CPP20_CONSTEXPR buffer<T,Allocator>::buffer(const_pointer data, size_type length)noexcept(is_nothrow_allocator_v<Allocator>):
|
||||||
m_data(this->allocate(sizeof(value_type) * length)),
|
m_data(this->allocate(sizeof(value_type) * length)),
|
||||||
m_cap(length),
|
m_cap(length),
|
||||||
m_size(length)
|
m_size(length)
|
||||||
@ -54,12 +54,12 @@ namespace rexy{
|
|||||||
m_size = count;
|
m_size = count;
|
||||||
}
|
}
|
||||||
template<class T, class Allocator>
|
template<class T, class Allocator>
|
||||||
REXY_CPP20_CONSTEXPR buffer<T,Allocator>::buffer(size_type cap)noexcept(noexcept(this->allocate(0))):
|
REXY_CPP20_CONSTEXPR buffer<T,Allocator>::buffer(size_type cap)noexcept(is_nothrow_allocator_v<Allocator>):
|
||||||
m_data(this->allocate(sizeof(value_type) * cap)),
|
m_data(this->allocate(sizeof(value_type) * cap)),
|
||||||
m_cap(cap),
|
m_cap(cap),
|
||||||
m_size(0){}
|
m_size(0){}
|
||||||
template<class T, class Allocator>
|
template<class T, class Allocator>
|
||||||
REXY_CPP20_CONSTEXPR buffer<T,Allocator>::buffer(const buffer& b)noexcept(noexcept(this->allocate(0))):
|
REXY_CPP20_CONSTEXPR buffer<T,Allocator>::buffer(const buffer& b)noexcept(is_nothrow_allocator_v<Allocator>):
|
||||||
m_data(this->allocate(sizeof(value_type) * b.m_cap)),
|
m_data(this->allocate(sizeof(value_type) * b.m_cap)),
|
||||||
m_cap(b.m_cap),
|
m_cap(b.m_cap),
|
||||||
m_size(b.m_size)
|
m_size(b.m_size)
|
||||||
@ -74,7 +74,7 @@ namespace rexy{
|
|||||||
m_cap(b.m_cap),
|
m_cap(b.m_cap),
|
||||||
m_size(b.m_size){}
|
m_size(b.m_size){}
|
||||||
template<class T, class Allocator>
|
template<class T, class Allocator>
|
||||||
REXY_CPP20_CONSTEXPR buffer<T,Allocator>::~buffer(void)noexcept(noexcept(this->deallocate(nullptr, 0))){
|
REXY_CPP20_CONSTEXPR buffer<T,Allocator>::~buffer(void)noexcept(is_nothrow_allocator_v<Allocator>){
|
||||||
for(size_type i = 0;i < m_size;++i){
|
for(size_type i = 0;i < m_size;++i){
|
||||||
m_data[i].~T();
|
m_data[i].~T();
|
||||||
}
|
}
|
||||||
@ -82,8 +82,7 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
template<class T, class Allocator>
|
template<class T, class Allocator>
|
||||||
REXY_CPP20_CONSTEXPR buffer<T,Allocator>& buffer<T,Allocator>::operator=(const buffer& b)
|
REXY_CPP20_CONSTEXPR buffer<T,Allocator>& buffer<T,Allocator>::operator=(const buffer& b)
|
||||||
noexcept(noexcept(this->allocate(0)) &&
|
noexcept(is_nothrow_allocator_v<Allocator>)
|
||||||
noexcept(this->deallocate(nullptr, 0)))
|
|
||||||
{
|
{
|
||||||
return (*this = buffer(b));
|
return (*this = buffer(b));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user