From 9de68bce8e1cf5b9b74ee0802fb78bcb100bcc4d Mon Sep 17 00:00:00 2001 From: Jan Gaspar Date: Tue, 26 Jul 2005 15:58:20 +0000 Subject: [PATCH] updated insert/rinsert methods - preparation for input iterator fix [SVN r2666] --- include/boost/circular_buffer/adaptor.hpp | 2 +- include/boost/circular_buffer/base.hpp | 46 +++++++++++++++++------ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/include/boost/circular_buffer/adaptor.hpp b/include/boost/circular_buffer/adaptor.hpp index d0d5f71..6ac7ceb 100644 --- a/include/boost/circular_buffer/adaptor.hpp +++ b/include/boost/circular_buffer/adaptor.hpp @@ -494,7 +494,7 @@ private: //! Determine the initial capacity. template static size_type init_capacity(size_type capacity, size_type min_capacity, InputIterator first, InputIterator last) { - BOOST_CB_IS_CONVERTIBLE(InputIterator, value_type); + BOOST_CB_IS_CONVERTIBLE(InputIterator, value_type); // check for valid iterator type return std::min(capacity, std::max(min_capacity, static_cast(std::distance(first, last)))); } diff --git a/include/boost/circular_buffer/base.hpp b/include/boost/circular_buffer/base.hpp index c06a90f..322cb40 100644 --- a/include/boost/circular_buffer/base.hpp +++ b/include/boost/circular_buffer/base.hpp @@ -452,7 +452,7 @@ public: InputIterator last, const allocator_type& alloc = allocator_type()) : m_alloc(alloc) { - BOOST_CB_IS_CONVERTIBLE(InputIterator, value_type); + BOOST_CB_IS_CONVERTIBLE(InputIterator, value_type); // check for valid iterator type BOOST_CB_ASSERT(std::distance(first, last) >= 0); // check for wrong range m_first = m_buff = allocate(capacity); m_end = m_buff + capacity; @@ -1132,7 +1132,7 @@ private: //! Specialized assign method. template void assign(Iterator first, Iterator last, cb_details::iterator_tag) { - BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); + BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); // check for valid iterator type assign(first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY::type()); } @@ -1172,15 +1172,27 @@ private: } //! Specialized insert method. - template - void insert(iterator pos, InputIterator n, InputIterator item, cb_details::int_tag) { + template + void insert(iterator pos, IntegralType n, IntegralType item, cb_details::int_tag) { insert(pos, (size_type)n, item); } + //! Specialized insert method. + template + void insert(iterator pos, Iterator first, Iterator last, cb_details::iterator_tag) { + BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); // check for valid iterator type + insert(pos, first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY::type()); + } + //! Specialized insert method. template - void insert(iterator pos, InputIterator first, InputIterator last, cb_details::iterator_tag) { - BOOST_CB_IS_CONVERTIBLE(InputIterator, value_type); + void insert(iterator pos, InputIterator first, InputIterator last, std::input_iterator_tag) { + + } + + //! Specialized insert method. + template + void insert(iterator pos, ForwardIterator first, ForwardIterator last, std::forward_iterator_tag) { BOOST_CB_ASSERT(std::distance(first, last) >= 0); // check for wrong range difference_type n = std::distance(first, last); if (n == 0) @@ -1192,9 +1204,9 @@ private: std::advance(first, n - copy); n = copy; } - insert_n_item(pos, n, iterator_wrapper(first)); + insert_n_item(pos, n, iterator_wrapper(first)); } - + //! Helper insert method. template void insert_n_item(iterator pos, size_type n, const Wrapper& wrapper) { @@ -1246,11 +1258,23 @@ private: } //! Specialized rinsert method. + template + void rinsert(iterator pos, Iterator first, Iterator last, cb_details::iterator_tag) { + BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); // check for valid iterator type + rinsert(pos, first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY::type()); + } + + //! Specialized insert method. template - void rinsert(iterator pos, InputIterator first, InputIterator last, cb_details::iterator_tag) { - BOOST_CB_IS_CONVERTIBLE(InputIterator, value_type); + void rinsert(iterator pos, InputIterator first, InputIterator last, std::input_iterator_tag) { + + } + + //! Specialized rinsert method. + template + void rinsert(iterator pos, ForwardIterator first, ForwardIterator last, std::forward_iterator_tag) { BOOST_CB_ASSERT(std::distance(first, last) >= 0); // check for wrong range - rinsert_n_item(pos, std::distance(first, last), iterator_wrapper(first)); + rinsert_n_item(pos, std::distance(first, last), iterator_wrapper(first)); } //! Helper rinsert method.