22 #include <type_traits>
28 template <
typename Elem,
30 typename Allocator = std::allocator<Elem>>
33 using storage = std::deque<Elem, Allocator>;
34 using allocator_type =
typename storage::allocator_type;
35 using value_type =
typename storage::value_type;
36 using reference =
typename storage::reference;
37 using const_reference =
typename storage::const_reference;
38 using iterator =
typename storage::iterator;
39 using const_iterator =
typename storage::const_iterator;
40 using reverse_iterator =
typename storage::reverse_iterator;
41 using const_reverse_iterator =
typename storage::const_reverse_iterator;
42 using difference_type =
typename storage::difference_type;
43 using size_type =
typename storage::size_type;
50 DequeRingBuf(
const allocator_type& alloc) : data_(alloc) {}
52 : data_(other.data_, allocator) {}
54 : data_(std::move(other.data_), allocator) {}
56 allocator_type get_allocator()
const {
return data_.get_allocator(); }
58 reference front() {
return data_.front(); }
59 const_reference front()
const {
return data_.front(); }
60 reference back() {
return data_.back(); }
61 const_reference back()
const {
return data_.back(); }
62 reference at(size_type index) {
return data_.at(index); }
63 const_reference at(size_type index)
const {
return data_.at(index); }
64 reference operator[](size_type index) {
return data_[index]; }
65 const_reference operator[](size_type index)
const {
return data_[index]; }
67 iterator begin() {
return data_.begin(); }
68 iterator end() {
return data_.end(); }
69 const_iterator begin()
const {
return data_.begin(); }
70 const_iterator end()
const {
return data_.end(); }
71 const_iterator cbegin()
const {
return data_.cbegin(); }
72 const_iterator cend()
const {
return data_.cend(); }
73 reverse_iterator rbegin() {
return data_.rbegin(); }
74 reverse_iterator rend() {
return data_.rend(); }
75 const_reverse_iterator rbegin()
const {
return data_.rbegin(); }
76 const_reverse_iterator rend()
const {
return data_.rend(); }
77 const_reverse_iterator crbegin()
const {
return data_.crbegin(); }
78 const_reverse_iterator crend()
const {
return data_.crend(); }
80 bool empty()
const {
return data_.empty(); }
81 size_type size()
const {
return data_.size(); }
82 constexpr size_type max_size()
const {
return Capacity; }
84 void clear() noexcept(noexcept(data_.clear())) {
return data_.clear(); }
85 iterator erase(const_iterator pos) noexcept(noexcept(data_.erase(pos))) {
86 return data_.erase(pos);
88 iterator erase(const_iterator first,
89 const_iterator last) noexcept(noexcept(data_.erase(first,
91 return data_.erase(first, last);
94 void push_front(const_reference value) { emplace_front(value); }
95 void push_front(value_type&& value) { emplace_front(std::move(value)); }
97 template <
typename... Args>
98 reference emplace_front(Args&&... args) {
99 if (max_size() == 0) {
100 return data_.front();
103 data_.emplace_front(std::forward<Args>(args)...);
105 if (size() > max_size()) {
108 return data_.front();
111 void push_back(const_reference value) { emplace_back(value); }
112 void push_back(value_type&& value) { emplace_back(std::move(value)); }
114 template <
typename... Args>
115 reference emplace_back(Args&&... args) {
116 if (max_size() == 0) {
120 data_.emplace_back(std::forward<Args>(args)...);
122 if (size() > max_size()) {
128 void pop_front() noexcept(noexcept(data_.pop_front())) {
129 return data_.pop_front();
131 void pop_back() noexcept(noexcept(data_.pop_back())) {
132 return data_.pop_back();
135 void swap(
DequeRingBuf& other) noexcept(noexcept(data_.swap(other.data_))) {
136 return data_.swap(other.data_);
140 return lhs.data_ < rhs.data_;
143 return lhs.data_ > rhs.data_;
146 return lhs.data_ <= rhs.data_;
149 return lhs.data_ >= rhs.data_;
152 return lhs.data_ == rhs.data_;
155 return lhs.data_ != rhs.data_;