/**
This file is a part of rexy's general purpose library
Copyright (C) 2021 rexy712
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#ifndef REXY_BUFFER_HPP
#define REXY_BUFFER_HPP
#include "allocator.hpp"
#include "detail/hasallocator.hpp"
#include //size_t, ptrdiff_t
#include //reverse_iterator
namespace rexy{
template>
class buffer : protected detail::hasallocator
{
public:
using value_type = T;
using size_type = size_t;
using difference_type = ptrdiff_t;
using pointer = T*;
using const_pointer = const T*;
using reference = T&;
using const_reference = const T&;
using allocator_type = Allocator;
using iterator = T*;
using const_iterator = const T*;
using reverse_iterator = std::reverse_iterator;
using const_reverse_iterator = std::reverse_iterator;
protected:
pointer m_data = nullptr;
size_type m_cap = 0;
size_type m_size = 0;
public:
constexpr buffer(void);
buffer(const_pointer data, size_type length)noexcept(noexcept(this->allocate(0)));
template
buffer(const Iter& start, const Iter& last);
buffer(size_type cap)noexcept(noexcept(this->allocate(0)));
buffer(const buffer& b)noexcept(noexcept(this->allocate(0)));
constexpr buffer(buffer&& b)noexcept;
~buffer(void)noexcept(noexcept(this->deallocate(nullptr, 0)));
buffer& operator=(const buffer& b)
noexcept(noexcept(this->allocate(0)) &&
noexcept(this->deallocate(nullptr, 0)));
constexpr buffer& operator=(buffer&& b)noexcept;
constexpr pointer data(void);
constexpr const_pointer data(void)const;
void resize(size_type new_cap);
constexpr void set_size(size_type size);
constexpr size_type cap(void)const;
constexpr const size_type& size(void)const;
constexpr size_type& size(void);
constexpr pointer release(void);
constexpr reference operator[](size_type i);
constexpr const_reference operator[](size_type i)const;
constexpr reference at(size_type i);
constexpr const_reference at(size_type i)const;
constexpr iterator begin(void);
constexpr const_iterator begin(void)const;
constexpr const_iterator cbegin(void)const;
constexpr iterator end(void);
constexpr const_iterator end(void)const;
constexpr const_iterator cend(void)const;
constexpr reverse_iterator rbegin(void);
constexpr const_reverse_iterator rbegin(void)const;
constexpr reverse_iterator rend(void);
constexpr const_reverse_iterator rend(void)const;
constexpr const_reverse_iterator crbegin(void)const;
constexpr const_reverse_iterator crend(void)const;
};
}
#include "buffer.tpp"
#endif