Skip to content

Commit dae0d66

Browse files
authored
Merge pull request #32 from NAThompson/develop
Add .cbegin() and .cend().
2 parents 7be41ca + 466b40a commit dae0d66

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

include/boost/circular_buffer/base.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ private empty_value<Alloc>
287287
*/
288288
const_iterator begin() const BOOST_NOEXCEPT { return const_iterator(this, empty() ? 0 : m_first); }
289289

290+
const_iterator cbegin() const BOOST_NOEXCEPT { return begin(); }
290291
//! Get the const iterator pointing to the end of the <code>circular_buffer</code>.
291292
/*!
292293
\return A const random access iterator pointing to the element "one behind" the last element of the <code>
@@ -303,6 +304,7 @@ private empty_value<Alloc>
303304
*/
304305
const_iterator end() const BOOST_NOEXCEPT { return const_iterator(this, 0); }
305306

307+
const_iterator cend() const BOOST_NOEXCEPT { return end(); }
306308
//! Get the iterator pointing to the beginning of the "reversed" <code>circular_buffer</code>.
307309
/*!
308310
\return A reverse random access iterator pointing to the last element of the <code>circular_buffer</code>.

test/base_test.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,23 @@ void iterator_constructor_and_assign_test() {
1717

1818
circular_buffer<MyInteger> cb(4, 3);
1919
circular_buffer<MyInteger>::iterator it = cb.begin();
20+
circular_buffer<MyInteger>::const_iterator cit2 = cb.cbegin();
2021
circular_buffer<MyInteger>::iterator itCopy;
2122
itCopy = it;
2223
it = it;
2324
circular_buffer<MyInteger>::const_iterator cit;
2425
cit = it;
2526
circular_buffer<MyInteger>::const_iterator end1 = cb.end();
2627
circular_buffer<MyInteger>::const_iterator end2 = end1;
28+
circular_buffer<MyInteger>::const_iterator end3 = cb.cend();
2729

2830
BOOST_TEST(itCopy == it);
2931
BOOST_TEST(cit == it);
3032
BOOST_TEST(end1 == end2);
3133
BOOST_TEST(it != end1);
3234
BOOST_TEST(cit != end2);
35+
BOOST_TEST(cit2 == it);
36+
BOOST_TEST(end3 == end1);
3337
}
3438

3539
void iterator_reference_test() {

0 commit comments

Comments
 (0)