Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ae705c7

Browse filesBrowse files
committed
fixed some bugs regarding acess rights
1 parent 1b9ecf4 commit ae705c7
Copy full SHA for ae705c7

File tree

1 file changed

+10
-10
lines changed
Filter options

1 file changed

+10
-10
lines changed

‎circular_buffer.h

Copy file name to clipboardExpand all lines: circular_buffer.h
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <mutex>
66
#include <memory>
77
#include <iterator>
8-
#include <type_traits>
98
#include <algorithm>
109
#include <utility>
1110

@@ -20,7 +19,7 @@ class CircularBuffer {
2019
typedef const T& const_reference;
2120
typedef size_t size_type;
2221
typedef ptrdiff_t difference_type;
23-
template <bool isConst> struct BufferIterator;
22+
template <bool isConst> struct BufferIterator;
2423

2524

2625
public:
@@ -80,7 +79,7 @@ class CircularBuffer {
8079
}
8180
return *this;
8281
}
83-
82+
8483
void push_back(const value_type& data);
8584
void push_back(value_type&& data) noexcept;
8685
void pop_front();
@@ -116,31 +115,33 @@ class CircularBuffer {
116115
void _decrement_bufferstate();
117116
mutable std::mutex _mtx;
118117
std::unique_ptr<value_type[]> _buff;
119-
120118
size_type _head = 0;
121119
size_type _tail = 0;
122120
size_type _size = 0;
123121
size_type _max_size = 0;
124-
122+
125123
template<bool isConst = false>
126124
struct BufferIterator{
127125
public:
128-
129-
typedef std::random_access_iterator_tag iterator_type;
126+
friend class CircularBuffer<T>;
127+
typedef std::forward_iterator_tag iterator_category;
128+
typedef ptrdiff_t difference_type;
129+
typedef T value_type;
130130
typedef typename std::conditional<isConst, const value_type&, value_type&>::type reference;
131131
typedef typename std::conditional<isConst, const value_type*, value_type*>::type pointer;
132132
typedef typename std::conditional<isConst, const CircularBuffer<value_type>*,
133133
CircularBuffer<value_type>*>::type cbuf_pointer;
134-
134+
private:
135135
cbuf_pointer _ptrToBuffer;
136136
size_type _offset;
137137
size_type _index;
138138
bool _reverse;
139-
139+
140140
bool _comparable(const BufferIterator<isConst>& other) const{
141141
return (_ptrToBuffer == other._ptrToBuffer)&&(_reverse == other._reverse);
142142
}
143143

144+
public:
144145
BufferIterator()
145146
:_ptrToBuffer{nullptr}, _offset{0}, _index{0}, _reverse{false}{}
146147

@@ -246,7 +247,6 @@ class CircularBuffer {
246247
return false;
247248
return ((_index + _offset)>=(other._index+other._offset));
248249
}
249-
250250
};
251251
};
252252

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.