Skip to content

Commit 66c7308

Browse files
committed
added copy constructor
1 parent 67a6a80 commit 66c7308

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

circular_buffer.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ class CircularBuffer {
3131

3232
CircularBuffer(const CircularBuffer& other)
3333
:_buff{std::unique_ptr<T[]>(new T[other.capacity()])},
34-
_max_size{other.capacity()}{
34+
_max_size{other.capacity()},
35+
_size{other._size},
36+
_head{other._head},
37+
_tail{other._tail},
38+
_full{other._full}{
3539

3640
std::copy(other.data(), other.data() + _max_size, _buff.get());
3741
}

samples/sample_circularbuffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ int main(int argc, char *argv[])
125125
std::cout<<"Checking maxsize of copy buffer"<<test_stringbufcopy.capacity()<<"\n";
126126
std::cout<<"Checking size of copy buffer"<<test_stringbufcopy.size()<<"\n";
127127
std::cout<<"Checking [] in copybuffer"<<test_stringbufcopy[1]<<"\n";
128-
std::cout<<"Checking maxsize buffer"<<test_structbuf.capacity()<<"\n";
129-
std::cout<<"Checking size buffer"<<test_structbuf.size()<<"\n";
128+
std::cout<<"Checking maxsize buffer"<<test_stringbuf.capacity()<<"\n";
129+
std::cout<<"Checking size buffer"<<test_stringbuf.size()<<"\n";
130130

131131
return 0;
132132
}

0 commit comments

Comments
 (0)