diff options
author | bugaevskiy <bugaevskiy@yandex-team.com> | 2022-08-13 11:01:28 +0300 |
---|---|---|
committer | bugaevskiy <bugaevskiy@yandex-team.com> | 2022-08-13 11:01:28 +0300 |
commit | 9f56b74635b15ccaa4ff881784be7ed8e3f18fe1 (patch) | |
tree | 327cbe13b6f71d02e5d4db4a053c8280acaf35cb | |
parent | a85e598807b487f05575def7c6d63a3f827e5b89 (diff) | |
download | ydb-9f56b74635b15ccaa4ff881784be7ed8e3f18fe1.tar.gz |
Reimport boost/circular_buffer as a separate project
-rw-r--r-- | CMakeLists.darwin.txt | 1 | ||||
-rw-r--r-- | CMakeLists.linux.txt | 1 | ||||
-rw-r--r-- | contrib/restricted/boost/CMakeLists.txt | 1 | ||||
-rw-r--r-- | contrib/restricted/boost/boost/circular_buffer.hpp | 62 | ||||
-rw-r--r-- | contrib/restricted/boost/boost/circular_buffer/base.hpp | 3134 | ||||
-rw-r--r-- | contrib/restricted/boost/boost/circular_buffer/debug.hpp | 248 | ||||
-rw-r--r-- | contrib/restricted/boost/boost/circular_buffer/details.hpp | 475 | ||||
-rw-r--r-- | contrib/restricted/boost/boost/circular_buffer/space_optimized.hpp | 1713 | ||||
-rw-r--r-- | contrib/restricted/boost/boost/circular_buffer_fwd.hpp | 43 | ||||
-rw-r--r-- | contrib/restricted/boost/circular_buffer/CMakeLists.txt | 25 |
10 files changed, 28 insertions, 5675 deletions
diff --git a/CMakeLists.darwin.txt b/CMakeLists.darwin.txt index 49ed346e46..6985f59f9b 100644 --- a/CMakeLists.darwin.txt +++ b/CMakeLists.darwin.txt @@ -291,6 +291,7 @@ add_subdirectory(contrib/restricted/boost/smart_ptr) add_subdirectory(contrib/restricted/boost/move) add_subdirectory(contrib/restricted/boost/array) add_subdirectory(contrib/restricted/boost/bind) +add_subdirectory(contrib/restricted/boost/circular_buffer) add_subdirectory(contrib/restricted/boost/concept_check) add_subdirectory(contrib/restricted/boost/container) add_subdirectory(contrib/restricted/boost/intrusive) diff --git a/CMakeLists.linux.txt b/CMakeLists.linux.txt index cd15eb1c81..99ba472a13 100644 --- a/CMakeLists.linux.txt +++ b/CMakeLists.linux.txt @@ -294,6 +294,7 @@ add_subdirectory(contrib/restricted/boost/smart_ptr) add_subdirectory(contrib/restricted/boost/move) add_subdirectory(contrib/restricted/boost/array) add_subdirectory(contrib/restricted/boost/bind) +add_subdirectory(contrib/restricted/boost/circular_buffer) add_subdirectory(contrib/restricted/boost/concept_check) add_subdirectory(contrib/restricted/boost/container) add_subdirectory(contrib/restricted/boost/intrusive) diff --git a/contrib/restricted/boost/CMakeLists.txt b/contrib/restricted/boost/CMakeLists.txt index 570d833e19..fcc62241c5 100644 --- a/contrib/restricted/boost/CMakeLists.txt +++ b/contrib/restricted/boost/CMakeLists.txt @@ -18,6 +18,7 @@ target_link_libraries(contrib-restricted-boost INTERFACE restricted-boost-array restricted-boost-assert restricted-boost-bind + restricted-boost-circular_buffer restricted-boost-concept_check restricted-boost-config restricted-boost-container diff --git a/contrib/restricted/boost/boost/circular_buffer.hpp b/contrib/restricted/boost/boost/circular_buffer.hpp deleted file mode 100644 index 7cf8928bc0..0000000000 --- a/contrib/restricted/boost/boost/circular_buffer.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// Circular buffer library header file. - -// Copyright (c) 2003-2008 Jan Gaspar - -// Use, modification, and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See www.boost.org/libs/circular_buffer for documentation. - -#if !defined(BOOST_CIRCULAR_BUFFER_HPP) -#define BOOST_CIRCULAR_BUFFER_HPP - -#if defined(_MSC_VER) - #pragma once -#endif - -#include <boost/circular_buffer_fwd.hpp> -#include <boost/detail/workaround.hpp> -#include <boost/static_assert.hpp> - -// BOOST_CB_ENABLE_DEBUG: Debug support control. -#if !defined(BOOST_CB_ENABLE_DEBUG) - #define BOOST_CB_ENABLE_DEBUG 0 -#endif - -// BOOST_CB_ASSERT: Runtime assertion. -#if BOOST_CB_ENABLE_DEBUG - #include <boost/assert.hpp> - #define BOOST_CB_ASSERT(Expr) BOOST_ASSERT(Expr) -#else - #define BOOST_CB_ASSERT(Expr) ((void)0) -#endif - -// BOOST_CB_IS_CONVERTIBLE: Check if Iterator::value_type is convertible to Type. -#if BOOST_WORKAROUND(__BORLANDC__, <= 0x0550) || BOOST_WORKAROUND(__MWERKS__, <= 0x2407) - #define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) ((void)0) -#else - #include <boost/detail/iterator.hpp> - #include <boost/type_traits/is_convertible.hpp> - #define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) \ - BOOST_STATIC_ASSERT((is_convertible<typename detail::iterator_traits<Iterator>::value_type, Type>::value)) -#endif - -// BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS: -// Check if the STL provides templated iterator constructors for its containers. -#if defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) - #define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS BOOST_STATIC_ASSERT(false); -#else - #define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS ((void)0); -#endif - -#include <boost/circular_buffer/debug.hpp> -#include <boost/circular_buffer/details.hpp> -#include <boost/circular_buffer/base.hpp> -#include <boost/circular_buffer/space_optimized.hpp> - -#undef BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS -#undef BOOST_CB_IS_CONVERTIBLE -#undef BOOST_CB_ASSERT - -#endif // #if !defined(BOOST_CIRCULAR_BUFFER_HPP) diff --git a/contrib/restricted/boost/boost/circular_buffer/base.hpp b/contrib/restricted/boost/boost/circular_buffer/base.hpp deleted file mode 100644 index 47441544d4..0000000000 --- a/contrib/restricted/boost/boost/circular_buffer/base.hpp +++ /dev/null @@ -1,3134 +0,0 @@ -// Implementation of the base circular buffer. - -// Copyright (c) 2003-2008 Jan Gaspar -// Copyright (c) 2013 Paul A. Bristow // Doxygen comments changed. -// Copyright (c) 2013 Antony Polukhin // Move semantics implementation. - -// Copyright 2014,2018 Glen Joseph Fernandes -// (glenjofe@gmail.com) - -// Use, modification, and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#if !defined(BOOST_CIRCULAR_BUFFER_BASE_HPP) -#define BOOST_CIRCULAR_BUFFER_BASE_HPP - -#if defined(_MSC_VER) - #pragma once -#endif - -#include <boost/config.hpp> -#include <boost/concept_check.hpp> -#include <boost/limits.hpp> -#include <boost/core/allocator_access.hpp> -#include <boost/core/empty_value.hpp> -#include <boost/type_traits/is_stateless.hpp> -#include <boost/type_traits/is_integral.hpp> -#include <boost/type_traits/is_scalar.hpp> -#include <boost/type_traits/is_nothrow_move_constructible.hpp> -#include <boost/type_traits/is_nothrow_move_assignable.hpp> -#include <boost/type_traits/is_copy_constructible.hpp> -#include <boost/type_traits/conditional.hpp> -#include <boost/move/adl_move_swap.hpp> -#include <boost/move/move.hpp> -#include <algorithm> -#include <iterator> -#include <utility> -#include <deque> -#include <stdexcept> - -#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205)) - #include <stddef.h> -#endif - -namespace boost { - -/*! - \class circular_buffer - \brief Circular buffer - a STL compliant container. - \tparam T The type of the elements stored in the <code>circular_buffer</code>. - \par Type Requirements T - The <code>T</code> has to be <a href="https://www.boost.org/sgi/stl/Assignable.html"> - SGIAssignable</a> (SGI STL defined combination of <a href="../../../utility/Assignable.html"> - Assignable</a> and <a href="../../../utility/CopyConstructible.html">CopyConstructible</a>). - Moreover <code>T</code> has to be <a href="https://www.boost.org/sgi/stl/DefaultConstructible.html"> - DefaultConstructible</a> if supplied as a default parameter when invoking some of the - <code>circular_buffer</code>'s methods e.g. - <code>insert(iterator pos, const value_type& item = %value_type())</code>. And - <a href="https://www.boost.org/sgi/stl/EqualityComparable.html">EqualityComparable</a> and/or - <a href="../../../utility/LessThanComparable.html">LessThanComparable</a> if the <code>circular_buffer</code> - will be compared with another container. - \tparam Alloc The allocator type used for all internal memory management. - \par Type Requirements Alloc - The <code>Alloc</code> has to meet the allocator requirements imposed by STL. - \par Default Alloc - std::allocator<T> - - For detailed documentation of the circular_buffer visit: - http://www.boost.org/libs/circular_buffer/doc/circular_buffer.html -*/ -template <class T, class Alloc> -class circular_buffer -: -/*! \cond */ -#if BOOST_CB_ENABLE_DEBUG -public cb_details::debug_iterator_registry, -#endif -/*! \endcond */ -private empty_value<Alloc> -{ - typedef empty_value<Alloc> base; - - // Requirements - //BOOST_CLASS_REQUIRE(T, boost, SGIAssignableConcept); - - - //BOOST_CONCEPT_ASSERT((Assignable<T>)); - //BOOST_CONCEPT_ASSERT((CopyConstructible<T>)); - //BOOST_CONCEPT_ASSERT((DefaultConstructible<T>)); - - // Required if the circular_buffer will be compared with anther container. - //BOOST_CONCEPT_ASSERT((EqualityComparable<T>)); - //BOOST_CONCEPT_ASSERT((LessThanComparable<T>)); - -public: -// Basic types - - //! The type of this <code>circular_buffer</code>. - typedef circular_buffer<T, Alloc> this_type; - - //! The type of elements stored in the <code>circular_buffer</code>. - typedef typename Alloc::value_type value_type; - - //! A pointer to an element. - typedef typename allocator_pointer<Alloc>::type pointer; - - //! A const pointer to the element. - typedef typename allocator_const_pointer<Alloc>::type const_pointer; - - //! A reference to an element. - typedef value_type& reference; - - //! A const reference to an element. - typedef const value_type& const_reference; - - //! The distance type. - /*! - (A signed integral type used to represent the distance between two iterators.) - */ - typedef typename allocator_difference_type<Alloc>::type difference_type; - - //! The size type. - /*! - (An unsigned integral type that can represent any non-negative value of the container's distance type.) - */ - typedef typename allocator_size_type<Alloc>::type size_type; - - //! The type of an allocator used in the <code>circular_buffer</code>. - typedef Alloc allocator_type; - -// Iterators - - //! A const (random access) iterator used to iterate through the <code>circular_buffer</code>. - typedef cb_details::iterator< circular_buffer<T, Alloc>, cb_details::const_traits<Alloc> > const_iterator; - - //! A (random access) iterator used to iterate through the <code>circular_buffer</code>. - typedef cb_details::iterator< circular_buffer<T, Alloc>, cb_details::nonconst_traits<Alloc> > iterator; - - //! A const iterator used to iterate backwards through a <code>circular_buffer</code>. - typedef std::reverse_iterator<const_iterator> const_reverse_iterator; - - //! An iterator used to iterate backwards through a <code>circular_buffer</code>. - typedef std::reverse_iterator<iterator> reverse_iterator; - -// Container specific types - - //! An array range. - /*! - (A typedef for the <a href="https://www.boost.org/sgi/stl/pair.html"><code>std::pair</code></a> where - its first element is a pointer to a beginning of an array and its second element represents - a size of the array.) - */ - typedef std::pair<pointer, size_type> array_range; - - //! A range of a const array. - /*! - (A typedef for the <a href="https://www.boost.org/sgi/stl/pair.html"><code>std::pair</code></a> where - its first element is a pointer to a beginning of a const array and its second element represents - a size of the const array.) - */ - typedef std::pair<const_pointer, size_type> const_array_range; - - //! The capacity type. - /*! - (Same as <code>size_type</code> - defined for consistency with the __cbso class. - - */ - // <a href="space_optimized.html"><code>circular_buffer_space_optimized</code></a>.) - - typedef size_type capacity_type; - -// Helper types - - //! A type representing the "best" way to pass the value_type to a method. - typedef const value_type& param_value_type; - - //! A type representing rvalue from param type. - //! On compilers without rvalue references support this type is the Boost.Moves type used for emulation. - typedef BOOST_RV_REF(value_type) rvalue_type; - -private: -// Member variables - - //! The internal buffer used for storing elements in the circular buffer. - pointer m_buff; - - //! The internal buffer's end (end of the storage space). - pointer m_end; - - //! The virtual beginning of the circular buffer. - pointer m_first; - - //! The virtual end of the circular buffer (one behind the last element). - pointer m_last; - - //! The number of items currently stored in the circular buffer. - size_type m_size; - -// Friends -#if defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) - friend iterator; - friend const_iterator; -#else - template <class Buff, class Traits> friend struct cb_details::iterator; -#endif - -public: -// Allocator - - //! Get the allocator. - /*! - \return The allocator. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>get_allocator()</code> for obtaining an allocator %reference. - */ - allocator_type get_allocator() const BOOST_NOEXCEPT { return alloc(); } - - //! Get the allocator reference. - /*! - \return A reference to the allocator. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \note This method was added in order to optimize obtaining of the allocator with a state, - although use of stateful allocators in STL is discouraged. - \sa <code>get_allocator() const</code> - */ - allocator_type& get_allocator() BOOST_NOEXCEPT { return alloc(); } - -// Element access - - //! Get the iterator pointing to the beginning of the <code>circular_buffer</code>. - /*! - \return A random access iterator pointing to the first element of the <code>circular_buffer</code>. If the - <code>circular_buffer</code> is empty it returns an iterator equal to the one returned by - <code>end()</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>end()</code>, <code>rbegin()</code>, <code>rend()</code> - */ - iterator begin() BOOST_NOEXCEPT { return iterator(this, empty() ? 0 : m_first); } - - //! Get the iterator pointing to the end of the <code>circular_buffer</code>. - /*! - \return A random access iterator pointing to the element "one behind" the last element of the <code> - circular_buffer</code>. If the <code>circular_buffer</code> is empty it returns an iterator equal to - the one returned by <code>begin()</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>begin()</code>, <code>rbegin()</code>, <code>rend()</code> - */ - iterator end() BOOST_NOEXCEPT { return iterator(this, 0); } - - //! Get the const iterator pointing to the beginning of the <code>circular_buffer</code>. - /*! - \return A const random access iterator pointing to the first element of the <code>circular_buffer</code>. If - the <code>circular_buffer</code> is empty it returns an iterator equal to the one returned by - <code>end() const</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>end() const</code>, <code>rbegin() const</code>, <code>rend() const</code> - */ - const_iterator begin() const BOOST_NOEXCEPT { return const_iterator(this, empty() ? 0 : m_first); } - - const_iterator cbegin() const BOOST_NOEXCEPT { return begin(); } - //! Get the const iterator pointing to the end of the <code>circular_buffer</code>. - /*! - \return A const random access iterator pointing to the element "one behind" the last element of the <code> - circular_buffer</code>. If the <code>circular_buffer</code> is empty it returns an iterator equal to - the one returned by <code>begin() const</code> const. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>begin() const</code>, <code>rbegin() const</code>, <code>rend() const</code> - */ - const_iterator end() const BOOST_NOEXCEPT { return const_iterator(this, 0); } - - const_iterator cend() const BOOST_NOEXCEPT { return end(); } - //! Get the iterator pointing to the beginning of the "reversed" <code>circular_buffer</code>. - /*! - \return A reverse random access iterator pointing to the last element of the <code>circular_buffer</code>. - If the <code>circular_buffer</code> is empty it returns an iterator equal to the one returned by - <code>rend()</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>rend()</code>, <code>begin()</code>, <code>end()</code> - */ - reverse_iterator rbegin() BOOST_NOEXCEPT { return reverse_iterator(end()); } - - //! Get the iterator pointing to the end of the "reversed" <code>circular_buffer</code>. - /*! - \return A reverse random access iterator pointing to the element "one before" the first element of the <code> - circular_buffer</code>. If the <code>circular_buffer</code> is empty it returns an iterator equal to - the one returned by <code>rbegin()</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>rbegin()</code>, <code>begin()</code>, <code>end()</code> - */ - reverse_iterator rend() BOOST_NOEXCEPT { return reverse_iterator(begin()); } - - //! Get the const iterator pointing to the beginning of the "reversed" <code>circular_buffer</code>. - /*! - \return A const reverse random access iterator pointing to the last element of the - <code>circular_buffer</code>. If the <code>circular_buffer</code> is empty it returns an iterator equal - to the one returned by <code>rend() const</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>rend() const</code>, <code>begin() const</code>, <code>end() const</code> - */ - const_reverse_iterator rbegin() const BOOST_NOEXCEPT { return const_reverse_iterator(end()); } - - //! Get the const iterator pointing to the end of the "reversed" <code>circular_buffer</code>. - /*! - \return A const reverse random access iterator pointing to the element "one before" the first element of the - <code>circular_buffer</code>. If the <code>circular_buffer</code> is empty it returns an iterator equal - to the one returned by <code>rbegin() const</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>rbegin() const</code>, <code>begin() const</code>, <code>end() const</code> - */ - const_reverse_iterator rend() const BOOST_NOEXCEPT { return const_reverse_iterator(begin()); } - - //! Get the element at the <code>index</code> position. - /*! - \pre <code>0 \<= index \&\& index \< size()</code> - \param index The position of the element. - \return A reference to the element at the <code>index</code> position. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>at()</code> - */ - reference operator [] (size_type index) { - BOOST_CB_ASSERT(index < size()); // check for invalid index - return *add(m_first, index); - } - - //! Get the element at the <code>index</code> position. - /*! - \pre <code>0 \<= index \&\& index \< size()</code> - \param index The position of the element. - \return A const reference to the element at the <code>index</code> position. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>\link at(size_type)const at() const \endlink</code> - */ - const_reference operator [] (size_type index) const { - BOOST_CB_ASSERT(index < size()); // check for invalid index - return *add(m_first, index); - } - - //! Get the element at the <code>index</code> position. - /*! - \param index The position of the element. - \return A reference to the element at the <code>index</code> position. - \throws <code>std::out_of_range</code> when the <code>index</code> is invalid (when - <code>index >= size()</code>). - \par Exception Safety - Strong. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>\link operator[](size_type) operator[] \endlink</code> - */ - reference at(size_type index) { - check_position(index); - return (*this)[index]; - } - - //! Get the element at the <code>index</code> position. - /*! - \param index The position of the element. - \return A const reference to the element at the <code>index</code> position. - \throws <code>std::out_of_range</code> when the <code>index</code> is invalid (when - <code>index >= size()</code>). - \par Exception Safety - Strong. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>\link operator[](size_type)const operator[] const \endlink</code> - */ - const_reference at(size_type index) const { - check_position(index); - return (*this)[index]; - } - - //! Get the first element. - /*! - \pre <code>!empty()</code> - \return A reference to the first element of the <code>circular_buffer</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>back()</code> - */ - reference front() { - BOOST_CB_ASSERT(!empty()); // check for empty buffer (front element not available) - return *m_first; - } - - //! Get the last element. - /*! - \pre <code>!empty()</code> - \return A reference to the last element of the <code>circular_buffer</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>front()</code> - */ - reference back() { - BOOST_CB_ASSERT(!empty()); // check for empty buffer (back element not available) - return *((m_last == m_buff ? m_end : m_last) - 1); - } - - //! Get the first element. - /*! - \pre <code>!empty()</code> - \return A const reference to the first element of the <code>circular_buffer</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>back() const</code> - */ - const_reference front() const { - BOOST_CB_ASSERT(!empty()); // check for empty buffer (front element not available) - return *m_first; - } - - //! Get the last element. - /*! - \pre <code>!empty()</code> - \return A const reference to the last element of the <code>circular_buffer</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>front() const</code> - */ - const_reference back() const { - BOOST_CB_ASSERT(!empty()); // check for empty buffer (back element not available) - return *((m_last == m_buff ? m_end : m_last) - 1); - } - - //! Get the first continuous array of the internal buffer. - /*! - This method in combination with <code>array_two()</code> can be useful when passing the stored data into - a legacy C API as an array. Suppose there is a <code>circular_buffer</code> of capacity 10, containing 7 - characters <code>'a', 'b', ..., 'g'</code> where <code>buff[0] == 'a'</code>, <code>buff[1] == 'b'</code>, - ... and <code>buff[6] == 'g'</code>:<br><br> - <code>circular_buffer<char> buff(10);</code><br><br> - The internal representation is often not linear and the state of the internal buffer may look like this:<br> - <br><code> - |e|f|g| | | |a|b|c|d|<br> - end ___^<br> - begin _______^</code><br><br> - - where <code>|a|b|c|d|</code> represents the "array one", <code>|e|f|g|</code> represents the "array two" and - <code>| | | |</code> is a free space.<br> - Now consider a typical C style function for writing data into a file:<br><br> - <code>int write(int file_desc, char* buff, int num_bytes);</code><br><br> - There are two ways how to write the content of the <code>circular_buffer</code> into a file. Either relying - on <code>array_one()</code> and <code>array_two()</code> methods and calling the write function twice:<br><br> - <code>array_range ar = buff.array_one();<br> - write(file_desc, ar.first, ar.second);<br> - ar = buff.array_two();<br> - write(file_desc, ar.first, ar.second);</code><br><br> - Or relying on the <code>linearize()</code> method:<br><br><code> - write(file_desc, buff.linearize(), buff.size());</code><br><br> - Since the complexity of <code>array_one()</code> and <code>array_two()</code> methods is constant the first - option is suitable when calling the write method is "cheap". On the other hand the second option is more - suitable when calling the write method is more "expensive" than calling the <code>linearize()</code> method - whose complexity is linear. - \return The array range of the first continuous array of the internal buffer. In the case the - <code>circular_buffer</code> is empty the size of the returned array is <code>0</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \warning In general invoking any method which modifies the internal state of the circular_buffer may - delinearize the internal buffer and invalidate the array ranges returned by <code>array_one()</code> - and <code>array_two()</code> (and their const versions). - \note In the case the internal buffer is linear e.g. <code>|a|b|c|d|e|f|g| | | |</code> the "array one" is - represented by <code>|a|b|c|d|e|f|g|</code> and the "array two" does not exist (the - <code>array_two()</code> method returns an array with the size <code>0</code>). - \sa <code>array_two()</code>, <code>linearize()</code> - */ - array_range array_one() { - return array_range(m_first, (m_last <= m_first && !empty() ? m_end : m_last) - m_first); - } - - //! Get the second continuous array of the internal buffer. - /*! - This method in combination with <code>array_one()</code> can be useful when passing the stored data into - a legacy C API as an array. - \return The array range of the second continuous array of the internal buffer. In the case the internal buffer - is linear or the <code>circular_buffer</code> is empty the size of the returned array is - <code>0</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>array_one()</code> - */ - array_range array_two() { - return array_range(m_buff, m_last <= m_first && !empty() ? m_last - m_buff : 0); - } - - //! Get the first continuous array of the internal buffer. - /*! - This method in combination with <code>array_two() const</code> can be useful when passing the stored data into - a legacy C API as an array. - \return The array range of the first continuous array of the internal buffer. In the case the - <code>circular_buffer</code> is empty the size of the returned array is <code>0</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>array_two() const</code>; <code>array_one()</code> for more details how to pass data into a legacy C - API. - */ - const_array_range array_one() const { - return const_array_range(m_first, (m_last <= m_first && !empty() ? m_end : m_last) - m_first); - } - - //! Get the second continuous array of the internal buffer. - /*! - This method in combination with <code>array_one() const</code> can be useful when passing the stored data into - a legacy C API as an array. - \return The array range of the second continuous array of the internal buffer. In the case the internal buffer - is linear or the <code>circular_buffer</code> is empty the size of the returned array is - <code>0</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>array_one() const</code> - */ - const_array_range array_two() const { - return const_array_range(m_buff, m_last <= m_first && !empty() ? m_last - m_buff : 0); - } - - //! Linearize the internal buffer into a continuous array. - /*! - This method can be useful when passing the stored data into a legacy C API as an array. - \post <code>\&(*this)[0] \< \&(*this)[1] \< ... \< \&(*this)[size() - 1]</code> - \return A pointer to the beginning of the array or <code>0</code> if empty. - \throws <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&)</a>. - \par Exception Safety - Basic; no-throw if the operations in the <i>Throws</i> section do not throw anything. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to - <code>end()</code>); does not invalidate any iterators if the postcondition (the <i>Effect</i>) is already - met prior calling this method. - \par Complexity - Linear (in the size of the <code>circular_buffer</code>); constant if the postcondition (the - <i>Effect</i>) is already met. - \warning In general invoking any method which modifies the internal state of the <code>circular_buffer</code> - may delinearize the internal buffer and invalidate the returned pointer. - \sa <code>array_one()</code> and <code>array_two()</code> for the other option how to pass data into a legacy - C API; <code>is_linearized()</code>, <code>rotate(const_iterator)</code> - */ - pointer linearize() { - if (empty()) - return 0; - if (m_first < m_last || m_last == m_buff) - return m_first; - pointer src = m_first; - pointer dest = m_buff; - size_type moved = 0; - size_type constructed = 0; - BOOST_TRY { - for (pointer first = m_first; dest < src; src = first) { - for (size_type ii = 0; src < m_end; ++src, ++dest, ++moved, ++ii) { - if (moved == size()) { - first = dest; - break; - } - if (dest == first) { - first += ii; - break; - } - if (is_uninitialized(dest)) { - boost::allocator_construct(alloc(), boost::to_address(dest), boost::move_if_noexcept(*src)); - ++constructed; - } else { - value_type tmp = boost::move_if_noexcept(*src); - replace(src, boost::move_if_noexcept(*dest)); - replace(dest, boost::move(tmp)); - } - } - } - } BOOST_CATCH(...) { - m_last += constructed; - m_size += constructed; - BOOST_RETHROW - } - BOOST_CATCH_END - for (src = m_end - constructed; src < m_end; ++src) - destroy_item(src); - m_first = m_buff; - m_last = add(m_buff, size()); -#if BOOST_CB_ENABLE_DEBUG - invalidate_iterators_except(end()); -#endif - return m_buff; - } - - //! Is the <code>circular_buffer</code> linearized? - /*! - \return <code>true</code> if the internal buffer is linearized into a continuous array (i.e. the - <code>circular_buffer</code> meets a condition - <code>\&(*this)[0] \< \&(*this)[1] \< ... \< \&(*this)[size() - 1]</code>); - <code>false</code> otherwise. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>linearize()</code>, <code>array_one()</code>, <code>array_two()</code> - */ - bool is_linearized() const BOOST_NOEXCEPT { return m_first < m_last || m_last == m_buff; } - - //! Rotate elements in the <code>circular_buffer</code>. - /*! - A more effective implementation of - <code><a href="https://www.boost.org/sgi/stl/rotate.html">std::rotate</a></code>. - \pre <code>new_begin</code> is a valid iterator pointing to the <code>circular_buffer</code> <b>except</b> its - end. - \post Before calling the method suppose:<br><br> - <code>m == std::distance(new_begin, end())</code><br><code>n == std::distance(begin(), new_begin)</code> - <br><code>val_0 == *new_begin, val_1 == *(new_begin + 1), ... val_m == *(new_begin + m)</code><br> - <code>val_r1 == *(new_begin - 1), val_r2 == *(new_begin - 2), ... val_rn == *(new_begin - n)</code><br> - <br>then after call to the method:<br><br> - <code>val_0 == (*this)[0] \&\& val_1 == (*this)[1] \&\& ... \&\& val_m == (*this)[m - 1] \&\& val_r1 == - (*this)[m + n - 1] \&\& val_r2 == (*this)[m + n - 2] \&\& ... \&\& val_rn == (*this)[m]</code> - \param new_begin The new beginning. - \throws See <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&)</a>. - \par Exception Safety - Basic; no-throw if the <code>circular_buffer</code> is full or <code>new_begin</code> points to - <code>begin()</code> or if the operations in the <i>Throws</i> section do not throw anything. - \par Iterator Invalidation - If <code>m \< n</code> invalidates iterators pointing to the last <code>m</code> elements - (<b>including</b> <code>new_begin</code>, but not iterators equal to <code>end()</code>) else invalidates - iterators pointing to the first <code>n</code> elements; does not invalidate any iterators if the - <code>circular_buffer</code> is full. - \par Complexity - Linear (in <code>(std::min)(m, n)</code>); constant if the <code>circular_buffer</code> is full. - \sa <code><a href="https://www.boost.org/sgi/stl/rotate.html">std::rotate</a></code> - */ - void rotate(const_iterator new_begin) { - BOOST_CB_ASSERT(new_begin.is_valid(this)); // check for uninitialized or invalidated iterator - BOOST_CB_ASSERT(new_begin.m_it != 0); // check for iterator pointing to end() - if (full()) { - m_first = m_last = const_cast<pointer>(new_begin.m_it); - } else { - difference_type m = end() - new_begin; - difference_type n = new_begin - begin(); - if (m < n) { - for (; m > 0; --m) { - push_front(boost::move_if_noexcept(back())); - pop_back(); - } - } else { - for (; n > 0; --n) { - push_back(boost::move_if_noexcept(front())); - pop_front(); - } - } - } - } - -// Size and capacity - - //! Get the number of elements currently stored in the <code>circular_buffer</code>. - /*! - \return The number of elements stored in the <code>circular_buffer</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>capacity()</code>, <code>max_size()</code>, <code>reserve()</code>, - <code>\link resize() resize(size_type, const_reference)\endlink</code> - */ - size_type size() const BOOST_NOEXCEPT { return m_size; } - - /*! \brief Get the largest possible size or capacity of the <code>circular_buffer</code>. (It depends on - allocator's %max_size()). - \return The maximum size/capacity the <code>circular_buffer</code> can be set to. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>size()</code>, <code>capacity()</code>, <code>reserve()</code> - */ - size_type max_size() const BOOST_NOEXCEPT { - return (std::min<size_type>)(boost::allocator_max_size(alloc()), (std::numeric_limits<difference_type>::max)()); - } - - //! Is the <code>circular_buffer</code> empty? - /*! - \return <code>true</code> if there are no elements stored in the <code>circular_buffer</code>; - <code>false</code> otherwise. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>full()</code> - */ - bool empty() const BOOST_NOEXCEPT { return size() == 0; } - - //! Is the <code>circular_buffer</code> full? - /*! - \return <code>true</code> if the number of elements stored in the <code>circular_buffer</code> - equals the capacity of the <code>circular_buffer</code>; <code>false</code> otherwise. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>empty()</code> - */ - bool full() const BOOST_NOEXCEPT { return capacity() == size(); } - - /*! \brief Get the maximum number of elements which can be inserted into the <code>circular_buffer</code> without - overwriting any of already stored elements. - \return <code>capacity() - size()</code> - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>capacity()</code>, <code>size()</code>, <code>max_size()</code> - */ - size_type reserve() const BOOST_NOEXCEPT { return capacity() - size(); } - - //! Get the capacity of the <code>circular_buffer</code>. - /*! - \return The maximum number of elements which can be stored in the <code>circular_buffer</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>reserve()</code>, <code>size()</code>, <code>max_size()</code>, - <code>set_capacity(capacity_type)</code> - */ - capacity_type capacity() const BOOST_NOEXCEPT { return m_end - m_buff; } - - //! Change the capacity of the <code>circular_buffer</code>. - /*! - \pre If <code>T</code> is a move only type, then compiler shall support <code>noexcept</code> modifiers - and move constructor of <code>T</code> must be marked with it (must not throw exceptions). - \post <code>capacity() == new_capacity \&\& size() \<= new_capacity</code><br><br> - If the current number of elements stored in the <code>circular_buffer</code> is greater than the desired - new capacity then number of <code>[size() - new_capacity]</code> <b>last</b> elements will be removed and - the new size will be equal to <code>new_capacity</code>. - \param new_capacity The new capacity. - \throws "An allocation error" if memory is exhausted, (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept. - \par Exception Safety - Strong. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to - <code>end()</code>) if the new capacity is different from the original. - \par Complexity - Linear (in <code>min[size(), new_capacity]</code>). - \sa <code>rset_capacity(capacity_type)</code>, - <code>\link resize() resize(size_type, const_reference)\endlink</code> - */ - void set_capacity(capacity_type new_capacity) { - if (new_capacity == capacity()) - return; - pointer buff = allocate(new_capacity); - iterator b = begin(); - BOOST_TRY { - reset(buff, - cb_details::uninitialized_move_if_noexcept(b, b + (std::min)(new_capacity, size()), buff, alloc()), - new_capacity); - } BOOST_CATCH(...) { - deallocate(buff, new_capacity); - BOOST_RETHROW - } - BOOST_CATCH_END - } - - //! Change the size of the <code>circular_buffer</code>. - /*! - \post <code>size() == new_size \&\& capacity() >= new_size</code><br><br> - If the new size is greater than the current size, copies of <code>item</code> will be inserted at the - <b>back</b> of the of the <code>circular_buffer</code> in order to achieve the desired size. In the case - the resulting size exceeds the current capacity the capacity will be set to <code>new_size</code>.<br> - If the current number of elements stored in the <code>circular_buffer</code> is greater than the desired - new size then number of <code>[size() - new_size]</code> <b>last</b> elements will be removed. (The - capacity will remain unchanged.) - \param new_size The new size. - \param item The element the <code>circular_buffer</code> will be filled with in order to gain the requested - size. (See the <i>Effect</i>.) - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to - <code>end()</code>) if the new size is greater than the current capacity. Invalidates iterators pointing - to the removed elements if the new size is lower that the original size. Otherwise it does not invalidate - any iterator. - \par Complexity - Linear (in the new size of the <code>circular_buffer</code>). - \sa <code>\link rresize() rresize(size_type, const_reference)\endlink</code>, - <code>set_capacity(capacity_type)</code> - */ - void resize(size_type new_size, param_value_type item = value_type()) { - if (new_size > size()) { - if (new_size > capacity()) - set_capacity(new_size); - insert(end(), new_size - size(), item); - } else { - iterator e = end(); - erase(e - (size() - new_size), e); - } - } - - //! Change the capacity of the <code>circular_buffer</code>. - /*! - \pre If <code>T</code> is a move only type, then compiler shall support <code>noexcept</code> modifiers - and move constructor of <code>T</code> must be marked with it (must not throw exceptions). - \post <code>capacity() == new_capacity \&\& size() \<= new_capacity</code><br><br> - If the current number of elements stored in the <code>circular_buffer</code> is greater than the desired - new capacity then number of <code>[size() - new_capacity]</code> <b>first</b> elements will be removed - and the new size will be equal to <code>new_capacity</code>. - \param new_capacity The new capacity. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept. - \par Exception Safety - Strong. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to - <code>end()</code>) if the new capacity is different from the original. - \par Complexity - Linear (in <code>min[size(), new_capacity]</code>). - \sa <code>set_capacity(capacity_type)</code>, - <code>\link rresize() rresize(size_type, const_reference)\endlink</code> - */ - void rset_capacity(capacity_type new_capacity) { - if (new_capacity == capacity()) - return; - pointer buff = allocate(new_capacity); - iterator e = end(); - BOOST_TRY { - reset(buff, cb_details::uninitialized_move_if_noexcept(e - (std::min)(new_capacity, size()), - e, buff, alloc()), new_capacity); - } BOOST_CATCH(...) { - deallocate(buff, new_capacity); - BOOST_RETHROW - } - BOOST_CATCH_END - } - - //! Change the size of the <code>circular_buffer</code>. - /*! - \post <code>size() == new_size \&\& capacity() >= new_size</code><br><br> - If the new size is greater than the current size, copies of <code>item</code> will be inserted at the - <b>front</b> of the of the <code>circular_buffer</code> in order to achieve the desired size. In the case - the resulting size exceeds the current capacity the capacity will be set to <code>new_size</code>.<br> - If the current number of elements stored in the <code>circular_buffer</code> is greater than the desired - new size then number of <code>[size() - new_size]</code> <b>first</b> elements will be removed. (The - capacity will remain unchanged.) - \param new_size The new size. - \param item The element the <code>circular_buffer</code> will be filled with in order to gain the requested - size. (See the <i>Effect</i>.) - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to - <code>end()</code>) if the new size is greater than the current capacity. Invalidates iterators pointing - to the removed elements if the new size is lower that the original size. Otherwise it does not invalidate - any iterator. - \par Complexity - Linear (in the new size of the <code>circular_buffer</code>). - \sa <code>\link resize() resize(size_type, const_reference)\endlink</code>, - <code>rset_capacity(capacity_type)</code> - */ - void rresize(size_type new_size, param_value_type item = value_type()) { - if (new_size > size()) { - if (new_size > capacity()) - set_capacity(new_size); - rinsert(begin(), new_size - size(), item); - } else { - rerase(begin(), end() - new_size); - } - } - -// Construction/Destruction - - //! Create an empty <code>circular_buffer</code> with zero capacity. - /*! - \post <code>capacity() == 0 \&\& size() == 0</code> - \param alloc The allocator. - \throws Nothing. - \par Complexity - Constant. - \warning Since Boost version 1.36 the behaviour of this constructor has changed. Now the constructor does not - allocate any memory and both capacity and size are set to zero. Also note when inserting an element - into a <code>circular_buffer</code> with zero capacity (e.g. by - <code>\link push_back() push_back(const_reference)\endlink</code> or - <code>\link insert(iterator, param_value_type) insert(iterator, value_type)\endlink</code>) nothing - will be inserted and the size (as well as capacity) remains zero. - \note You can explicitly set the capacity by calling the <code>set_capacity(capacity_type)</code> method or you - can use the other constructor with the capacity specified. - \sa <code>circular_buffer(capacity_type, const allocator_type& alloc)</code>, - <code>set_capacity(capacity_type)</code> - */ - explicit circular_buffer(const allocator_type& alloc = allocator_type()) BOOST_NOEXCEPT - : base(boost::empty_init_t(), alloc), m_buff(0), m_end(0), m_first(0), m_last(0), m_size(0) {} - - //! Create an empty <code>circular_buffer</code> with the specified capacity. - /*! - \post <code>capacity() == buffer_capacity \&\& size() == 0</code> - \param buffer_capacity The maximum number of elements which can be stored in the <code>circular_buffer</code>. - \param alloc The allocator. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - \par Complexity - Constant. - */ - explicit circular_buffer(capacity_type buffer_capacity, const allocator_type& alloc = allocator_type()) - : base(boost::empty_init_t(), alloc), m_size(0) { - initialize_buffer(buffer_capacity); - m_first = m_last = m_buff; - } - - /*! \brief Create a full <code>circular_buffer</code> with the specified capacity and filled with <code>n</code> - copies of <code>item</code>. - \post <code>capacity() == n \&\& full() \&\& (*this)[0] == item \&\& (*this)[1] == item \&\& ... \&\& - (*this)[n - 1] == item </code> - \param n The number of elements the created <code>circular_buffer</code> will be filled with. - \param item The element the created <code>circular_buffer</code> will be filled with. - \param alloc The allocator. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Complexity - Linear (in the <code>n</code>). - */ - circular_buffer(size_type n, param_value_type item, const allocator_type& alloc = allocator_type()) - : base(boost::empty_init_t(), alloc), m_size(n) { - initialize_buffer(n, item); - m_first = m_last = m_buff; - } - - /*! \brief Create a <code>circular_buffer</code> with the specified capacity and filled with <code>n</code> - copies of <code>item</code>. - \pre <code>buffer_capacity >= n</code> - \post <code>capacity() == buffer_capacity \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item - \&\& ... \&\& (*this)[n - 1] == item</code> - \param buffer_capacity The capacity of the created <code>circular_buffer</code>. - \param n The number of elements the created <code>circular_buffer</code> will be filled with. - \param item The element the created <code>circular_buffer</code> will be filled with. - \param alloc The allocator. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Complexity - Linear (in the <code>n</code>). - */ - circular_buffer(capacity_type buffer_capacity, size_type n, param_value_type item, - const allocator_type& alloc = allocator_type()) - : base(boost::empty_init_t(), alloc), m_size(n) { - BOOST_CB_ASSERT(buffer_capacity >= size()); // check for capacity lower than size - initialize_buffer(buffer_capacity, item); - m_first = m_buff; - m_last = buffer_capacity == n ? m_buff : m_buff + n; - } - - //! The copy constructor. - /*! - Creates a copy of the specified <code>circular_buffer</code>. - \post <code>*this == cb</code> - \param cb The <code>circular_buffer</code> to be copied. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Complexity - Linear (in the size of <code>cb</code>). - */ - circular_buffer(const circular_buffer<T, Alloc>& cb) - : -#if BOOST_CB_ENABLE_DEBUG - debug_iterator_registry(), -#endif - base(boost::empty_init_t(), cb.get_allocator()), - m_size(cb.size()) { - initialize_buffer(cb.capacity()); - m_first = m_buff; - BOOST_TRY { - m_last = cb_details::uninitialized_copy(cb.begin(), cb.end(), m_buff, alloc()); - } BOOST_CATCH(...) { - deallocate(m_buff, cb.capacity()); - BOOST_RETHROW - } - BOOST_CATCH_END - if (m_last == m_end) - m_last = m_buff; - } - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - //! The move constructor. - /*! \brief Move constructs a <code>circular_buffer</code> from <code>cb</code>, leaving <code>cb</code> empty. - \pre C++ compiler with rvalue references support. - \post <code>cb.empty()</code> - \param cb <code>circular_buffer</code> to 'steal' value from. - \throws Nothing. - \par Constant. - */ - circular_buffer(circular_buffer<T, Alloc>&& cb) BOOST_NOEXCEPT - : base(boost::empty_init_t(), cb.get_allocator()), m_buff(0), m_end(0), m_first(0), m_last(0), m_size(0) { - cb.swap(*this); - } -#endif // BOOST_NO_CXX11_RVALUE_REFERENCES - - //! Create a full <code>circular_buffer</code> filled with a copy of the range. - /*! - \pre Valid range <code>[first, last)</code>.<br> - <code>first</code> and <code>last</code> have to meet the requirements of - <a href="https://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>. - \post <code>capacity() == std::distance(first, last) \&\& full() \&\& (*this)[0]== *first \&\& - (*this)[1] == *(first + 1) \&\& ... \&\& (*this)[std::distance(first, last) - 1] == *(last - 1)</code> - \param first The beginning of the range to be copied. - \param last The end of the range to be copied. - \param alloc The allocator. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Complexity - Linear (in the <code>std::distance(first, last)</code>). - */ - template <class InputIterator> - circular_buffer(InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type()) - : base(boost::empty_init_t(), alloc) { - initialize(first, last, is_integral<InputIterator>()); - } - - //! Create a <code>circular_buffer</code> with the specified capacity and filled with a copy of the range. - /*! - \pre Valid range <code>[first, last)</code>.<br> - <code>first</code> and <code>last</code> have to meet the requirements of - <a href="https://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>. - \post <code>capacity() == buffer_capacity \&\& size() \<= std::distance(first, last) \&\& - (*this)[0]== *(last - buffer_capacity) \&\& (*this)[1] == *(last - buffer_capacity + 1) \&\& ... \&\& - (*this)[buffer_capacity - 1] == *(last - 1)</code><br><br> - If the number of items to be copied from the range <code>[first, last)</code> is greater than the - specified <code>buffer_capacity</code> then only elements from the range - <code>[last - buffer_capacity, last)</code> will be copied. - \param buffer_capacity The capacity of the created <code>circular_buffer</code>. - \param first The beginning of the range to be copied. - \param last The end of the range to be copied. - \param alloc The allocator. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Complexity - Linear (in <code>std::distance(first, last)</code>; in - <code>min[capacity, std::distance(first, last)]</code> if the <code>InputIterator</code> is a - <a href="https://www.boost.org/sgi/stl/RandomAccessIterator.html">RandomAccessIterator</a>). - */ - template <class InputIterator> - circular_buffer(capacity_type buffer_capacity, InputIterator first, InputIterator last, - const allocator_type& alloc = allocator_type()) - : base(boost::empty_init_t(), alloc) { - initialize(buffer_capacity, first, last, is_integral<InputIterator>()); - } - - //! The destructor. - /*! - Destroys the <code>circular_buffer</code>. - \throws Nothing. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer</code> (including iterators equal to - <code>end()</code>). - \par Complexity - Constant (in the size of the <code>circular_buffer</code>) for scalar types; linear for other types. - \sa <code>clear()</code> - */ - ~circular_buffer() BOOST_NOEXCEPT { - destroy(); -#if BOOST_CB_ENABLE_DEBUG - invalidate_all_iterators(); -#endif - } - -public: -// Assign methods - - //! The assign operator. - /*! - Makes this <code>circular_buffer</code> to become a copy of the specified <code>circular_buffer</code>. - \post <code>*this == cb</code> - \param cb The <code>circular_buffer</code> to be copied. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Exception Safety - Strong. - \par Iterator Invalidation - Invalidates all iterators pointing to this <code>circular_buffer</code> (except iterators equal to - <code>end()</code>). - \par Complexity - Linear (in the size of <code>cb</code>). - \sa <code>\link assign(size_type, param_value_type) assign(size_type, const_reference)\endlink</code>, - <code>\link assign(capacity_type, size_type, param_value_type) - assign(capacity_type, size_type, const_reference)\endlink</code>, - <code>assign(InputIterator, InputIterator)</code>, - <code>assign(capacity_type, InputIterator, InputIterator)</code> - */ - circular_buffer<T, Alloc>& operator = (const circular_buffer<T, Alloc>& cb) { - if (this == &cb) - return *this; - pointer buff = allocate(cb.capacity()); - BOOST_TRY { - reset(buff, cb_details::uninitialized_copy(cb.begin(), cb.end(), buff, alloc()), cb.capacity()); - } BOOST_CATCH(...) { - deallocate(buff, cb.capacity()); - BOOST_RETHROW - } - BOOST_CATCH_END - return *this; - } - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - /*! \brief Move assigns content of <code>cb</code> to <code>*this</code>, leaving <code>cb</code> empty. - \pre C++ compiler with rvalue references support. - \post <code>cb.empty()</code> - \param cb <code>circular_buffer</code> to 'steal' value from. - \throws Nothing. - \par Complexity - Constant. - */ - circular_buffer<T, Alloc>& operator = (circular_buffer<T, Alloc>&& cb) BOOST_NOEXCEPT { - cb.swap(*this); // now `this` holds `cb` - circular_buffer<T, Alloc>(get_allocator()) // temporary that holds initial `cb` allocator - .swap(cb); // makes `cb` empty - return *this; - } -#endif // BOOST_NO_CXX11_RVALUE_REFERENCES - - //! Assign <code>n</code> items into the <code>circular_buffer</code>. - /*! - The content of the <code>circular_buffer</code> will be removed and replaced with <code>n</code> copies of the - <code>item</code>. - \post <code>capacity() == n \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item \&\& ... \&\& - (*this) [n - 1] == item</code> - \param n The number of elements the <code>circular_buffer</code> will be filled with. - \param item The element the <code>circular_buffer</code> will be filled with. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to - <code>end()</code>). - \par Complexity - Linear (in the <code>n</code>). - \sa <code>\link operator=(const circular_buffer&) operator=\endlink</code>, - <code>\link assign(capacity_type, size_type, param_value_type) - assign(capacity_type, size_type, const_reference)\endlink</code>, - <code>assign(InputIterator, InputIterator)</code>, - <code>assign(capacity_type, InputIterator, InputIterator)</code> - */ - void assign(size_type n, param_value_type item) { - assign_n(n, n, cb_details::assign_n<param_value_type, allocator_type>(n, item, alloc())); - } - - //! Assign <code>n</code> items into the <code>circular_buffer</code> specifying the capacity. - /*! - The capacity of the <code>circular_buffer</code> will be set to the specified value and the content of the - <code>circular_buffer</code> will be removed and replaced with <code>n</code> copies of the <code>item</code>. - \pre <code>capacity >= n</code> - \post <code>capacity() == buffer_capacity \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item - \&\& ... \&\& (*this) [n - 1] == item </code> - \param buffer_capacity The new capacity. - \param n The number of elements the <code>circular_buffer</code> will be filled with. - \param item The element the <code>circular_buffer</code> will be filled with. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to - <code>end()</code>). - \par Complexity - Linear (in the <code>n</code>). - \sa <code>\link operator=(const circular_buffer&) operator=\endlink</code>, - <code>\link assign(size_type, param_value_type) assign(size_type, const_reference)\endlink</code>, - <code>assign(InputIterator, InputIterator)</code>, - <code>assign(capacity_type, InputIterator, InputIterator)</code> - */ - void assign(capacity_type buffer_capacity, size_type n, param_value_type item) { - BOOST_CB_ASSERT(buffer_capacity >= n); // check for new capacity lower than n - assign_n(buffer_capacity, n, cb_details::assign_n<param_value_type, allocator_type>(n, item, alloc())); - } - - //! Assign a copy of the range into the <code>circular_buffer</code>. - /*! - The content of the <code>circular_buffer</code> will be removed and replaced with copies of elements from the - specified range. - \pre Valid range <code>[first, last)</code>.<br> - <code>first</code> and <code>last</code> have to meet the requirements of - <a href="https://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>. - \post <code>capacity() == std::distance(first, last) \&\& size() == std::distance(first, last) \&\& - (*this)[0]== *first \&\& (*this)[1] == *(first + 1) \&\& ... \&\& (*this)[std::distance(first, last) - 1] - == *(last - 1)</code> - \param first The beginning of the range to be copied. - \param last The end of the range to be copied. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to - <code>end()</code>). - \par Complexity - Linear (in the <code>std::distance(first, last)</code>). - \sa <code>\link operator=(const circular_buffer&) operator=\endlink</code>, - <code>\link assign(size_type, param_value_type) assign(size_type, const_reference)\endlink</code>, - <code>\link assign(capacity_type, size_type, param_value_type) - assign(capacity_type, size_type, const_reference)\endlink</code>, - <code>assign(capacity_type, InputIterator, InputIterator)</code> - */ - template <class InputIterator> - void assign(InputIterator first, InputIterator last) { - assign(first, last, is_integral<InputIterator>()); - } - - //! Assign a copy of the range into the <code>circular_buffer</code> specifying the capacity. - /*! - The capacity of the <code>circular_buffer</code> will be set to the specified value and the content of the - <code>circular_buffer</code> will be removed and replaced with copies of elements from the specified range. - \pre Valid range <code>[first, last)</code>.<br> - <code>first</code> and <code>last</code> have to meet the requirements of - <a href="https://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>. - \post <code>capacity() == buffer_capacity \&\& size() \<= std::distance(first, last) \&\& - (*this)[0]== *(last - buffer_capacity) \&\& (*this)[1] == *(last - buffer_capacity + 1) \&\& ... \&\& - (*this)[buffer_capacity - 1] == *(last - 1)</code><br><br> - If the number of items to be copied from the range <code>[first, last)</code> is greater than the - specified <code>buffer_capacity</code> then only elements from the range - <code>[last - buffer_capacity, last)</code> will be copied. - \param buffer_capacity The new capacity. - \param first The beginning of the range to be copied. - \param last The end of the range to be copied. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to - <code>end()</code>). - \par Complexity - Linear (in <code>std::distance(first, last)</code>; in - <code>min[capacity, std::distance(first, last)]</code> if the <code>InputIterator</code> is a - <a href="https://www.boost.org/sgi/stl/RandomAccessIterator.html">RandomAccessIterator</a>). - \sa <code>\link operator=(const circular_buffer&) operator=\endlink</code>, - <code>\link assign(size_type, param_value_type) assign(size_type, const_reference)\endlink</code>, - <code>\link assign(capacity_type, size_type, param_value_type) - assign(capacity_type, size_type, const_reference)\endlink</code>, - <code>assign(InputIterator, InputIterator)</code> - */ - template <class InputIterator> - void assign(capacity_type buffer_capacity, InputIterator first, InputIterator last) { - assign(buffer_capacity, first, last, is_integral<InputIterator>()); - } - - //! Swap the contents of two <code>circular_buffer</code>s. - /*! - \post <code>this</code> contains elements of <code>cb</code> and vice versa; the capacity of <code>this</code> - equals to the capacity of <code>cb</code> and vice versa. - \param cb The <code>circular_buffer</code> whose content will be swapped. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Invalidates all iterators of both <code>circular_buffer</code>s. (On the other hand the iterators still - point to the same elements but within another container. If you want to rely on this feature you have to - turn the <a href="#debug">Debug Support</a> off otherwise an assertion will report an error if such - invalidated iterator is used.) - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>swap(circular_buffer<T, Alloc>&, circular_buffer<T, Alloc>&)</code> - */ - void swap(circular_buffer<T, Alloc>& cb) BOOST_NOEXCEPT { - swap_allocator(cb, is_stateless<allocator_type>()); - adl_move_swap(m_buff, cb.m_buff); - adl_move_swap(m_end, cb.m_end); - adl_move_swap(m_first, cb.m_first); - adl_move_swap(m_last, cb.m_last); - adl_move_swap(m_size, cb.m_size); -#if BOOST_CB_ENABLE_DEBUG - invalidate_all_iterators(); - cb.invalidate_all_iterators(); -#endif - } - -// push and pop -private: - /*! INTERNAL ONLY */ - template <class ValT> - void push_back_impl(ValT item) { - if (full()) { - if (empty()) - return; - replace(m_last, static_cast<ValT>(item)); - increment(m_last); - m_first = m_last; - } else { - boost::allocator_construct(alloc(), boost::to_address(m_last), static_cast<ValT>(item)); - increment(m_last); - ++m_size; - } - } - - /*! INTERNAL ONLY */ - template <class ValT> - void push_front_impl(ValT item) { - BOOST_TRY { - if (full()) { - if (empty()) - return; - decrement(m_first); - replace(m_first, static_cast<ValT>(item)); - m_last = m_first; - } else { - decrement(m_first); - boost::allocator_construct(alloc(), boost::to_address(m_first), static_cast<ValT>(item)); - ++m_size; - } - } BOOST_CATCH(...) { - increment(m_first); - BOOST_RETHROW - } - BOOST_CATCH_END - } - -public: - //! Insert a new element at the end of the <code>circular_buffer</code>. - /*! - \post if <code>capacity() > 0</code> then <code>back() == item</code><br> - If the <code>circular_buffer</code> is full, the first element will be removed. If the capacity is - <code>0</code>, nothing will be inserted. - \param item The element to be inserted. - \throws Whatever <code>T::T(const T&)</code> throws. - Whatever <code>T::operator = (const T&)</code> throws. - \par Exception Safety - Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. - \par Iterator Invalidation - Does not invalidate any iterators with the exception of iterators pointing to the overwritten element. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>\link push_front() push_front(const_reference)\endlink</code>, - <code>pop_back()</code>, <code>pop_front()</code> - */ - void push_back(param_value_type item) { - push_back_impl<param_value_type>(item); - } - - //! Insert a new element at the end of the <code>circular_buffer</code> using rvalue references or rvalues references emulation. - /*! - \post if <code>capacity() > 0</code> then <code>back() == item</code><br> - If the <code>circular_buffer</code> is full, the first element will be removed. If the capacity is - <code>0</code>, nothing will be inserted. - \param item The element to be inserted. - \throws Whatever <code>T::T(T&&)</code> throws. - Whatever <code>T::operator = (T&&)</code> throws. - \par Exception Safety - Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. - \par Iterator Invalidation - Does not invalidate any iterators with the exception of iterators pointing to the overwritten element. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>\link push_front() push_front(const_reference)\endlink</code>, - <code>pop_back()</code>, <code>pop_front()</code> - */ - void push_back(rvalue_type item) { - push_back_impl<rvalue_type>(boost::move(item)); - } - - //! Insert a new default-constructed element at the end of the <code>circular_buffer</code>. - /*! - \post if <code>capacity() > 0</code> then <code>back() == item</code><br> - If the <code>circular_buffer</code> is full, the first element will be removed. If the capacity is - <code>0</code>, nothing will be inserted. - \throws Whatever <code>T::T()</code> throws. - Whatever <code>T::T(T&&)</code> throws. - Whatever <code>T::operator = (T&&)</code> throws. - \par Exception Safety - Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. - \par Iterator Invalidation - Does not invalidate any iterators with the exception of iterators pointing to the overwritten element. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>\link push_front() push_front(const_reference)\endlink</code>, - <code>pop_back()</code>, <code>pop_front()</code> - */ - void push_back() { - value_type temp; - push_back(boost::move(temp)); - } - - //! Insert a new element at the beginning of the <code>circular_buffer</code>. - /*! - \post if <code>capacity() > 0</code> then <code>front() == item</code><br> - If the <code>circular_buffer</code> is full, the last element will be removed. If the capacity is - <code>0</code>, nothing will be inserted. - \param item The element to be inserted. - \throws Whatever <code>T::T(const T&)</code> throws. - Whatever <code>T::operator = (const T&)</code> throws. - \par Exception Safety - Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. - \par Iterator Invalidation - Does not invalidate any iterators with the exception of iterators pointing to the overwritten element. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>\link push_back() push_back(const_reference)\endlink</code>, - <code>pop_back()</code>, <code>pop_front()</code> - */ - void push_front(param_value_type item) { - push_front_impl<param_value_type>(item); - } - - //! Insert a new element at the beginning of the <code>circular_buffer</code> using rvalue references or rvalues references emulation. - /*! - \post if <code>capacity() > 0</code> then <code>front() == item</code><br> - If the <code>circular_buffer</code> is full, the last element will be removed. If the capacity is - <code>0</code>, nothing will be inserted. - \param item The element to be inserted. - \throws Whatever <code>T::T(T&&)</code> throws. - Whatever <code>T::operator = (T&&)</code> throws. - \par Exception Safety - Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. - \par Iterator Invalidation - Does not invalidate any iterators with the exception of iterators pointing to the overwritten element. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>\link push_back() push_back(const_reference)\endlink</code>, - <code>pop_back()</code>, <code>pop_front()</code> - */ - void push_front(rvalue_type item) { - push_front_impl<rvalue_type>(boost::move(item)); - } - - //! Insert a new default-constructed element at the beginning of the <code>circular_buffer</code>. - /*! - \post if <code>capacity() > 0</code> then <code>front() == item</code><br> - If the <code>circular_buffer</code> is full, the last element will be removed. If the capacity is - <code>0</code>, nothing will be inserted. - \throws Whatever <code>T::T()</code> throws. - Whatever <code>T::T(T&&)</code> throws. - Whatever <code>T::operator = (T&&)</code> throws. - \par Exception Safety - Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. - \par Iterator Invalidation - Does not invalidate any iterators with the exception of iterators pointing to the overwritten element. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>\link push_back() push_back(const_reference)\endlink</code>, - <code>pop_back()</code>, <code>pop_front()</code> - */ - void push_front() { - value_type temp; - push_front(boost::move(temp)); - } - - //! Remove the last element from the <code>circular_buffer</code>. - /*! - \pre <code>!empty()</code> - \post The last element is removed from the <code>circular_buffer</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Invalidates only iterators pointing to the removed element. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>pop_front()</code>, <code>\link push_back() push_back(const_reference)\endlink</code>, - <code>\link push_front() push_front(const_reference)\endlink</code> - */ - void pop_back() { - BOOST_CB_ASSERT(!empty()); // check for empty buffer (back element not available) - decrement(m_last); - destroy_item(m_last); - --m_size; - } - - //! Remove the first element from the <code>circular_buffer</code>. - /*! - \pre <code>!empty()</code> - \post The first element is removed from the <code>circular_buffer</code>. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Invalidates only iterators pointing to the removed element. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>). - \sa <code>pop_back()</code>, <code>\link push_back() push_back(const_reference)\endlink</code>, - <code>\link push_front() push_front(const_reference)\endlink</code> - */ - void pop_front() { - BOOST_CB_ASSERT(!empty()); // check for empty buffer (front element not available) - destroy_item(m_first); - increment(m_first); - --m_size; - } -private: - /*! INTERNAL ONLY */ - template <class ValT> - iterator insert_impl(iterator pos, ValT item) { - BOOST_CB_ASSERT(pos.is_valid(this)); // check for uninitialized or invalidated iterator - iterator b = begin(); - if (full() && pos == b) - return b; - return insert_item<ValT>(pos, static_cast<ValT>(item)); - } - -public: -// Insert - - //! Insert an element at the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> or its end. - \post The <code>item</code> will be inserted at the position <code>pos</code>.<br> - If the <code>circular_buffer</code> is full, the first element will be overwritten. If the - <code>circular_buffer</code> is full and the <code>pos</code> points to <code>begin()</code>, then the - <code>item</code> will not be inserted. If the capacity is <code>0</code>, nothing will be inserted. - \param pos An iterator specifying the position where the <code>item</code> will be inserted. - \param item The element to be inserted. - \return Iterator to the inserted element or <code>begin()</code> if the <code>item</code> is not inserted. (See - the <i>Effect</i>.) - \throws Whatever <code>T::T(const T&)</code> throws. - Whatever <code>T::operator = (const T&)</code> throws. - <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&)</a>. - - \par Exception Safety - Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. - \par Iterator Invalidation - Invalidates iterators pointing to the elements at the insertion point (including <code>pos</code>) and - iterators behind the insertion point (towards the end; except iterators equal to <code>end()</code>). It - also invalidates iterators pointing to the overwritten element. - \par Complexity - Linear (in <code>std::distance(pos, end())</code>). - \sa <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code>, - <code>\link rinsert(iterator, param_value_type) rinsert(iterator, value_type)\endlink</code>, - <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code> - */ - iterator insert(iterator pos, param_value_type item) { - return insert_impl<param_value_type>(pos, item); - } - - //! Insert an element at the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> or its end. - \post The <code>item</code> will be inserted at the position <code>pos</code>.<br> - If the <code>circular_buffer</code> is full, the first element will be overwritten. If the - <code>circular_buffer</code> is full and the <code>pos</code> points to <code>begin()</code>, then the - <code>item</code> will not be inserted. If the capacity is <code>0</code>, nothing will be inserted. - \param pos An iterator specifying the position where the <code>item</code> will be inserted. - \param item The element to be inserted. - \return Iterator to the inserted element or <code>begin()</code> if the <code>item</code> is not inserted. (See - the <i>Effect</i>.) - \throws Whatever <code>T::T(T&&)</code> throws. - Whatever <code>T::operator = (T&&)</code> throws. - <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&)</a>. - \par Exception Safety - Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. - \par Iterator Invalidation - Invalidates iterators pointing to the elements at the insertion point (including <code>pos</code>) and - iterators behind the insertion point (towards the end; except iterators equal to <code>end()</code>). It - also invalidates iterators pointing to the overwritten element. - \par Complexity - Linear (in <code>std::distance(pos, end())</code>). - \sa <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code>, - <code>\link rinsert(iterator, param_value_type) rinsert(iterator, value_type)\endlink</code>, - <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code> - */ - iterator insert(iterator pos, rvalue_type item) { - return insert_impl<rvalue_type>(pos, boost::move(item)); - } - - //! Insert a default-constructed element at the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> or its end. - \post The <code>item</code> will be inserted at the position <code>pos</code>.<br> - If the <code>circular_buffer</code> is full, the first element will be overwritten. If the - <code>circular_buffer</code> is full and the <code>pos</code> points to <code>begin()</code>, then the - <code>item</code> will not be inserted. If the capacity is <code>0</code>, nothing will be inserted. - \param pos An iterator specifying the position where the <code>item</code> will be inserted. - \return Iterator to the inserted element or <code>begin()</code> if the <code>item</code> is not inserted. (See - the <i>Effect</i>.) - \throws Whatever <code>T::T()</code> throws. - Whatever <code>T::T(T&&)</code> throws. - Whatever <code>T::operator = (T&&)</code> throws. - <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&)</a>. - \par Exception Safety - Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. - \par Iterator Invalidation - Invalidates iterators pointing to the elements at the insertion point (including <code>pos</code>) and - iterators behind the insertion point (towards the end; except iterators equal to <code>end()</code>). It - also invalidates iterators pointing to the overwritten element. - \par Complexity - Linear (in <code>std::distance(pos, end())</code>). - \sa <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code>, - <code>\link rinsert(iterator, param_value_type) rinsert(iterator, value_type)\endlink</code>, - <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code> - */ - iterator insert(iterator pos) { - value_type temp; - return insert(pos, boost::move(temp)); - } - - //! Insert <code>n</code> copies of the <code>item</code> at the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> or its end. - \post The number of <code>min[n, (pos - begin()) + reserve()]</code> elements will be inserted at the position - <code>pos</code>.<br>The number of <code>min[pos - begin(), max[0, n - reserve()]]</code> elements will - be overwritten at the beginning of the <code>circular_buffer</code>.<br>(See <i>Example</i> for the - explanation.) - \param pos An iterator specifying the position where the <code>item</code>s will be inserted. - \param n The number of <code>item</code>s the to be inserted. - \param item The element whose copies will be inserted. - \throws Whatever <code>T::T(const T&)</code> throws. - Whatever <code>T::operator = (const T&)</code> throws. - <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&)</a>. - \par Exception Safety - Basic; no-throw if the operations in the <i>Throws</i> section do not throw anything. - \par Iterator Invalidation - Invalidates iterators pointing to the elements at the insertion point (including <code>pos</code>) and - iterators behind the insertion point (towards the end; except iterators equal to <code>end()</code>). It - also invalidates iterators pointing to the overwritten elements. - \par Complexity - Linear (in <code>min[capacity(), std::distance(pos, end()) + n]</code>). - \par Example - Consider a <code>circular_buffer</code> with the capacity of 6 and the size of 4. Its internal buffer may - look like the one below.<br><br> - <code>|1|2|3|4| | |</code><br> - <code>p ___^</code><br><br>After inserting 5 elements at the position <code>p</code>:<br><br> - <code>insert(p, (size_t)5, 0);</code><br><br>actually only 4 elements get inserted and elements - <code>1</code> and <code>2</code> are overwritten. This is due to the fact the insert operation preserves - the capacity. After insertion the internal buffer looks like this:<br><br><code>|0|0|0|0|3|4|</code><br> - <br>For comparison if the capacity would not be preserved the internal buffer would then result in - <code>|1|2|0|0|0|0|0|3|4|</code>. - \sa <code>\link insert(iterator, param_value_type) insert(iterator, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code>, - <code>\link rinsert(iterator, param_value_type) rinsert(iterator, value_type)\endlink</code>, - <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code> - */ - void insert(iterator pos, size_type n, param_value_type item) { - BOOST_CB_ASSERT(pos.is_valid(this)); // check for uninitialized or invalidated iterator - if (n == 0) - return; - size_type copy = capacity() - (end() - pos); - if (copy == 0) - return; - if (n > copy) - n = copy; - insert_n(pos, n, cb_details::item_wrapper<const_pointer, param_value_type>(item)); - } - - //! Insert the range <code>[first, last)</code> at the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> or its end.<br> - Valid range <code>[first, last)</code> where <code>first</code> and <code>last</code> meet the - requirements of an <a href="https://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>. - \post Elements from the range - <code>[first + max[0, distance(first, last) - (pos - begin()) - reserve()], last)</code> will be - inserted at the position <code>pos</code>.<br>The number of <code>min[pos - begin(), max[0, - distance(first, last) - reserve()]]</code> elements will be overwritten at the beginning of the - <code>circular_buffer</code>.<br>(See <i>Example</i> for the explanation.) - \param pos An iterator specifying the position where the range will be inserted. - \param first The beginning of the range to be inserted. - \param last The end of the range to be inserted. - \throws Whatever <code>T::T(const T&)</code> throws if the <code>InputIterator</code> is not a move iterator. - Whatever <code>T::operator = (const T&)</code> throws if the <code>InputIterator</code> is not a move iterator. - Whatever <code>T::T(T&&)</code> throws if the <code>InputIterator</code> is a move iterator. - Whatever <code>T::operator = (T&&)</code> throws if the <code>InputIterator</code> is a move iterator. - \par Exception Safety - Basic; no-throw if the operations in the <i>Throws</i> section do not throw anything. - \par Iterator Invalidation - Invalidates iterators pointing to the elements at the insertion point (including <code>pos</code>) and - iterators behind the insertion point (towards the end; except iterators equal to <code>end()</code>). It - also invalidates iterators pointing to the overwritten elements. - \par Complexity - Linear (in <code>[std::distance(pos, end()) + std::distance(first, last)]</code>; in - <code>min[capacity(), std::distance(pos, end()) + std::distance(first, last)]</code> if the - <code>InputIterator</code> is a - <a href="https://www.boost.org/sgi/stl/RandomAccessIterator.html">RandomAccessIterator</a>). - \par Example - Consider a <code>circular_buffer</code> with the capacity of 6 and the size of 4. Its internal buffer may - look like the one below.<br><br> - <code>|1|2|3|4| | |</code><br> - <code>p ___^</code><br><br>After inserting a range of elements at the position <code>p</code>:<br><br> - <code>int array[] = { 5, 6, 7, 8, 9 };</code><br><code>insert(p, array, array + 5);</code><br><br> - actually only elements <code>6</code>, <code>7</code>, <code>8</code> and <code>9</code> from the - specified range get inserted and elements <code>1</code> and <code>2</code> are overwritten. This is due - to the fact the insert operation preserves the capacity. After insertion the internal buffer looks like - this:<br><br><code>|6|7|8|9|3|4|</code><br><br>For comparison if the capacity would not be preserved the - internal buffer would then result in <code>|1|2|5|6|7|8|9|3|4|</code>. - \sa <code>\link insert(iterator, param_value_type) insert(iterator, value_type)\endlink</code>, - <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, <code>\link rinsert(iterator, param_value_type) - rinsert(iterator, value_type)\endlink</code>, <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code> - */ - template <class InputIterator> - void insert(iterator pos, InputIterator first, InputIterator last) { - BOOST_CB_ASSERT(pos.is_valid(this)); // check for uninitialized or invalidated iterator - insert(pos, first, last, is_integral<InputIterator>()); - } - -private: - /*! INTERNAL ONLY */ - template <class ValT> - iterator rinsert_impl(iterator pos, ValT item) { - BOOST_CB_ASSERT(pos.is_valid(this)); // check for uninitialized or invalidated iterator - if (full() && pos.m_it == 0) - return end(); - if (pos == begin()) { - BOOST_TRY { - decrement(m_first); - construct_or_replace(!full(), m_first, static_cast<ValT>(item)); - } BOOST_CATCH(...) { - increment(m_first); - BOOST_RETHROW - } - BOOST_CATCH_END - pos.m_it = m_first; - } else { - pointer src = m_first; - pointer dest = m_first; - decrement(dest); - pos.m_it = map_pointer(pos.m_it); - bool construct = !full(); - BOOST_TRY { - while (src != pos.m_it) { - construct_or_replace(construct, dest, boost::move_if_noexcept(*src)); - increment(src); - increment(dest); - construct = false; - } - decrement(pos.m_it); - replace(pos.m_it, static_cast<ValT>(item)); - } BOOST_CATCH(...) { - if (!construct && !full()) { - decrement(m_first); - ++m_size; - } - BOOST_RETHROW - } - BOOST_CATCH_END - decrement(m_first); - } - if (full()) - m_last = m_first; - else - ++m_size; - return iterator(this, pos.m_it); - } - -public: - - //! Insert an element before the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> or its end. - \post The <code>item</code> will be inserted before the position <code>pos</code>.<br> - If the <code>circular_buffer</code> is full, the last element will be overwritten. If the - <code>circular_buffer</code> is full and the <code>pos</code> points to <code>end()</code>, then the - <code>item</code> will not be inserted. If the capacity is <code>0</code>, nothing will be inserted. - \param pos An iterator specifying the position before which the <code>item</code> will be inserted. - \param item The element to be inserted. - \return Iterator to the inserted element or <code>end()</code> if the <code>item</code> is not inserted. (See - the <i>Effect</i>.) - \throws Whatever <code>T::T(const T&)</code> throws. - Whatever <code>T::operator = (const T&)</code> throws. - <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&)</a>. - \par Exception Safety - Basic; no-throw if the operations in the <i>Throws</i> section do not throw anything. - \par Iterator Invalidation - Invalidates iterators pointing to the elements before the insertion point (towards the beginning and - excluding <code>pos</code>). It also invalidates iterators pointing to the overwritten element. - \par Complexity - Linear (in <code>std::distance(begin(), pos)</code>). - \sa <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code>, - <code>\link insert(iterator, param_value_type) insert(iterator, value_type)\endlink</code>, - <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code> - */ - iterator rinsert(iterator pos, param_value_type item) { - return rinsert_impl<param_value_type>(pos, item); - } - - //! Insert an element before the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> or its end. - \post The <code>item</code> will be inserted before the position <code>pos</code>.<br> - If the <code>circular_buffer</code> is full, the last element will be overwritten. If the - <code>circular_buffer</code> is full and the <code>pos</code> points to <code>end()</code>, then the - <code>item</code> will not be inserted. If the capacity is <code>0</code>, nothing will be inserted. - \param pos An iterator specifying the position before which the <code>item</code> will be inserted. - \param item The element to be inserted. - \return Iterator to the inserted element or <code>end()</code> if the <code>item</code> is not inserted. (See - the <i>Effect</i>.) - \throws Whatever <code>T::T(T&&)</code> throws. - Whatever <code>T::operator = (T&&)</code> throws. - <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&)</a>. - \par Exception Safety - Basic; no-throw if the operations in the <i>Throws</i> section do not throw anything. - \par Iterator Invalidation - Invalidates iterators pointing to the elements before the insertion point (towards the beginning and - excluding <code>pos</code>). It also invalidates iterators pointing to the overwritten element. - \par Complexity - Linear (in <code>std::distance(begin(), pos)</code>). - \sa <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code>, - <code>\link insert(iterator, param_value_type) insert(iterator, value_type)\endlink</code>, - <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code> - */ - iterator rinsert(iterator pos, rvalue_type item) { - return rinsert_impl<rvalue_type>(pos, boost::move(item)); - } - - //! Insert an element before the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> or its end. - \post The <code>item</code> will be inserted before the position <code>pos</code>.<br> - If the <code>circular_buffer</code> is full, the last element will be overwritten. If the - <code>circular_buffer</code> is full and the <code>pos</code> points to <code>end()</code>, then the - <code>item</code> will not be inserted. If the capacity is <code>0</code>, nothing will be inserted. - \param pos An iterator specifying the position before which the <code>item</code> will be inserted. - \return Iterator to the inserted element or <code>end()</code> if the <code>item</code> is not inserted. (See - the <i>Effect</i>.) - \throws Whatever <code>T::T()</code> throws. - Whatever <code>T::T(T&&)</code> throws. - Whatever <code>T::operator = (T&&)</code> throws. - <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&)</a>. - \par Exception Safety - Basic; no-throw if the operations in the <i>Throws</i> section do not throw anything. - \par Iterator Invalidation - Invalidates iterators pointing to the elements before the insertion point (towards the beginning and - excluding <code>pos</code>). It also invalidates iterators pointing to the overwritten element. - \par Complexity - Linear (in <code>std::distance(begin(), pos)</code>). - \sa <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code>, - <code>\link insert(iterator, param_value_type) insert(iterator, value_type)\endlink</code>, - <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code> - */ - iterator rinsert(iterator pos) { - value_type temp; - return rinsert(pos, boost::move(temp)); - } - - //! Insert <code>n</code> copies of the <code>item</code> before the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> or its end. - \post The number of <code>min[n, (end() - pos) + reserve()]</code> elements will be inserted before the - position <code>pos</code>.<br>The number of <code>min[end() - pos, max[0, n - reserve()]]</code> elements - will be overwritten at the end of the <code>circular_buffer</code>.<br>(See <i>Example</i> for the - explanation.) - \param pos An iterator specifying the position where the <code>item</code>s will be inserted. - \param n The number of <code>item</code>s the to be inserted. - \param item The element whose copies will be inserted. - \throws Whatever <code>T::T(const T&)</code> throws. - Whatever <code>T::operator = (const T&)</code> throws. - <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&)</a>. - \par Exception Safety - Basic; no-throw if the operations in the <i>Throws</i> section do not throw anything. - \par Iterator Invalidation - Invalidates iterators pointing to the elements before the insertion point (towards the beginning and - excluding <code>pos</code>). It also invalidates iterators pointing to the overwritten elements. - \par Complexity - Linear (in <code>min[capacity(), std::distance(begin(), pos) + n]</code>). - \par Example - Consider a <code>circular_buffer</code> with the capacity of 6 and the size of 4. Its internal buffer may - look like the one below.<br><br> - <code>|1|2|3|4| | |</code><br> - <code>p ___^</code><br><br>After inserting 5 elements before the position <code>p</code>:<br><br> - <code>rinsert(p, (size_t)5, 0);</code><br><br>actually only 4 elements get inserted and elements - <code>3</code> and <code>4</code> are overwritten. This is due to the fact the rinsert operation preserves - the capacity. After insertion the internal buffer looks like this:<br><br><code>|1|2|0|0|0|0|</code><br> - <br>For comparison if the capacity would not be preserved the internal buffer would then result in - <code>|1|2|0|0|0|0|0|3|4|</code>. - \sa <code>\link rinsert(iterator, param_value_type) rinsert(iterator, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code>, - <code>\link insert(iterator, param_value_type) insert(iterator, value_type)\endlink</code>, - <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code> - */ - void rinsert(iterator pos, size_type n, param_value_type item) { - BOOST_CB_ASSERT(pos.is_valid(this)); // check for uninitialized or invalidated iterator - rinsert_n(pos, n, cb_details::item_wrapper<const_pointer, param_value_type>(item)); - } - - //! Insert the range <code>[first, last)</code> before the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> or its end.<br> - Valid range <code>[first, last)</code> where <code>first</code> and <code>last</code> meet the - requirements of an <a href="https://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>. - \post Elements from the range - <code>[first, last - max[0, distance(first, last) - (end() - pos) - reserve()])</code> will be inserted - before the position <code>pos</code>.<br>The number of <code>min[end() - pos, max[0, - distance(first, last) - reserve()]]</code> elements will be overwritten at the end of the - <code>circular_buffer</code>.<br>(See <i>Example</i> for the explanation.) - \param pos An iterator specifying the position where the range will be inserted. - \param first The beginning of the range to be inserted. - \param last The end of the range to be inserted. - \throws Whatever <code>T::T(const T&)</code> throws if the <code>InputIterator</code> is not a move iterator. - Whatever <code>T::operator = (const T&)</code> throws if the <code>InputIterator</code> is not a move iterator. - Whatever <code>T::T(T&&)</code> throws if the <code>InputIterator</code> is a move iterator. - Whatever <code>T::operator = (T&&)</code> throws if the <code>InputIterator</code> is a move iterator. - \par Exception Safety - Basic; no-throw if the operations in the <i>Throws</i> section do not throw anything. - \par Iterator Invalidation - Invalidates iterators pointing to the elements before the insertion point (towards the beginning and - excluding <code>pos</code>). It also invalidates iterators pointing to the overwritten elements. - \par Complexity - Linear (in <code>[std::distance(begin(), pos) + std::distance(first, last)]</code>; in - <code>min[capacity(), std::distance(begin(), pos) + std::distance(first, last)]</code> if the - <code>InputIterator</code> is a - <a href="https://www.boost.org/sgi/stl/RandomAccessIterator.html">RandomAccessIterator</a>). - \par Example - Consider a <code>circular_buffer</code> with the capacity of 6 and the size of 4. Its internal buffer may - look like the one below.<br><br> - <code>|1|2|3|4| | |</code><br> - <code>p ___^</code><br><br>After inserting a range of elements before the position <code>p</code>:<br><br> - <code>int array[] = { 5, 6, 7, 8, 9 };</code><br><code>insert(p, array, array + 5);</code><br><br> - actually only elements <code>5</code>, <code>6</code>, <code>7</code> and <code>8</code> from the - specified range get inserted and elements <code>3</code> and <code>4</code> are overwritten. This is due - to the fact the rinsert operation preserves the capacity. After insertion the internal buffer looks like - this:<br><br><code>|1|2|5|6|7|8|</code><br><br>For comparison if the capacity would not be preserved the - internal buffer would then result in <code>|1|2|5|6|7|8|9|3|4|</code>. - \sa <code>\link rinsert(iterator, param_value_type) rinsert(iterator, value_type)\endlink</code>, - <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, <code>\link insert(iterator, param_value_type) - insert(iterator, value_type)\endlink</code>, <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code> - */ - template <class InputIterator> - void rinsert(iterator pos, InputIterator first, InputIterator last) { - BOOST_CB_ASSERT(pos.is_valid(this)); // check for uninitialized or invalidated iterator - rinsert(pos, first, last, is_integral<InputIterator>()); - } - -// Erase - - //! Remove an element at the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> (but not an - <code>end()</code>). - \post The element at the position <code>pos</code> is removed. - \param pos An iterator pointing at the element to be removed. - \return Iterator to the first element remaining beyond the removed element or <code>end()</code> if no such - element exists. - \throws <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&)</a>. - \par Exception Safety - Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. - \par Iterator Invalidation - Invalidates iterators pointing to the erased element and iterators pointing to the elements behind - the erased element (towards the end; except iterators equal to <code>end()</code>). - \par Complexity - Linear (in <code>std::distance(pos, end())</code>). - \sa <code>erase(iterator, iterator)</code>, <code>rerase(iterator)</code>, - <code>rerase(iterator, iterator)</code>, <code>erase_begin(size_type)</code>, - <code>erase_end(size_type)</code>, <code>clear()</code> - */ - iterator erase(iterator pos) { - BOOST_CB_ASSERT(pos.is_valid(this)); // check for uninitialized or invalidated iterator - BOOST_CB_ASSERT(pos.m_it != 0); // check for iterator pointing to end() - pointer next = pos.m_it; - increment(next); - for (pointer p = pos.m_it; next != m_last; p = next, increment(next)) - replace(p, boost::move_if_noexcept(*next)); - decrement(m_last); - destroy_item(m_last); - --m_size; -#if BOOST_CB_ENABLE_DEBUG - return m_last == pos.m_it ? end() : iterator(this, pos.m_it); -#else - return m_last == pos.m_it ? end() : pos; -#endif - } - - //! Erase the range <code>[first, last)</code>. - /*! - \pre Valid range <code>[first, last)</code>. - \post The elements from the range <code>[first, last)</code> are removed. (If <code>first == last</code> - nothing is removed.) - \param first The beginning of the range to be removed. - \param last The end of the range to be removed. - \return Iterator to the first element remaining beyond the removed elements or <code>end()</code> if no such - element exists. - \throws <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&)</a>. - \par Exception Safety - Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. - \par Iterator Invalidation - Invalidates iterators pointing to the erased elements and iterators pointing to the elements behind - the erased range (towards the end; except iterators equal to <code>end()</code>). - \par Complexity - Linear (in <code>std::distance(first, end())</code>). - \sa <code>erase(iterator)</code>, <code>rerase(iterator)</code>, <code>rerase(iterator, iterator)</code>, - <code>erase_begin(size_type)</code>, <code>erase_end(size_type)</code>, <code>clear()</code> - */ - iterator erase(iterator first, iterator last) { - BOOST_CB_ASSERT(first.is_valid(this)); // check for uninitialized or invalidated iterator - BOOST_CB_ASSERT(last.is_valid(this)); // check for uninitialized or invalidated iterator - BOOST_CB_ASSERT(first <= last); // check for wrong range - if (first == last) - return first; - pointer p = first.m_it; - while (last.m_it != 0) - replace((first++).m_it, boost::move_if_noexcept(*last++)); - do { - decrement(m_last); - destroy_item(m_last); - --m_size; - } while(m_last != first.m_it); - return m_last == p ? end() : iterator(this, p); - } - - //! Remove an element at the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> (but not an - <code>end()</code>). - \post The element at the position <code>pos</code> is removed. - \param pos An iterator pointing at the element to be removed. - \return Iterator to the first element remaining in front of the removed element or <code>begin()</code> if no - such element exists. - \throws <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&)</a>. - \par Exception Safety - Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. - \par Iterator Invalidation - Invalidates iterators pointing to the erased element and iterators pointing to the elements in front of - the erased element (towards the beginning). - \par Complexity - Linear (in <code>std::distance(begin(), pos)</code>). - \note This method is symmetric to the <code>erase(iterator)</code> method and is more effective than - <code>erase(iterator)</code> if the iterator <code>pos</code> is close to the beginning of the - <code>circular_buffer</code>. (See the <i>Complexity</i>.) - \sa <code>erase(iterator)</code>, <code>erase(iterator, iterator)</code>, - <code>rerase(iterator, iterator)</code>, <code>erase_begin(size_type)</code>, - <code>erase_end(size_type)</code>, <code>clear()</code> - */ - iterator rerase(iterator pos) { - BOOST_CB_ASSERT(pos.is_valid(this)); // check for uninitialized or invalidated iterator - BOOST_CB_ASSERT(pos.m_it != 0); // check for iterator pointing to end() - pointer prev = pos.m_it; - pointer p = prev; - for (decrement(prev); p != m_first; p = prev, decrement(prev)) - replace(p, boost::move_if_noexcept(*prev)); - destroy_item(m_first); - increment(m_first); - --m_size; -#if BOOST_CB_ENABLE_DEBUG - return p == pos.m_it ? begin() : iterator(this, pos.m_it); -#else - return p == pos.m_it ? begin() : pos; -#endif - } - - //! Erase the range <code>[first, last)</code>. - /*! - \pre Valid range <code>[first, last)</code>. - \post The elements from the range <code>[first, last)</code> are removed. (If <code>first == last</code> - nothing is removed.) - \param first The beginning of the range to be removed. - \param last The end of the range to be removed. - \return Iterator to the first element remaining in front of the removed elements or <code>begin()</code> if no - such element exists. - \throws <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&)</a>. - \par Exception Safety - Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. - \par Iterator Invalidation - Invalidates iterators pointing to the erased elements and iterators pointing to the elements in front of - the erased range (towards the beginning). - \par Complexity - Linear (in <code>std::distance(begin(), last)</code>). - \note This method is symmetric to the <code>erase(iterator, iterator)</code> method and is more effective than - <code>erase(iterator, iterator)</code> if <code>std::distance(begin(), first)</code> is lower that - <code>std::distance(last, end())</code>. - \sa <code>erase(iterator)</code>, <code>erase(iterator, iterator)</code>, <code>rerase(iterator)</code>, - <code>erase_begin(size_type)</code>, <code>erase_end(size_type)</code>, <code>clear()</code> - */ - iterator rerase(iterator first, iterator last) { - BOOST_CB_ASSERT(first.is_valid(this)); // check for uninitialized or invalidated iterator - BOOST_CB_ASSERT(last.is_valid(this)); // check for uninitialized or invalidated iterator - BOOST_CB_ASSERT(first <= last); // check for wrong range - if (first == last) - return first; - pointer p = map_pointer(last.m_it); - last.m_it = p; - while (first.m_it != m_first) { - decrement(first.m_it); - decrement(p); - replace(p, boost::move_if_noexcept(*first.m_it)); - } - do { - destroy_item(m_first); - increment(m_first); - --m_size; - } while(m_first != p); - if (m_first == last.m_it) - return begin(); - decrement(last.m_it); - return iterator(this, last.m_it); - } - - //! Remove first <code>n</code> elements (with constant complexity for scalar types). - /*! - \pre <code>n \<= size()</code> - \post The <code>n</code> elements at the beginning of the <code>circular_buffer</code> will be removed. - \param n The number of elements to be removed. - \throws <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&)</a>. - \par Exception Safety - Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. (I.e. no throw in - case of scalars.) - \par Iterator Invalidation - Invalidates iterators pointing to the first <code>n</code> erased elements. - \par Complexity - Constant (in <code>n</code>) for scalar types; linear for other types. - \note This method has been specially designed for types which do not require an explicit destructruction (e.g. - integer, float or a pointer). For these scalar types a call to a destructor is not required which makes - it possible to implement the "erase from beginning" operation with a constant complexity. For non-sacalar - types the complexity is linear (hence the explicit destruction is needed) and the implementation is - actually equivalent to - <code>\link circular_buffer::rerase(iterator, iterator) rerase(begin(), begin() + n)\endlink</code>. - \sa <code>erase(iterator)</code>, <code>erase(iterator, iterator)</code>, - <code>rerase(iterator)</code>, <code>rerase(iterator, iterator)</code>, - <code>erase_end(size_type)</code>, <code>clear()</code> - */ - void erase_begin(size_type n) { - BOOST_CB_ASSERT(n <= size()); // check for n greater than size -#if BOOST_CB_ENABLE_DEBUG - erase_begin(n, false_type()); -#else - erase_begin(n, is_scalar<value_type>()); -#endif - } - - //! Remove last <code>n</code> elements (with constant complexity for scalar types). - /*! - \pre <code>n \<= size()</code> - \post The <code>n</code> elements at the end of the <code>circular_buffer</code> will be removed. - \param n The number of elements to be removed. - \throws <a href="circular_buffer/implementation.html#circular_buffer.implementation.exceptions_of_move_if_noexcept_t">Exceptions of move_if_noexcept(T&)</a>. - \par Exception Safety - Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. (I.e. no throw in - case of scalars.) - \par Iterator Invalidation - Invalidates iterators pointing to the last <code>n</code> erased elements. - \par Complexity - Constant (in <code>n</code>) for scalar types; linear for other types. - \note This method has been specially designed for types which do not require an explicit destructruction (e.g. - integer, float or a pointer). For these scalar types a call to a destructor is not required which makes - it possible to implement the "erase from end" operation with a constant complexity. For non-sacalar - types the complexity is linear (hence the explicit destruction is needed) and the implementation is - actually equivalent to - <code>\link circular_buffer::erase(iterator, iterator) erase(end() - n, end())\endlink</code>. - \sa <code>erase(iterator)</code>, <code>erase(iterator, iterator)</code>, - <code>rerase(iterator)</code>, <code>rerase(iterator, iterator)</code>, - <code>erase_begin(size_type)</code>, <code>clear()</code> - */ - void erase_end(size_type n) { - BOOST_CB_ASSERT(n <= size()); // check for n greater than size -#if BOOST_CB_ENABLE_DEBUG - erase_end(n, false_type()); -#else - erase_end(n, is_scalar<value_type>()); -#endif - } - - //! Remove all stored elements from the <code>circular_buffer</code>. - /*! - \post <code>size() == 0</code> - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to - <code>end()</code>). - \par Complexity - Constant (in the size of the <code>circular_buffer</code>) for scalar types; linear for other types. - \sa <code>~circular_buffer()</code>, <code>erase(iterator)</code>, <code>erase(iterator, iterator)</code>, - <code>rerase(iterator)</code>, <code>rerase(iterator, iterator)</code>, - <code>erase_begin(size_type)</code>, <code>erase_end(size_type)</code> - */ - void clear() BOOST_NOEXCEPT { - destroy_content(); - m_size = 0; - } - -private: -// Helper methods - - /*! INTERNAL ONLY */ - void check_position(size_type index) const { - if (index >= size()) - throw_exception(std::out_of_range("circular_buffer")); - } - - /*! INTERNAL ONLY */ - template <class Pointer> - void increment(Pointer& p) const { - if (++p == m_end) - p = m_buff; - } - - /*! INTERNAL ONLY */ - template <class Pointer> - void decrement(Pointer& p) const { - if (p == m_buff) - p = m_end; - --p; - } - - /*! INTERNAL ONLY */ - template <class Pointer> - Pointer add(Pointer p, difference_type n) const { - return p + (n < (m_end - p) ? n : n - (m_end - m_buff)); - } - - /*! INTERNAL ONLY */ - template <class Pointer> - Pointer sub(Pointer p, difference_type n) const { - return p - (n > (p - m_buff) ? n - (m_end - m_buff) : n); - } - - /*! INTERNAL ONLY */ - pointer map_pointer(pointer p) const { return p == 0 ? m_last : p; } - - /*! INTERNAL ONLY */ - const Alloc& alloc() const { - return base::get(); - } - - /*! INTERNAL ONLY */ - Alloc& alloc() { - return base::get(); - } - - /*! INTERNAL ONLY */ - pointer allocate(size_type n) { - if (n > max_size()) - throw_exception(std::length_error("circular_buffer")); -#if BOOST_CB_ENABLE_DEBUG - pointer p = (n == 0) ? 0 : alloc().allocate(n); - cb_details::do_fill_uninitialized_memory(p, sizeof(value_type) * n); - return p; -#else - return (n == 0) ? 0 : alloc().allocate(n); -#endif - } - - /*! INTERNAL ONLY */ - void deallocate(pointer p, size_type n) { - if (p != 0) - alloc().deallocate(p, n); - } - - /*! INTERNAL ONLY */ - bool is_uninitialized(const_pointer p) const BOOST_NOEXCEPT { - return (m_first < m_last) - ? (p >= m_last || p < m_first) - : (p >= m_last && p < m_first); - } - - /*! INTERNAL ONLY */ - void replace(pointer pos, param_value_type item) { - *pos = item; -#if BOOST_CB_ENABLE_DEBUG - invalidate_iterators(iterator(this, pos)); -#endif - } - - /*! INTERNAL ONLY */ - void replace(pointer pos, rvalue_type item) { - *pos = boost::move(item); -#if BOOST_CB_ENABLE_DEBUG - invalidate_iterators(iterator(this, pos)); -#endif - } - - /*! INTERNAL ONLY */ - void construct_or_replace(bool construct, pointer pos, param_value_type item) { - if (construct) - boost::allocator_construct(alloc(), boost::to_address(pos), item); - else - replace(pos, item); - } - - /*! INTERNAL ONLY */ - void construct_or_replace(bool construct, pointer pos, rvalue_type item) { - if (construct) - boost::allocator_construct(alloc(), boost::to_address(pos), boost::move(item)); - else - replace(pos, boost::move(item)); - } - - /*! INTERNAL ONLY */ - void destroy_item(pointer p) { - boost::allocator_destroy(alloc(), boost::to_address(p)); -#if BOOST_CB_ENABLE_DEBUG - invalidate_iterators(iterator(this, p)); - cb_details::do_fill_uninitialized_memory(p, sizeof(value_type)); -#endif - } - - /*! INTERNAL ONLY */ - void destroy_if_constructed(pointer pos) { - if (is_uninitialized(pos)) - destroy_item(pos); - } - - /*! INTERNAL ONLY */ - void destroy_content() { -#if BOOST_CB_ENABLE_DEBUG - destroy_content(false_type()); -#else - destroy_content(is_scalar<value_type>()); -#endif - } - - /*! INTERNAL ONLY */ - void destroy_content(const true_type&) { - m_first = add(m_first, size()); - } - - /*! INTERNAL ONLY */ - void destroy_content(const false_type&) { - for (size_type ii = 0; ii < size(); ++ii, increment(m_first)) - destroy_item(m_first); - } - - /*! INTERNAL ONLY */ - void destroy() BOOST_NOEXCEPT { - destroy_content(); - deallocate(m_buff, capacity()); -#if BOOST_CB_ENABLE_DEBUG - m_buff = 0; - m_first = 0; - m_last = 0; - m_end = 0; -#endif - } - - /*! INTERNAL ONLY */ - void initialize_buffer(capacity_type buffer_capacity) { - m_buff = allocate(buffer_capacity); - m_end = m_buff + buffer_capacity; - } - - /*! INTERNAL ONLY */ - void initialize_buffer(capacity_type buffer_capacity, param_value_type item) { - initialize_buffer(buffer_capacity); - BOOST_TRY { - cb_details::uninitialized_fill_n_with_alloc(m_buff, size(), item, alloc()); - } BOOST_CATCH(...) { - deallocate(m_buff, size()); - BOOST_RETHROW - } - BOOST_CATCH_END - } - - /*! INTERNAL ONLY */ - template <class IntegralType> - void initialize(IntegralType n, IntegralType item, const true_type&) { - m_size = static_cast<size_type>(n); - initialize_buffer(size(), item); - m_first = m_last = m_buff; - } - - /*! INTERNAL ONLY */ - template <class Iterator> - void initialize(Iterator first, Iterator last, const false_type&) { - BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); // check for invalid iterator type -#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x581)) - initialize(first, last, std::iterator_traits<Iterator>::iterator_category()); -#else - initialize(first, last, BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::iterator_category()); -#endif - } - - /*! INTERNAL ONLY */ - template <class InputIterator> - void initialize(InputIterator first, InputIterator last, const std::input_iterator_tag&) { - BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS // check if the STL provides templated iterator constructors - // for containers - std::deque<value_type, allocator_type> tmp(first, last, alloc()); - size_type distance = tmp.size(); - initialize(distance, boost::make_move_iterator(tmp.begin()), boost::make_move_iterator(tmp.end()), distance); - } - - /*! INTERNAL ONLY */ - template <class ForwardIterator> - void initialize(ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag&) { - BOOST_CB_ASSERT(std::distance(first, last) >= 0); // check for wrong range - size_type distance = std::distance(first, last); - initialize(distance, first, last, distance); - } - - /*! INTERNAL ONLY */ - template <class IntegralType> - void initialize(capacity_type buffer_capacity, IntegralType n, IntegralType item, const true_type&) { - BOOST_CB_ASSERT(buffer_capacity >= static_cast<size_type>(n)); // check for capacity lower than n - m_size = static_cast<size_type>(n); - initialize_buffer(buffer_capacity, item); - m_first = m_buff; - m_last = buffer_capacity == size() ? m_buff : m_buff + size(); - } - - /*! INTERNAL ONLY */ - template <class Iterator> - void initialize(capacity_type buffer_capacity, Iterator first, Iterator last, const false_type&) { - BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); // check for invalid iterator type -#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x581)) - initialize(buffer_capacity, first, last, std::iterator_traits<Iterator>::iterator_category()); -#else - initialize(buffer_capacity, first, last, BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::iterator_category()); -#endif - } - - /*! INTERNAL ONLY */ - template <class InputIterator> - void initialize(capacity_type buffer_capacity, - InputIterator first, - InputIterator last, - const std::input_iterator_tag&) { - initialize_buffer(buffer_capacity); - m_first = m_last = m_buff; - m_size = 0; - if (buffer_capacity == 0) - return; - while (first != last && !full()) { - boost::allocator_construct(alloc(), boost::to_address(m_last), *first++); - increment(m_last); - ++m_size; - } - while (first != last) { - replace(m_last, *first++); - increment(m_last); - m_first = m_last; - } - } - - /*! INTERNAL ONLY */ - template <class ForwardIterator> - void initialize(capacity_type buffer_capacity, - ForwardIterator first, - ForwardIterator last, - const std::forward_iterator_tag&) { - BOOST_CB_ASSERT(std::distance(first, last) >= 0); // check for wrong range - initialize(buffer_capacity, first, last, std::distance(first, last)); - } - - /*! INTERNAL ONLY */ - template <class ForwardIterator> - void initialize(capacity_type buffer_capacity, - ForwardIterator first, - ForwardIterator last, - size_type distance) { - initialize_buffer(buffer_capacity); - m_first = m_buff; - if (distance > buffer_capacity) { - std::advance(first, distance - buffer_capacity); - m_size = buffer_capacity; - } else { - m_size = distance; - } - BOOST_TRY { - m_last = cb_details::uninitialized_copy(first, last, m_buff, alloc()); - } BOOST_CATCH(...) { - deallocate(m_buff, buffer_capacity); - BOOST_RETHROW - } - BOOST_CATCH_END - if (m_last == m_end) - m_last = m_buff; - } - - /*! INTERNAL ONLY */ - void reset(pointer buff, pointer last, capacity_type new_capacity) { - destroy(); - m_size = last - buff; - m_first = m_buff = buff; - m_end = m_buff + new_capacity; - m_last = last == m_end ? m_buff : last; - } - - /*! INTERNAL ONLY */ - void swap_allocator(circular_buffer<T, Alloc>&, const true_type&) { - // Swap is not needed because allocators have no state. - } - - /*! INTERNAL ONLY */ - void swap_allocator(circular_buffer<T, Alloc>& cb, const false_type&) { - adl_move_swap(alloc(), cb.alloc()); - } - - /*! INTERNAL ONLY */ - template <class IntegralType> - void assign(IntegralType n, IntegralType item, const true_type&) { - assign(static_cast<size_type>(n), static_cast<value_type>(item)); - } - - /*! INTERNAL ONLY */ - template <class Iterator> - void assign(Iterator first, Iterator last, const false_type&) { - BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); // check for invalid iterator type -#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x581)) - assign(first, last, std::iterator_traits<Iterator>::iterator_category()); -#else - assign(first, last, BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::iterator_category()); -#endif - } - - /*! INTERNAL ONLY */ - template <class InputIterator> - void assign(InputIterator first, InputIterator last, const std::input_iterator_tag&) { - BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS // check if the STL provides templated iterator constructors - // for containers - std::deque<value_type, allocator_type> tmp(first, last, alloc()); - size_type distance = tmp.size(); - assign_n(distance, distance, - cb_details::make_assign_range - (boost::make_move_iterator(tmp.begin()), boost::make_move_iterator(tmp.end()), alloc())); - } - - /*! INTERNAL ONLY */ - template <class ForwardIterator> - void assign(ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag&) { - BOOST_CB_ASSERT(std::distance(first, last) >= 0); // check for wrong range - size_type distance = std::distance(first, last); - assign_n(distance, distance, cb_details::make_assign_range(first, last, alloc())); - } - - /*! INTERNAL ONLY */ - template <class IntegralType> - void assign(capacity_type new_capacity, IntegralType n, IntegralType item, const true_type&) { - assign(new_capacity, static_cast<size_type>(n), static_cast<value_type>(item)); - } - - /*! INTERNAL ONLY */ - template <class Iterator> - void assign(capacity_type new_capacity, Iterator first, Iterator last, const false_type&) { - BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); // check for invalid iterator type -#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x581)) - assign(new_capacity, first, last, std::iterator_traits<Iterator>::iterator_category()); -#else - assign(new_capacity, first, last, BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::iterator_category()); -#endif - } - - /*! INTERNAL ONLY */ - template <class InputIterator> - void assign(capacity_type new_capacity, InputIterator first, InputIterator last, const std::input_iterator_tag&) { - if (new_capacity == capacity()) { - clear(); - insert(begin(), first, last); - } else { - circular_buffer<value_type, allocator_type> tmp(new_capacity, first, last, alloc()); - tmp.swap(*this); - } - } - - /*! INTERNAL ONLY */ - template <class ForwardIterator> - void assign(capacity_type new_capacity, ForwardIterator first, ForwardIterator last, - const std::forward_iterator_tag&) { - BOOST_CB_ASSERT(std::distance(first, last) >= 0); // check for wrong range - size_type distance = std::distance(first, last); - if (distance > new_capacity) { - std::advance(first, distance - new_capacity); - distance = new_capacity; - } - assign_n(new_capacity, distance, - cb_details::make_assign_range(first, last, alloc())); - } - - /*! INTERNAL ONLY */ - template <class Functor> - void assign_n(capacity_type new_capacity, size_type n, const Functor& fnc) { - if (new_capacity == capacity()) { - destroy_content(); - BOOST_TRY { - fnc(m_buff); - } BOOST_CATCH(...) { - m_size = 0; - BOOST_RETHROW - } - BOOST_CATCH_END - } else { - pointer buff = allocate(new_capacity); - BOOST_TRY { - fnc(buff); - } BOOST_CATCH(...) { - deallocate(buff, new_capacity); - BOOST_RETHROW - } - BOOST_CATCH_END - destroy(); - m_buff = buff; - m_end = m_buff + new_capacity; - } - m_size = n; - m_first = m_buff; - m_last = add(m_buff, size()); - } - - /*! INTERNAL ONLY */ - template <class ValT> - iterator insert_item(const iterator& pos, ValT item) { - pointer p = pos.m_it; - if (p == 0) { - construct_or_replace(!full(), m_last, static_cast<ValT>(item)); - p = m_last; - } else { - pointer src = m_last; - pointer dest = m_last; - bool construct = !full(); - BOOST_TRY { - while (src != p) { - decrement(src); - construct_or_replace(construct, dest, boost::move_if_noexcept(*src)); - decrement(dest); - construct = false; - } - replace(p, static_cast<ValT>(item)); - } BOOST_CATCH(...) { - if (!construct && !full()) { - increment(m_last); - ++m_size; - } - BOOST_RETHROW - } - BOOST_CATCH_END - } - increment(m_last); - if (full()) - m_first = m_last; - else - ++m_size; - return iterator(this, p); - } - - /*! INTERNAL ONLY */ - template <class IntegralType> - void insert(const iterator& pos, IntegralType n, IntegralType item, const true_type&) { - insert(pos, static_cast<size_type>(n), static_cast<value_type>(item)); - } - - /*! INTERNAL ONLY */ - template <class Iterator> - void insert(const iterator& pos, Iterator first, Iterator last, const false_type&) { - BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); // check for invalid iterator type -#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x581)) - insert(pos, first, last, std::iterator_traits<Iterator>::iterator_category()); -#else - insert(pos, first, last, BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::iterator_category()); -#endif - } - - /*! INTERNAL ONLY */ - template <class InputIterator> - void insert(iterator pos, InputIterator first, InputIterator last, const std::input_iterator_tag&) { - if (!full() || pos != begin()) { - for (;first != last; ++pos) - pos = insert(pos, *first++); - } - } - - /*! INTERNAL ONLY */ - template <class ForwardIterator> - void insert(const iterator& pos, ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag&) { - BOOST_CB_ASSERT(std::distance(first, last) >= 0); // check for wrong range - size_type n = std::distance(first, last); - if (n == 0) - return; - size_type copy = capacity() - (end() - pos); - if (copy == 0) - return; - if (n > copy) { - std::advance(first, n - copy); - n = copy; - } - insert_n(pos, n, cb_details::iterator_wrapper<ForwardIterator>(first)); - } - - /*! INTERNAL ONLY */ - template <class Wrapper> - void insert_n(const iterator& pos, size_type n, const Wrapper& wrapper) { - size_type construct = reserve(); - if (construct > n) - construct = n; - if (pos.m_it == 0) { - size_type ii = 0; - pointer p = m_last; - BOOST_TRY { - for (; ii < construct; ++ii, increment(p)) - boost::allocator_construct(alloc(), boost::to_address(p), *wrapper()); - for (;ii < n; ++ii, increment(p)) - replace(p, *wrapper()); - } BOOST_CATCH(...) { - size_type constructed = (std::min)(ii, construct); - m_last = add(m_last, constructed); - m_size += constructed; - BOOST_RETHROW - } - BOOST_CATCH_END - } else { - pointer src = m_last; - pointer dest = add(m_last, n - 1); - pointer p = pos.m_it; - size_type ii = 0; - BOOST_TRY { - while (src != pos.m_it) { - decrement(src); - construct_or_replace(is_uninitialized(dest), dest, *src); - decrement(dest); - } - for (; ii < n; ++ii, increment(p)) - construct_or_replace(is_uninitialized(p), p, *wrapper()); - } BOOST_CATCH(...) { - for (p = add(m_last, n - 1); p != dest; decrement(p)) - destroy_if_constructed(p); - for (n = 0, p = pos.m_it; n < ii; ++n, increment(p)) - destroy_if_constructed(p); - BOOST_RETHROW - } - BOOST_CATCH_END - } - m_last = add(m_last, n); - m_first = add(m_first, n - construct); - m_size += construct; - } - - /*! INTERNAL ONLY */ - template <class IntegralType> - void rinsert(const iterator& pos, IntegralType n, IntegralType item, const true_type&) { - rinsert(pos, static_cast<size_type>(n), static_cast<value_type>(item)); - } - - /*! INTERNAL ONLY */ - template <class Iterator> - void rinsert(const iterator& pos, Iterator first, Iterator last, const false_type&) { - BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); // check for invalid iterator type -#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x581)) - rinsert(pos, first, last, std::iterator_traits<Iterator>::iterator_category()); -#else - rinsert(pos, first, last, BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::iterator_category()); -#endif - } - - /*! INTERNAL ONLY */ - template <class InputIterator> - void rinsert(iterator pos, InputIterator first, InputIterator last, const std::input_iterator_tag&) { - if (!full() || pos.m_it != 0) { - for (;first != last; ++pos) { - pos = rinsert(pos, *first++); - if (pos.m_it == 0) - break; - } - } - } - - /*! INTERNAL ONLY */ - template <class ForwardIterator> - void rinsert(const iterator& pos, ForwardIterator first, ForwardIterator last, const std::forward_iterator_tag&) { - BOOST_CB_ASSERT(std::distance(first, last) >= 0); // check for wrong range - rinsert_n(pos, std::distance(first, last), cb_details::iterator_wrapper<ForwardIterator>(first)); - } - - /*! INTERNAL ONLY */ - template <class Wrapper> - void rinsert_n(const iterator& pos, size_type n, const Wrapper& wrapper) { - if (n == 0) - return; - iterator b = begin(); - size_type copy = capacity() - (pos - b); - if (copy == 0) - return; - if (n > copy) - n = copy; - size_type construct = reserve(); - if (construct > n) - construct = n; - if (pos == b) { - pointer p = sub(m_first, n); - size_type ii = n; - BOOST_TRY { - for (;ii > construct; --ii, increment(p)) - replace(p, *wrapper()); - for (; ii > 0; --ii, increment(p)) - boost::allocator_construct(alloc(), boost::to_address(p), *wrapper()); - } BOOST_CATCH(...) { - size_type constructed = ii < construct ? construct - ii : 0; - m_last = add(m_last, constructed); - m_size += constructed; - BOOST_RETHROW - } - BOOST_CATCH_END - } else { - pointer src = m_first; - pointer dest = sub(m_first, n); - pointer p = map_pointer(pos.m_it); - BOOST_TRY { - while (src != p) { - construct_or_replace(is_uninitialized(dest), dest, *src); - increment(src); - increment(dest); - } - for (size_type ii = 0; ii < n; ++ii, increment(dest)) - construct_or_replace(is_uninitialized(dest), dest, *wrapper()); - } BOOST_CATCH(...) { - for (src = sub(m_first, n); src != dest; increment(src)) - destroy_if_constructed(src); - BOOST_RETHROW - } - BOOST_CATCH_END - } - m_first = sub(m_first, n); - m_last = sub(m_last, n - construct); - m_size += construct; - } - - /*! INTERNAL ONLY */ - void erase_begin(size_type n, const true_type&) { - m_first = add(m_first, n); - m_size -= n; - } - - /*! INTERNAL ONLY */ - void erase_begin(size_type n, const false_type&) { - iterator b = begin(); - rerase(b, b + n); - } - - /*! INTERNAL ONLY */ - void erase_end(size_type n, const true_type&) { - m_last = sub(m_last, n); - m_size -= n; - } - - /*! INTERNAL ONLY */ - void erase_end(size_type n, const false_type&) { - iterator e = end(); - erase(e - n, e); - } -}; - -// Non-member functions - -//! Compare two <code>circular_buffer</code>s element-by-element to determine if they are equal. -/*! - \param lhs The <code>circular_buffer</code> to compare. - \param rhs The <code>circular_buffer</code> to compare. - \return <code>lhs.\link circular_buffer::size() size()\endlink == rhs.\link circular_buffer::size() size()\endlink - && <a href="https://www.boost.org/sgi/stl/equal.html">std::equal</a>(lhs.\link circular_buffer::begin() - begin()\endlink, lhs.\link circular_buffer::end() end()\endlink, - rhs.\link circular_buffer::begin() begin()\endlink)</code> - \throws Nothing. - \par Complexity - Linear (in the size of the <code>circular_buffer</code>s). - \par Iterator Invalidation - Does not invalidate any iterators. -*/ -template <class T, class Alloc> -inline bool operator == (const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs) { - return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin()); -} - -/*! - \brief Compare two <code>circular_buffer</code>s element-by-element to determine if the left one is lesser than the - right one. - \param lhs The <code>circular_buffer</code> to compare. - \param rhs The <code>circular_buffer</code> to compare. - \return <code><a href="https://www.boost.org/sgi/stl/lexicographical_compare.html"> - std::lexicographical_compare</a>(lhs.\link circular_buffer::begin() begin()\endlink, - lhs.\link circular_buffer::end() end()\endlink, rhs.\link circular_buffer::begin() begin()\endlink, - rhs.\link circular_buffer::end() end()\endlink)</code> - \throws Nothing. - \par Complexity - Linear (in the size of the <code>circular_buffer</code>s). - \par Iterator Invalidation - Does not invalidate any iterators. -*/ -template <class T, class Alloc> -inline bool operator < (const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs) { - return std::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); -} - -#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) || defined(BOOST_MSVC) - -//! Compare two <code>circular_buffer</code>s element-by-element to determine if they are non-equal. -/*! - \param lhs The <code>circular_buffer</code> to compare. - \param rhs The <code>circular_buffer</code> to compare. - \return <code>!(lhs == rhs)</code> - \throws Nothing. - \par Complexity - Linear (in the size of the <code>circular_buffer</code>s). - \par Iterator Invalidation - Does not invalidate any iterators. - \sa <code>operator==(const circular_buffer<T,Alloc>&, const circular_buffer<T,Alloc>&)</code> -*/ -template <class T, class Alloc> -inline bool operator != (const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs) { - return !(lhs == rhs); -} - -/*! - \brief Compare two <code>circular_buffer</code>s element-by-element to determine if the left one is greater than - the right one. - \param lhs The <code>circular_buffer</code> to compare. - \param rhs The <code>circular_buffer</code> to compare. - \return <code>rhs \< lhs</code> - \throws Nothing. - \par Complexity - Linear (in the size of the <code>circular_buffer</code>s). - \par Iterator Invalidation - Does not invalidate any iterators. - \sa <code>operator<(const circular_buffer<T,Alloc>&, const circular_buffer<T,Alloc>&)</code> -*/ -template <class T, class Alloc> -inline bool operator > (const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs) { - return rhs < lhs; -} - -/*! - \brief Compare two <code>circular_buffer</code>s element-by-element to determine if the left one is lesser or equal - to the right one. - \param lhs The <code>circular_buffer</code> to compare. - \param rhs The <code>circular_buffer</code> to compare. - \return <code>!(rhs \< lhs)</code> - \throws Nothing. - \par Complexity - Linear (in the size of the <code>circular_buffer</code>s). - \par Iterator Invalidation - Does not invalidate any iterators. - \sa <code>operator<(const circular_buffer<T,Alloc>&, const circular_buffer<T,Alloc>&)</code> -*/ -template <class T, class Alloc> -inline bool operator <= (const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs) { - return !(rhs < lhs); -} - -/*! - \brief Compare two <code>circular_buffer</code>s element-by-element to determine if the left one is greater or - equal to the right one. - \param lhs The <code>circular_buffer</code> to compare. - \param rhs The <code>circular_buffer</code> to compare. - \return <code>!(lhs < rhs)</code> - \throws Nothing. - \par Complexity - Linear (in the size of the <code>circular_buffer</code>s). - \par Iterator Invalidation - Does not invalidate any iterators. - \sa <code>operator<(const circular_buffer<T,Alloc>&, const circular_buffer<T,Alloc>&)</code> -*/ -template <class T, class Alloc> -inline bool operator >= (const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs) { - return !(lhs < rhs); -} - -//! Swap the contents of two <code>circular_buffer</code>s. -/*! - \post <code>lhs</code> contains elements of <code>rhs</code> and vice versa. - \param lhs The <code>circular_buffer</code> whose content will be swapped with <code>rhs</code>. - \param rhs The <code>circular_buffer</code> whose content will be swapped with <code>lhs</code>. - \throws Nothing. - \par Complexity - Constant (in the size of the <code>circular_buffer</code>s). - \par Iterator Invalidation - Invalidates all iterators of both <code>circular_buffer</code>s. (On the other hand the iterators still - point to the same elements but within another container. If you want to rely on this feature you have to - turn the <a href="#debug">Debug Support</a> off otherwise an assertion will report an error if such - invalidated iterator is used.) - \sa <code>\link circular_buffer::swap(circular_buffer<T, Alloc>&) swap(circular_buffer<T, Alloc>&)\endlink</code> -*/ -template <class T, class Alloc> -inline void swap(circular_buffer<T, Alloc>& lhs, circular_buffer<T, Alloc>& rhs) BOOST_NOEXCEPT { - lhs.swap(rhs); -} - -#endif // #if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) || defined(BOOST_MSVC) - -} // namespace boost - -#endif // #if !defined(BOOST_CIRCULAR_BUFFER_BASE_HPP) diff --git a/contrib/restricted/boost/boost/circular_buffer/debug.hpp b/contrib/restricted/boost/boost/circular_buffer/debug.hpp deleted file mode 100644 index b6ab0fefbe..0000000000 --- a/contrib/restricted/boost/boost/circular_buffer/debug.hpp +++ /dev/null @@ -1,248 +0,0 @@ -// Debug support for the circular buffer library. - -// Copyright (c) 2003-2008 Jan Gaspar - -// Use, modification, and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#if !defined(BOOST_CIRCULAR_BUFFER_DEBUG_HPP) -#define BOOST_CIRCULAR_BUFFER_DEBUG_HPP - -#if defined(_MSC_VER) - #pragma once -#endif - -#if BOOST_CB_ENABLE_DEBUG -#include <cstring> - -#if defined(BOOST_NO_STDC_NAMESPACE) -namespace std { - using ::memset; -} -#endif - -#endif // BOOST_CB_ENABLE_DEBUG -namespace boost { - -namespace cb_details { - -#if BOOST_CB_ENABLE_DEBUG - -// The value the uninitialized memory is filled with. -const int UNINITIALIZED = 0xcc; - -template <class T> -inline void do_fill_uninitialized_memory(T* data, std::size_t size_in_bytes) BOOST_NOEXCEPT { - std::memset(static_cast<void*>(data), UNINITIALIZED, size_in_bytes); -} - -template <class T> -inline void do_fill_uninitialized_memory(T& /*data*/, std::size_t /*size_in_bytes*/) BOOST_NOEXCEPT { - // Do nothing -} - - -class debug_iterator_registry; - -/*! - \class debug_iterator_base - \brief Registers/unregisters iterators into the registry of valid iterators. - - This class is intended to be a base class of an iterator. -*/ -class debug_iterator_base { - -private: -// Members - - //! Iterator registry. - mutable const debug_iterator_registry* m_registry; - - //! Next iterator in the iterator chain. - mutable const debug_iterator_base* m_next; - -public: -// Construction/destruction - - //! Default constructor. - debug_iterator_base(); - - //! Constructor taking the iterator registry as a parameter. - debug_iterator_base(const debug_iterator_registry* registry); - - //! Copy constructor. - debug_iterator_base(const debug_iterator_base& rhs); - - //! Destructor. - ~debug_iterator_base(); - -// Methods - - //! Assign operator. - debug_iterator_base& operator = (const debug_iterator_base& rhs); - - //! Is the iterator valid? - bool is_valid(const debug_iterator_registry* registry) const; - - //! Invalidate the iterator. - /*! - \note The method is const in order to invalidate const iterators, too. - */ - void invalidate() const; - - //! Return the next iterator in the iterator chain. - const debug_iterator_base* next() const; - - //! Set the next iterator in the iterator chain. - /*! - \note The method is const in order to set a next iterator to a const iterator, too. - */ - void set_next(const debug_iterator_base* it) const; - -private: -// Helpers - - //! Register self as a valid iterator. - void register_self(); - - //! Unregister self from valid iterators. - void unregister_self(); -}; - -/*! - \class debug_iterator_registry - \brief Registry of valid iterators. - - This class is intended to be a base class of a container. -*/ -class debug_iterator_registry { - - //! Pointer to the chain of valid iterators. - mutable const debug_iterator_base* m_iterators; - -public: -// Methods - - //! Default constructor. - debug_iterator_registry() : m_iterators(0) {} - - //! Register an iterator into the list of valid iterators. - /*! - \note The method is const in order to register iterators into const containers, too. - */ - void register_iterator(const debug_iterator_base* it) const { - it->set_next(m_iterators); - m_iterators = it; - } - - //! Unregister an iterator from the list of valid iterators. - /*! - \note The method is const in order to unregister iterators from const containers, too. - */ - void unregister_iterator(const debug_iterator_base* it) const { - const debug_iterator_base* previous = 0; - for (const debug_iterator_base* p = m_iterators; p != it; previous = p, p = p->next()) {} - remove(it, previous); - } - - //! Invalidate every iterator pointing to the same element as the iterator passed as a parameter. - template <class Iterator> - void invalidate_iterators(const Iterator& it) { - const debug_iterator_base* previous = 0; - for (const debug_iterator_base* p = m_iterators; p != 0; p = p->next()) { - if (((Iterator*)p)->m_it == it.m_it) { - p->invalidate(); - remove(p, previous); - continue; - } - previous = p; - } - } - - //! Invalidate all iterators except an iterator poining to the same element as the iterator passed as a parameter. - template <class Iterator> - void invalidate_iterators_except(const Iterator& it) { - const debug_iterator_base* previous = 0; - for (const debug_iterator_base* p = m_iterators; p != 0; p = p->next()) { - if (((Iterator*)p)->m_it != it.m_it) { - p->invalidate(); - remove(p, previous); - continue; - } - previous = p; - } - } - - //! Invalidate all iterators. - void invalidate_all_iterators() { - for (const debug_iterator_base* p = m_iterators; p != 0; p = p->next()) - p->invalidate(); - m_iterators = 0; - } - -private: -// Helpers - - //! Remove the current iterator from the iterator chain. - void remove(const debug_iterator_base* current, - const debug_iterator_base* previous) const { - if (previous == 0) - m_iterators = m_iterators->next(); - else - previous->set_next(current->next()); - } -}; - -// Implementation of the debug_iterator_base methods. - -inline debug_iterator_base::debug_iterator_base() : m_registry(0), m_next(0) {} - -inline debug_iterator_base::debug_iterator_base(const debug_iterator_registry* registry) -: m_registry(registry), m_next(0) { - register_self(); -} - -inline debug_iterator_base::debug_iterator_base(const debug_iterator_base& rhs) -: m_registry(rhs.m_registry), m_next(0) { - register_self(); -} - -inline debug_iterator_base::~debug_iterator_base() { unregister_self(); } - -inline debug_iterator_base& debug_iterator_base::operator = (const debug_iterator_base& rhs) { - if (m_registry == rhs.m_registry) - return *this; - unregister_self(); - m_registry = rhs.m_registry; - register_self(); - return *this; -} - -inline bool debug_iterator_base::is_valid(const debug_iterator_registry* registry) const { - return m_registry == registry; -} - -inline void debug_iterator_base::invalidate() const { m_registry = 0; } - -inline const debug_iterator_base* debug_iterator_base::next() const { return m_next; } - -inline void debug_iterator_base::set_next(const debug_iterator_base* it) const { m_next = it; } - -inline void debug_iterator_base::register_self() { - if (m_registry != 0) - m_registry->register_iterator(this); -} - -inline void debug_iterator_base::unregister_self() { - if (m_registry != 0) - m_registry->unregister_iterator(this); -} - -#endif // #if BOOST_CB_ENABLE_DEBUG - -} // namespace cb_details - -} // namespace boost - -#endif // #if !defined(BOOST_CIRCULAR_BUFFER_DEBUG_HPP) diff --git a/contrib/restricted/boost/boost/circular_buffer/details.hpp b/contrib/restricted/boost/boost/circular_buffer/details.hpp deleted file mode 100644 index fc1499f687..0000000000 --- a/contrib/restricted/boost/boost/circular_buffer/details.hpp +++ /dev/null @@ -1,475 +0,0 @@ -// Helper classes and functions for the circular buffer. - -// Copyright (c) 2003-2008 Jan Gaspar - -// Copyright 2014,2018 Glen Joseph Fernandes -// (glenjofe@gmail.com) - -// Use, modification, and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#if !defined(BOOST_CIRCULAR_BUFFER_DETAILS_HPP) -#define BOOST_CIRCULAR_BUFFER_DETAILS_HPP - -#if defined(_MSC_VER) - #pragma once -#endif - -#include <boost/throw_exception.hpp> -#include <boost/core/allocator_access.hpp> -#include <boost/core/pointer_traits.hpp> -#include <boost/move/move.hpp> -#include <boost/type_traits/is_nothrow_move_constructible.hpp> -#include <boost/core/no_exceptions_support.hpp> -#include <iterator> - -// Silence MS /W4 warnings like C4913: -// "user defined binary operator ',' exists but no overload could convert all operands, default built-in binary operator ',' used" -// This might happen when previously including some boost headers that overload the coma operator. -#if defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable:4913) -#endif - -namespace boost { - -namespace cb_details { - -template <class Alloc> struct nonconst_traits; - -template<class ForwardIterator, class Diff, class T, class Alloc> -void uninitialized_fill_n_with_alloc( - ForwardIterator first, Diff n, const T& item, Alloc& alloc); - -template<class InputIterator, class ForwardIterator, class Alloc> -ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a); - -template<class InputIterator, class ForwardIterator, class Alloc> -ForwardIterator uninitialized_move_if_noexcept(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a); - -/*! - \struct const_traits - \brief Defines the data types for a const iterator. -*/ -template <class Alloc> -struct const_traits { - // Basic types - typedef typename Alloc::value_type value_type; - typedef typename boost::allocator_const_pointer<Alloc>::type pointer; - typedef const value_type& reference; - typedef typename boost::allocator_size_type<Alloc>::type size_type; - typedef typename boost::allocator_difference_type<Alloc>::type difference_type; - - // Non-const traits - typedef nonconst_traits<Alloc> nonconst_self; -}; - -/*! - \struct nonconst_traits - \brief Defines the data types for a non-const iterator. -*/ -template <class Alloc> -struct nonconst_traits { - // Basic types - typedef typename Alloc::value_type value_type; - typedef typename boost::allocator_pointer<Alloc>::type pointer; - typedef value_type& reference; - typedef typename boost::allocator_size_type<Alloc>::type size_type; - typedef typename boost::allocator_difference_type<Alloc>::type difference_type; - - // Non-const traits - typedef nonconst_traits<Alloc> nonconst_self; -}; - -/*! - \struct iterator_wrapper - \brief Helper iterator dereference wrapper. -*/ -template <class Iterator> -struct iterator_wrapper { - mutable Iterator m_it; - explicit iterator_wrapper(Iterator it) : m_it(it) {} - Iterator operator () () const { return m_it++; } -private: - iterator_wrapper<Iterator>& operator = (const iterator_wrapper<Iterator>&); // do not generate -}; - -/*! - \struct item_wrapper - \brief Helper item dereference wrapper. -*/ -template <class Pointer, class Value> -struct item_wrapper { - Value m_item; - explicit item_wrapper(Value item) : m_item(item) {} - Pointer operator () () const { return &m_item; } -private: - item_wrapper<Pointer, Value>& operator = (const item_wrapper<Pointer, Value>&); // do not generate -}; - -/*! - \struct assign_n - \brief Helper functor for assigning n items. -*/ -template <class Value, class Alloc> -struct assign_n { - typedef typename boost::allocator_size_type<Alloc>::type size_type; - size_type m_n; - Value m_item; - Alloc& m_alloc; - assign_n(size_type n, Value item, Alloc& alloc) : m_n(n), m_item(item), m_alloc(alloc) {} - template <class Pointer> - void operator () (Pointer p) const { - uninitialized_fill_n_with_alloc(p, m_n, m_item, m_alloc); - } -private: - assign_n<Value, Alloc>& operator = (const assign_n<Value, Alloc>&); // do not generate -}; - -/*! - \struct assign_range - \brief Helper functor for assigning range of items. -*/ -template <class Iterator, class Alloc> -struct assign_range { - Iterator m_first; - Iterator m_last; - Alloc& m_alloc; - - assign_range(const Iterator& first, const Iterator& last, Alloc& alloc) - : m_first(first), m_last(last), m_alloc(alloc) {} - - template <class Pointer> - void operator () (Pointer p) const { - boost::cb_details::uninitialized_copy(m_first, m_last, p, m_alloc); - } -}; - -template <class Iterator, class Alloc> -inline assign_range<Iterator, Alloc> make_assign_range(const Iterator& first, const Iterator& last, Alloc& a) { - return assign_range<Iterator, Alloc>(first, last, a); -} - -/*! - \class capacity_control - \brief Capacity controller of the space optimized circular buffer. -*/ -template <class Size> -class capacity_control { - - //! The capacity of the space-optimized circular buffer. - Size m_capacity; - - //! The lowest guaranteed or minimum capacity of the adapted space-optimized circular buffer. - Size m_min_capacity; - -public: - - //! Constructor. - capacity_control(Size buffer_capacity, Size min_buffer_capacity = 0) - : m_capacity(buffer_capacity), m_min_capacity(min_buffer_capacity) - { // Check for capacity lower than min_capacity. - BOOST_CB_ASSERT(buffer_capacity >= min_buffer_capacity); - } - - // Default copy constructor. - - // Default assign operator. - - //! Get the capacity of the space optimized circular buffer. - Size capacity() const { return m_capacity; } - - //! Get the minimal capacity of the space optimized circular buffer. - Size min_capacity() const { return m_min_capacity; } - - //! Size operator - returns the capacity of the space optimized circular buffer. - operator Size() const { return m_capacity; } -}; - -/*! - \struct iterator - \brief Random access iterator for the circular buffer. - \param Buff The type of the underlying circular buffer. - \param Traits Basic iterator types. - \note This iterator is not circular. It was designed - for iterating from begin() to end() of the circular buffer. -*/ -template <class Buff, class Traits> -struct iterator -#if BOOST_CB_ENABLE_DEBUG - : public debug_iterator_base -#endif // #if BOOST_CB_ENABLE_DEBUG -{ -// Helper types - - //! Non-const iterator. - typedef iterator<Buff, typename Traits::nonconst_self> nonconst_self; - -// Basic types - typedef std::random_access_iterator_tag iterator_category; - - //! The type of the elements stored in the circular buffer. - typedef typename Traits::value_type value_type; - - //! Pointer to the element. - typedef typename Traits::pointer pointer; - - //! Reference to the element. - typedef typename Traits::reference reference; - - //! Size type. - typedef typename Traits::size_type size_type; - - //! Difference type. - typedef typename Traits::difference_type difference_type; - -// Member variables - - //! The circular buffer where the iterator points to. - const Buff* m_buff; - - //! An internal iterator. - pointer m_it; - -// Construction & assignment - - // Default copy constructor. - - //! Default constructor. - iterator() : m_buff(0), m_it(0) {} - -#if BOOST_CB_ENABLE_DEBUG - - //! Copy constructor (used for converting from a non-const to a const iterator). - iterator(const nonconst_self& it) : debug_iterator_base(it), m_buff(it.m_buff), m_it(it.m_it) {} - - //! Internal constructor. - /*! - \note This constructor is not intended to be used directly by the user. - */ - iterator(const Buff* cb, const pointer p) : debug_iterator_base(cb), m_buff(cb), m_it(p) {} - -#else - - iterator(const nonconst_self& it) : m_buff(it.m_buff), m_it(it.m_it) {} - - iterator(const Buff* cb, const pointer p) : m_buff(cb), m_it(p) {} - -#endif // #if BOOST_CB_ENABLE_DEBUG - -// Random access iterator methods - - //! Dereferencing operator. - reference operator * () const { - BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator - BOOST_CB_ASSERT(m_it != 0); // check for iterator pointing to end() - return *m_it; - } - - //! Dereferencing operator. - pointer operator -> () const { return &(operator*()); } - - //! Difference operator. - template <class Traits0> - difference_type operator - (const iterator<Buff, Traits0>& it) const { - BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator - BOOST_CB_ASSERT(it.is_valid(m_buff)); // check for uninitialized or invalidated iterator - return linearize_pointer(*this) - linearize_pointer(it); - } - - //! Increment operator (prefix). - iterator& operator ++ () { - BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator - BOOST_CB_ASSERT(m_it != 0); // check for iterator pointing to end() - m_buff->increment(m_it); - if (m_it == m_buff->m_last) - m_it = 0; - return *this; - } - - //! Increment operator (postfix). - iterator operator ++ (int) { - iterator<Buff, Traits> tmp = *this; - ++*this; - return tmp; - } - - //! Decrement operator (prefix). - iterator& operator -- () { - BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator - BOOST_CB_ASSERT(m_it != m_buff->m_first); // check for iterator pointing to begin() - if (m_it == 0) - m_it = m_buff->m_last; - m_buff->decrement(m_it); - return *this; - } - - //! Decrement operator (postfix). - iterator operator -- (int) { - iterator<Buff, Traits> tmp = *this; - --*this; - return tmp; - } - - //! Iterator addition. - iterator& operator += (difference_type n) { - BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator - if (n > 0) { - BOOST_CB_ASSERT(m_buff->end() - *this >= n); // check for too large n - m_it = m_buff->add(m_it, n); - if (m_it == m_buff->m_last) - m_it = 0; - } else if (n < 0) { - *this -= -n; - } - return *this; - } - - //! Iterator addition. - iterator operator + (difference_type n) const { return iterator<Buff, Traits>(*this) += n; } - - //! Iterator subtraction. - iterator& operator -= (difference_type n) { - BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator - if (n > 0) { - BOOST_CB_ASSERT(*this - m_buff->begin() >= n); // check for too large n - m_it = m_buff->sub(m_it == 0 ? m_buff->m_last : m_it, n); - } else if (n < 0) { - *this += -n; - } - return *this; - } - - //! Iterator subtraction. - iterator operator - (difference_type n) const { return iterator<Buff, Traits>(*this) -= n; } - - //! Element access operator. - reference operator [] (difference_type n) const { return *(*this + n); } - -// Equality & comparison - - //! Equality. - template <class Traits0> - bool operator == (const iterator<Buff, Traits0>& it) const { - BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator - BOOST_CB_ASSERT(it.is_valid(m_buff)); // check for uninitialized or invalidated iterator - return m_it == it.m_it; - } - - //! Inequality. - template <class Traits0> - bool operator != (const iterator<Buff, Traits0>& it) const { - BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator - BOOST_CB_ASSERT(it.is_valid(m_buff)); // check for uninitialized or invalidated iterator - return m_it != it.m_it; - } - - //! Less. - template <class Traits0> - bool operator < (const iterator<Buff, Traits0>& it) const { - BOOST_CB_ASSERT(is_valid(m_buff)); // check for uninitialized or invalidated iterator - BOOST_CB_ASSERT(it.is_valid(m_buff)); // check for uninitialized or invalidated iterator - return linearize_pointer(*this) < linearize_pointer(it); - } - - //! Greater. - template <class Traits0> - bool operator > (const iterator<Buff, Traits0>& it) const { return it < *this; } - - //! Less or equal. - template <class Traits0> - bool operator <= (const iterator<Buff, Traits0>& it) const { return !(it < *this); } - - //! Greater or equal. - template <class Traits0> - bool operator >= (const iterator<Buff, Traits0>& it) const { return !(*this < it); } - -// Helpers - - //! Get a pointer which would point to the same element as the iterator in case the circular buffer is linearized. - template <class Traits0> - typename Traits0::pointer linearize_pointer(const iterator<Buff, Traits0>& it) const { - return it.m_it == 0 ? m_buff->m_buff + m_buff->size() : - (it.m_it < m_buff->m_first ? it.m_it + (m_buff->m_end - m_buff->m_first) - : m_buff->m_buff + (it.m_it - m_buff->m_first)); - } -}; - -//! Iterator addition. -template <class Buff, class Traits> -inline iterator<Buff, Traits> -operator + (typename Traits::difference_type n, const iterator<Buff, Traits>& it) { - return it + n; -} - -/*! - \fn ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator dest) - \brief Equivalent of <code>std::uninitialized_copy</code> but with explicit specification of value type. -*/ -template<class InputIterator, class ForwardIterator, class Alloc> -inline ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a) { - ForwardIterator next = dest; - BOOST_TRY { - for (; first != last; ++first, ++dest) - boost::allocator_construct(a, boost::to_address(dest), *first); - } BOOST_CATCH(...) { - for (; next != dest; ++next) - boost::allocator_destroy(a, boost::to_address(next)); - BOOST_RETHROW - } - BOOST_CATCH_END - return dest; -} - -template<class InputIterator, class ForwardIterator, class Alloc> -ForwardIterator uninitialized_move_if_noexcept_impl(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a, - true_type) { - for (; first != last; ++first, ++dest) - boost::allocator_construct(a, boost::to_address(dest), boost::move(*first)); - return dest; -} - -template<class InputIterator, class ForwardIterator, class Alloc> -ForwardIterator uninitialized_move_if_noexcept_impl(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a, - false_type) { - return uninitialized_copy(first, last, dest, a); -} - -/*! - \fn ForwardIterator uninitialized_move_if_noexcept(InputIterator first, InputIterator last, ForwardIterator dest) - \brief Equivalent of <code>std::uninitialized_copy</code> but with explicit specification of value type and moves elements if they have noexcept move constructors. -*/ -template<class InputIterator, class ForwardIterator, class Alloc> -ForwardIterator uninitialized_move_if_noexcept(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a) { - typedef typename boost::is_nothrow_move_constructible<typename Alloc::value_type>::type tag_t; - return uninitialized_move_if_noexcept_impl(first, last, dest, a, tag_t()); -} - -/*! - \fn void uninitialized_fill_n_with_alloc(ForwardIterator first, Diff n, const T& item, Alloc& alloc) - \brief Equivalent of <code>std::uninitialized_fill_n</code> with allocator. -*/ -template<class ForwardIterator, class Diff, class T, class Alloc> -inline void uninitialized_fill_n_with_alloc(ForwardIterator first, Diff n, const T& item, Alloc& alloc) { - ForwardIterator next = first; - BOOST_TRY { - for (; n > 0; ++first, --n) - boost::allocator_construct(alloc, boost::to_address(first), item); - } BOOST_CATCH(...) { - for (; next != first; ++next) - boost::allocator_destroy(alloc, boost::to_address(next)); - BOOST_RETHROW - } - BOOST_CATCH_END -} - -} // namespace cb_details - -} // namespace boost - -#if defined(_MSC_VER) -# pragma warning(pop) -#endif - -#endif // #if !defined(BOOST_CIRCULAR_BUFFER_DETAILS_HPP) diff --git a/contrib/restricted/boost/boost/circular_buffer/space_optimized.hpp b/contrib/restricted/boost/boost/circular_buffer/space_optimized.hpp deleted file mode 100644 index 21681fd32a..0000000000 --- a/contrib/restricted/boost/boost/circular_buffer/space_optimized.hpp +++ /dev/null @@ -1,1713 +0,0 @@ -// Implementation of the circular buffer adaptor. - -// Copyright (c) 2003-2008 Jan Gaspar -// Copyright (c) 2013 Paul A. Bristow // Doxygen comments changed for new version of documentation. -// Copyright (c) 2013 Antony Polukhin // Move semantics implementation. - -// Use, modification, and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#if !defined(BOOST_CIRCULAR_BUFFER_SPACE_OPTIMIZED_HPP) -#define BOOST_CIRCULAR_BUFFER_SPACE_OPTIMIZED_HPP - -#if defined(_MSC_VER) - #pragma once -#endif - -#include <boost/type_traits/is_same.hpp> -#include <boost/config/workaround.hpp> - -namespace boost { - -/*! - \class circular_buffer_space_optimized - \brief Space optimized circular buffer container adaptor. - <code>T</code> must be a copyable class or must have an noexcept move constructor - and move assignment operator. -*/ -template <class T, class Alloc> -class circular_buffer_space_optimized : -/*! \cond */ -#if BOOST_CB_ENABLE_DEBUG -public -#endif -/*! \endcond */ -circular_buffer<T, Alloc> { -public: -// Typedefs - - typedef typename circular_buffer<T, Alloc>::value_type value_type; - typedef typename circular_buffer<T, Alloc>::pointer pointer; - typedef typename circular_buffer<T, Alloc>::const_pointer const_pointer; - typedef typename circular_buffer<T, Alloc>::reference reference; - typedef typename circular_buffer<T, Alloc>::const_reference const_reference; - typedef typename circular_buffer<T, Alloc>::size_type size_type; - typedef typename circular_buffer<T, Alloc>::difference_type difference_type; - typedef typename circular_buffer<T, Alloc>::allocator_type allocator_type; - typedef typename circular_buffer<T, Alloc>::const_iterator const_iterator; - typedef typename circular_buffer<T, Alloc>::iterator iterator; - typedef typename circular_buffer<T, Alloc>::const_reverse_iterator const_reverse_iterator; - typedef typename circular_buffer<T, Alloc>::reverse_iterator reverse_iterator; - typedef typename circular_buffer<T, Alloc>::array_range array_range; - typedef typename circular_buffer<T, Alloc>::const_array_range const_array_range; - typedef typename circular_buffer<T, Alloc>::param_value_type param_value_type; - typedef typename circular_buffer<T, Alloc>::rvalue_type rvalue_type; - //typedef typename circular_buffer<T, Alloc>::return_value_type return_value_type; - -/* <pre> is not passed through to html or pdf. So <br> is used in code section below. Ugly :-( -Ideally want a link to capacity_control, but this would require include details -and this would expose all the functions in details. -There must be a better way of doing this. -*/ - - /*! Capacity controller of the space optimized circular buffer. - - \see capacity_control in details.hpp. -<p> -<code> -class capacity_control<br> -{<br> - size_type m_capacity; // Available capacity.<br> - size_type m_min_capacity; // Minimum capacity.<br> -public:<br> - capacity_control(size_type capacity, size_type min_capacity = 0)<br> - : m_capacity(capacity), m_min_capacity(min_capacity)<br> - {};<br> - size_type %capacity() const { return m_capacity; }<br> - size_type min_capacity() const { return m_min_capacity; }<br> - operator size_type() const { return m_capacity; }<br> -};<br> -</code> -</p> - - - <p>Always - <code>capacity >= min_capacity</code>. - </p> - <p> - The <code>capacity()</code> represents the capacity - of the <code>circular_buffer_space_optimized</code> and - the <code>min_capacity()</code> determines the minimal allocated size of its internal buffer. - </p> - <p>The converting constructor of the <code>capacity_control</code> allows implicit conversion from - <code>size_type</code>-like types which ensures compatibility of creating an instance of the - <code>circular_buffer_space_optimized</code> with other STL containers. - - On the other hand the operator <code>%size_type()</code> - provides implicit conversion to the <code>size_type</code> which allows to treat the - capacity of the <code>circular_buffer_space_optimized</code> the same way as in the - <code>circular_buffer</a></code>. -</p> - */ - typedef cb_details::capacity_control<size_type> capacity_type; - -// Inherited - - using circular_buffer<T, Alloc>::get_allocator; - using circular_buffer<T, Alloc>::begin; - using circular_buffer<T, Alloc>::end; - using circular_buffer<T, Alloc>::rbegin; - using circular_buffer<T, Alloc>::rend; - using circular_buffer<T, Alloc>::at; - using circular_buffer<T, Alloc>::front; - using circular_buffer<T, Alloc>::back; - using circular_buffer<T, Alloc>::array_one; - using circular_buffer<T, Alloc>::array_two; - using circular_buffer<T, Alloc>::linearize; - using circular_buffer<T, Alloc>::is_linearized; - using circular_buffer<T, Alloc>::rotate; - using circular_buffer<T, Alloc>::size; - using circular_buffer<T, Alloc>::max_size; - using circular_buffer<T, Alloc>::empty; - -#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) - reference operator [] (size_type n) { return circular_buffer<T, Alloc>::operator[](n); } - const_reference operator [] (size_type n) const { return circular_buffer<T, Alloc>::operator[](n); } -#else - using circular_buffer<T, Alloc>::operator[]; -#endif - -private: -// Member variables - - //! The capacity controller of the space optimized circular buffer. - capacity_type m_capacity_ctrl; - -public: -// Overridden - - //! Is the <code>circular_buffer_space_optimized</code> full? - /*! - \return <code>true</code> if the number of elements stored in the <code>circular_buffer_space_optimized</code> - equals the capacity of the <code>circular_buffer_space_optimized</code>; <code>false</code> otherwise. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>empty()</code> - */ - bool full() const BOOST_NOEXCEPT { return m_capacity_ctrl == size(); } - - /*! \brief Get the maximum number of elements which can be inserted into the - <code>circular_buffer_space_optimized</code> without overwriting any of already stored elements. - \return <code>capacity().%capacity() - size()</code> - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>capacity()</code>, <code>size()</code>, <code>max_size()</code> - */ - size_type reserve() const BOOST_NOEXCEPT { return m_capacity_ctrl - size(); } - - //! Get the capacity of the <code>circular_buffer_space_optimized</code>. - /*! - \return The capacity controller representing the maximum number of elements which can be stored in the - <code>circular_buffer_space_optimized</code> and the minimal allocated size of the internal buffer. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Does not invalidate any iterators. - \par Complexity - Constant (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>reserve()</code>, <code>size()</code>, <code>max_size()</code>, - <code>set_capacity(const capacity_type&)</code> - */ - const capacity_type& capacity() const BOOST_NOEXCEPT { return m_capacity_ctrl; } - -#if defined(BOOST_CB_TEST) - - // Return the current capacity of the adapted circular buffer. - /* - \note This method is not intended to be used directly by the user. - It is defined only for testing purposes. - */ - size_type internal_capacity() const BOOST_NOEXCEPT { return circular_buffer<T, Alloc>::capacity(); } - -#endif // #if defined(BOOST_CB_TEST) - - /*! \brief Change the capacity (and the minimal guaranteed amount of allocated memory) of the - <code>circular_buffer_space_optimized</code>. - \post <code>capacity() == capacity_ctrl \&\& size() \<= capacity_ctrl.capacity()</code><br><br> - If the current number of elements stored in the <code>circular_buffer_space_optimized</code> is greater - than the desired new capacity then number of <code>[size() - capacity_ctrl.capacity()]</code> <b>last</b> - elements will be removed and the new size will be equal to <code>capacity_ctrl.capacity()</code>.<br><br> - If the current number of elements stored in the <code>circular_buffer_space_optimized</code> is lower - than the new capacity then the amount of allocated memory in the internal buffer may be accommodated as - necessary but it will never drop below <code>capacity_ctrl.min_capacity()</code>. - \param capacity_ctrl The new capacity controller. - \throws "An allocation error" if memory is exhausted, (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept. - \par Exception Safety - Strong. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in <code>min[size(), capacity_ctrl.%capacity()]</code>). - \note To explicitly clear the extra allocated memory use the <b>shrink-to-fit</b> technique:<br><br> - <code>%boost::%circular_buffer_space_optimized\<int\> cb(1000);<br> - ...<br> - %boost::%circular_buffer_space_optimized\<int\>(cb).swap(cb);</code><br><br> - For more information about the shrink-to-fit technique in STL see - <a href="http://www.gotw.ca/gotw/054.htm">http://www.gotw.ca/gotw/054.htm</a>. - \sa <code>rset_capacity(const capacity_type&)</code>, - <code>\link resize() resize(size_type, const_reference)\endlink</code> - */ - void set_capacity(const capacity_type& capacity_ctrl) { - m_capacity_ctrl = capacity_ctrl; - if (capacity_ctrl < size()) { - iterator e = end(); - circular_buffer<T, Alloc>::erase(e - (size() - capacity_ctrl), e); - } - adjust_min_capacity(); - } - - //! Change the size of the <code>circular_buffer_space_optimized</code>. - /*! - \post <code>size() == new_size \&\& capacity().%capacity() >= new_size</code><br><br> - If the new size is greater than the current size, copies of <code>item</code> will be inserted at the - <b>back</b> of the of the <code>circular_buffer_space_optimized</code> in order to achieve the desired - size. In the case the resulting size exceeds the current capacity the capacity will be set to - <code>new_size</code>.<br><br> - If the current number of elements stored in the <code>circular_buffer_space_optimized</code> is greater - than the desired new size then number of <code>[size() - new_size]</code> <b>last</b> elements will be - removed. (The capacity will remain unchanged.)<br><br> - The amount of allocated memory in the internal buffer may be accommodated as necessary. - \param new_size The new size. - \param item The element the <code>circular_buffer_space_optimized</code> will be filled with in order to gain - the requested size. (See the <i>Effect</i>.) - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the new size of the <code>circular_buffer_space_optimized</code>). - \sa <code>\link rresize() rresize(size_type, const_reference)\endlink</code>, - <code>set_capacity(const capacity_type&)</code> - */ - void resize(size_type new_size, param_value_type item = value_type()) { - if (new_size > size()) { - if (new_size > m_capacity_ctrl) - m_capacity_ctrl = capacity_type(new_size, m_capacity_ctrl.min_capacity()); - insert(end(), new_size - size(), item); - } else { - iterator e = end(); - erase(e - (size() - new_size), e); - } - } - - /*! \brief Change the capacity (and the minimal guaranteed amount of allocated memory) of the - <code>circular_buffer_space_optimized</code>. - \post <code>capacity() == capacity_ctrl \&\& size() \<= capacity_ctrl</code><br><br> - If the current number of elements stored in the <code>circular_buffer_space_optimized</code> is greater - than the desired new capacity then number of <code>[size() - capacity_ctrl.capacity()]</code> - <b>first</b> elements will be removed and the new size will be equal to - <code>capacity_ctrl.capacity()</code>.<br><br> - If the current number of elements stored in the <code>circular_buffer_space_optimized</code> is lower - than the new capacity then the amount of allocated memory in the internal buffer may be accommodated as - necessary but it will never drop below <code>capacity_ctrl.min_capacity()</code>. - \param capacity_ctrl The new capacity controller. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept. - \par Exception Safety - Strong. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in <code>min[size(), capacity_ctrl.%capacity()]</code>). - \sa <code>set_capacity(const capacity_type&)</code>, - <code>\link rresize() rresize(size_type, const_reference)\endlink</code> - */ - void rset_capacity(const capacity_type& capacity_ctrl) { - m_capacity_ctrl = capacity_ctrl; - if (capacity_ctrl < size()) { - iterator b = begin(); - circular_buffer<T, Alloc>::rerase(b, b + (size() - capacity_ctrl)); - } - adjust_min_capacity(); - } - - //! Change the size of the <code>circular_buffer_space_optimized</code>. - /*! - \post <code>size() == new_size \&\& capacity().%capacity() >= new_size</code><br><br> - If the new size is greater than the current size, copies of <code>item</code> will be inserted at the - <b>front</b> of the of the <code>circular_buffer_space_optimized</code> in order to achieve the desired - size. In the case the resulting size exceeds the current capacity the capacity will be set to - <code>new_size</code>.<br><br> - If the current number of elements stored in the <code>circular_buffer_space_optimized</code> is greater - than the desired new size then number of <code>[size() - new_size]</code> <b>first</b> elements will be - removed. (The capacity will remain unchanged.)<br><br> - The amount of allocated memory in the internal buffer may be accommodated as necessary. - \param new_size The new size. - \param item The element the <code>circular_buffer_space_optimized</code> will be filled with in order to gain - the requested size. (See the <i>Effect</i>.) - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the new size of the <code>circular_buffer_space_optimized</code>). - \sa <code>\link resize() resize(size_type, const_reference)\endlink</code>, - <code>rset_capacity(const capacity_type&)</code> - */ - void rresize(size_type new_size, param_value_type item = value_type()) { - if (new_size > size()) { - if (new_size > m_capacity_ctrl) - m_capacity_ctrl = capacity_type(new_size, m_capacity_ctrl.min_capacity()); - rinsert(begin(), new_size - size(), item); - } else { - rerase(begin(), end() - new_size); - } - } - - //! Create an empty space optimized circular buffer with zero capacity. - /*! - \post <code>capacity().%capacity() == 0 \&\& capacity().min_capacity() == 0 \&\& size() == 0</code> - \param alloc The allocator. - \throws Nothing. - \par Complexity - Constant. - \warning Since Boost version 1.36 the behaviour of this constructor has changed. Now it creates a space - optimized circular buffer with zero capacity. - */ - explicit circular_buffer_space_optimized(const allocator_type& alloc = allocator_type()) BOOST_NOEXCEPT - : circular_buffer<T, Alloc>(0, alloc) - , m_capacity_ctrl(0) {} - - //! Create an empty space optimized circular buffer with the specified capacity. - /*! - \post <code>capacity() == capacity_ctrl \&\& size() == 0</code><br><br> - The amount of allocated memory in the internal buffer is <code>capacity_ctrl.min_capacity()</code>. - \param capacity_ctrl The capacity controller representing the maximum number of elements which can be stored in - the <code>circular_buffer_space_optimized</code> and the minimal allocated size of the - internal buffer. - \param alloc The allocator. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - \par Complexity - Constant. - */ - explicit circular_buffer_space_optimized(capacity_type capacity_ctrl, - const allocator_type& alloc = allocator_type()) - : circular_buffer<T, Alloc>(capacity_ctrl.min_capacity(), alloc) - , m_capacity_ctrl(capacity_ctrl) {} - - /*! \brief Create a full space optimized circular buffer with the specified capacity filled with - <code>capacity_ctrl.%capacity()</code> copies of <code>item</code>. - \post <code>capacity() == capacity_ctrl \&\& full() \&\& (*this)[0] == item \&\& (*this)[1] == item \&\& ... - \&\& (*this) [capacity_ctrl.%capacity() - 1] == item </code><br><br> - The amount of allocated memory in the internal buffer is <code>capacity_ctrl.capacity()</code>. - \param capacity_ctrl The capacity controller representing the maximum number of elements which can be stored in - the <code>circular_buffer_space_optimized</code> and the minimal allocated size of the - internal buffer. - \param item The element the created <code>circular_buffer_space_optimized</code> will be filled with. - \param alloc The allocator. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - \throws Whatever <code>T::T(const T&)</code> throws. - \par Complexity - Linear (in the <code>capacity_ctrl.%capacity()</code>). - */ - circular_buffer_space_optimized(capacity_type capacity_ctrl, param_value_type item, - const allocator_type& alloc = allocator_type()) - : circular_buffer<T, Alloc>(capacity_ctrl.capacity(), item, alloc) - , m_capacity_ctrl(capacity_ctrl) {} - - /*! \brief Create a space optimized circular buffer with the specified capacity filled with <code>n</code> copies - of <code>item</code>. - \pre <code>capacity_ctrl.%capacity() >= n</code> - \post <code>capacity() == capacity_ctrl \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item - \&\& ... \&\& (*this)[n - 1] == item</code><br><br> - The amount of allocated memory in the internal buffer is - <code>max[n, capacity_ctrl.min_capacity()]</code>. - \param capacity_ctrl The capacity controller representing the maximum number of elements which can be stored in - the <code>circular_buffer_space_optimized</code> and the minimal allocated size of the - internal buffer. - \param n The number of elements the created <code>circular_buffer_space_optimized</code> will be filled with. - \param item The element the created <code>circular_buffer_space_optimized</code> will be filled with. - \param alloc The allocator. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Complexity - Linear (in the <code>n</code>). - */ - circular_buffer_space_optimized(capacity_type capacity_ctrl, size_type n, param_value_type item, - const allocator_type& alloc = allocator_type()) - : circular_buffer<T, Alloc>(init_capacity(capacity_ctrl, n), n, item, alloc) - , m_capacity_ctrl(capacity_ctrl) {} - - //! The copy constructor. - /*! - Creates a copy of the specified <code>circular_buffer_space_optimized</code>. - \post <code>*this == cb</code><br><br> - The amount of allocated memory in the internal buffer is <code>cb.size()</code>. - \param cb The <code>circular_buffer_space_optimized</code> to be copied. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Complexity - Linear (in the size of <code>cb</code>). - */ - circular_buffer_space_optimized(const circular_buffer_space_optimized<T, Alloc>& cb) - : circular_buffer<T, Alloc>(cb.begin(), cb.end(), cb.get_allocator()) - , m_capacity_ctrl(cb.m_capacity_ctrl) {} - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - //! The move constructor. - /*! \brief Move constructs a <code>circular_buffer_space_optimized</code> from <code>cb</code>, - leaving <code>cb</code> empty. - \pre C++ compiler with rvalue references support. - \post <code>cb.empty()</code> - \param cb <code>circular_buffer</code> to 'steal' value from. - \throws Nothing. - \par Constant. - */ - circular_buffer_space_optimized(circular_buffer_space_optimized<T, Alloc>&& cb) BOOST_NOEXCEPT - : circular_buffer<T, Alloc>() - , m_capacity_ctrl(0) { - cb.swap(*this); - } -#endif // BOOST_NO_CXX11_RVALUE_REFERENCES - - //! Create a full space optimized circular buffer filled with a copy of the range. - /*! - \pre Valid range <code>[first, last)</code>.<br> - <code>first</code> and <code>last</code> have to meet the requirements of - <a href="https://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>. - \post <code>capacity().%capacity() == std::distance(first, last) \&\& capacity().min_capacity() == 0 \&\& - full() \&\& (*this)[0]== *first \&\& (*this)[1] == *(first + 1) \&\& ... \&\& - (*this)[std::distance(first, last) - 1] == *(last - 1)</code><br><br> - The amount of allocated memory in the internal buffer is <code>std::distance(first, last)</code>. - \param first The beginning of the range to be copied. - \param last The end of the range to be copied. - \param alloc The allocator. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept - and <code>InputIterator</code> is a move iterator. - \par Complexity - Linear (in the <code>std::distance(first, last)</code>). - */ - template <class InputIterator> - circular_buffer_space_optimized(InputIterator first, InputIterator last, - const allocator_type& alloc = allocator_type()) - : circular_buffer<T, Alloc>(first, last, alloc) - , m_capacity_ctrl(circular_buffer<T, Alloc>::capacity()) {} - - /*! \brief Create a space optimized circular buffer with the specified capacity (and the minimal guaranteed amount - of allocated memory) filled with a copy of the range. - \pre Valid range <code>[first, last)</code>.<br> - <code>first</code> and <code>last</code> have to meet the requirements of - <a href="https://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>. - \post <code>capacity() == capacity_ctrl \&\& size() \<= std::distance(first, last) \&\& (*this)[0]== - *(last - capacity_ctrl.%capacity()) \&\& (*this)[1] == *(last - capacity_ctrl.%capacity() + 1) \&\& ... - \&\& (*this)[capacity_ctrl.%capacity() - 1] == *(last - 1)</code><br><br> - If the number of items to be copied from the range <code>[first, last)</code> is greater than the - specified <code>capacity_ctrl.%capacity()</code> then only elements from the range - <code>[last - capacity_ctrl.%capacity(), last)</code> will be copied.<br><br> - The amount of allocated memory in the internal buffer is <code>max[capacity_ctrl.min_capacity(), - min[capacity_ctrl.%capacity(), std::distance(first, last)]]</code>. - \param capacity_ctrl The capacity controller representing the maximum number of elements which can be stored in - the <code>circular_buffer_space_optimized</code> and the minimal allocated size of the - internal buffer. - \param first The beginning of the range to be copied. - \param last The end of the range to be copied. - \param alloc The allocator. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Complexity - Linear (in <code>std::distance(first, last)</code>; in - <code>min[capacity_ctrl.%capacity(), std::distance(first, last)]</code> if the <code>InputIterator</code> - is a <a href="https://www.boost.org/sgi/stl/RandomAccessIterator.html">RandomAccessIterator</a>). - */ - template <class InputIterator> - circular_buffer_space_optimized(capacity_type capacity_ctrl, InputIterator first, InputIterator last, - const allocator_type& alloc = allocator_type()) - : circular_buffer<T, Alloc>( - init_capacity(capacity_ctrl, first, last, is_integral<InputIterator>()), - first, last, alloc) - , m_capacity_ctrl(capacity_ctrl) { - reduce_capacity( - is_same< BOOST_DEDUCED_TYPENAME std::iterator_traits<InputIterator>::iterator_category, std::input_iterator_tag >()); - } - -#if defined(BOOST_CB_NEVER_DEFINED) -// This section will never be compiled - the default destructor will be generated instead. -// Declared only for documentation purpose. - - //! The destructor. - /*! - Destroys the <code>circular_buffer_space_optimized</code>. - \throws Nothing. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (including - iterators equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>clear()</code> - */ - ~circular_buffer_space_optimized(); - - //! no-comment - void erase_begin(size_type n); - - //! no-comment - void erase_end(size_type n); - -#endif // #if defined(BOOST_CB_NEVER_DEFINED) - - //! The assign operator. - /*! - Makes this <code>circular_buffer_space_optimized</code> to become a copy of the specified - <code>circular_buffer_space_optimized</code>. - \post <code>*this == cb</code><br><br> - The amount of allocated memory in the internal buffer is <code>cb.size()</code>. - \param cb The <code>circular_buffer_space_optimized</code> to be copied. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - \throws Whatever <code>T::T(const T&)</code> throws. - \par Exception Safety - Strong. - \par Iterator Invalidation - Invalidates all iterators pointing to this <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of <code>cb</code>). - \sa <code>\link assign(size_type, param_value_type) assign(size_type, const_reference)\endlink</code>, - <code>\link assign(capacity_type, size_type, param_value_type) - assign(capacity_type, size_type, const_reference)\endlink</code>, - <code>assign(InputIterator, InputIterator)</code>, - <code>assign(capacity_type, InputIterator, InputIterator)</code> - */ - circular_buffer_space_optimized<T, Alloc>& operator = (const circular_buffer_space_optimized<T, Alloc>& cb) { - if (this == &cb) - return *this; - circular_buffer<T, Alloc>::assign(cb.begin(), cb.end()); - m_capacity_ctrl = cb.m_capacity_ctrl; - return *this; - } - -#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - /*! \brief Move assigns content of <code>cb</code> to <code>*this</code>, leaving <code>cb</code> empty. - \pre C++ compiler with rvalue references support. - \post <code>cb.empty()</code> - \param cb <code>circular_buffer</code> to 'steal' value from. - \throws Nothing. - \par Complexity - Constant. - */ - circular_buffer_space_optimized<T, Alloc>& operator = (circular_buffer_space_optimized<T, Alloc>&& cb) BOOST_NOEXCEPT { - cb.swap(*this); // now `this` holds `cb` - circular_buffer<T, Alloc>(get_allocator()) // temporary that holds initial `cb` allocator - .swap(cb); // makes `cb` empty - return *this; - } -#endif // BOOST_NO_CXX11_RVALUE_REFERENCES - - - //! Assign <code>n</code> items into the space optimized circular buffer. - /*! - The content of the <code>circular_buffer_space_optimized</code> will be removed and replaced with - <code>n</code> copies of the <code>item</code>. - \post <code>capacity().%capacity() == n \&\& capacity().min_capacity() == 0 \&\& size() == n \&\& (*this)[0] == - item \&\& (*this)[1] == item \&\& ... \&\& (*this) [n - 1] == item</code><br><br> - The amount of allocated memory in the internal buffer is <code>n</code>. - \param n The number of elements the <code>circular_buffer_space_optimized</code> will be filled with. - \param item The element the <code>circular_buffer_space_optimized</code> will be filled with. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the <code>n</code>). - \sa <code>\link operator=(const circular_buffer_space_optimized&) operator=\endlink</code>, - <code>\link assign(capacity_type, size_type, param_value_type) - assign(capacity_type, size_type, const_reference)\endlink</code>, - <code>assign(InputIterator, InputIterator)</code>, - <code>assign(capacity_type, InputIterator, InputIterator)</code> - */ - void assign(size_type n, param_value_type item) { - circular_buffer<T, Alloc>::assign(n, item); - m_capacity_ctrl = capacity_type(n); - } - - //! Assign <code>n</code> items into the space optimized circular buffer specifying the capacity. - /*! - The capacity of the <code>circular_buffer_space_optimized</code> will be set to the specified value and the - content of the <code>circular_buffer_space_optimized</code> will be removed and replaced with <code>n</code> - copies of the <code>item</code>. - \pre <code>capacity_ctrl.%capacity() >= n</code> - \post <code>capacity() == capacity_ctrl \&\& size() == n \&\& (*this)[0] == item \&\& (*this)[1] == item - \&\& ... \&\& (*this) [n - 1] == item </code><br><br> - The amount of allocated memory will be <code>max[n, capacity_ctrl.min_capacity()]</code>. - \param capacity_ctrl The new capacity controller. - \param n The number of elements the <code>circular_buffer_space_optimized</code> will be filled with. - \param item The element the <code>circular_buffer_space_optimized</code> will be filled with. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the <code>n</code>). - \sa <code>\link operator=(const circular_buffer_space_optimized&) operator=\endlink</code>, - <code>\link assign(size_type, param_value_type) assign(size_type, const_reference)\endlink</code>, - <code>assign(InputIterator, InputIterator)</code>, - <code>assign(capacity_type, InputIterator, InputIterator)</code> - */ - void assign(capacity_type capacity_ctrl, size_type n, param_value_type item) { - BOOST_CB_ASSERT(capacity_ctrl.capacity() >= n); // check for new capacity lower than n - circular_buffer<T, Alloc>::assign((std::max)(capacity_ctrl.min_capacity(), n), n, item); - m_capacity_ctrl = capacity_ctrl; - } - - //! Assign a copy of the range into the space optimized circular buffer. - /*! - The content of the <code>circular_buffer_space_optimized</code> will be removed and replaced with copies of - elements from the specified range. - \pre Valid range <code>[first, last)</code>.<br> - <code>first</code> and <code>last</code> have to meet the requirements of - <a href="https://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>. - \post <code>capacity().%capacity() == std::distance(first, last) \&\& capacity().min_capacity() == 0 \&\& - size() == std::distance(first, last) \&\& (*this)[0]== *first \&\& (*this)[1] == *(first + 1) \&\& ... - \&\& (*this)[std::distance(first, last) - 1] == *(last - 1)</code><br><br> - The amount of allocated memory in the internal buffer is <code>std::distance(first, last)</code>. - \param first The beginning of the range to be copied. - \param last The end of the range to be copied. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept and - <code>InputIterator</code> is a move iterator. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the <code>std::distance(first, last)</code>). - \sa <code>\link operator=(const circular_buffer_space_optimized&) operator=\endlink</code>, - <code>\link assign(size_type, param_value_type) assign(size_type, const_reference)\endlink</code>, - <code>\link assign(capacity_type, size_type, param_value_type) - assign(capacity_type, size_type, const_reference)\endlink</code>, - <code>assign(capacity_type, InputIterator, InputIterator)</code> - */ - template <class InputIterator> - void assign(InputIterator first, InputIterator last) { - circular_buffer<T, Alloc>::assign(first, last); - m_capacity_ctrl = capacity_type(circular_buffer<T, Alloc>::capacity()); - } - - //! Assign a copy of the range into the space optimized circular buffer specifying the capacity. - /*! - The capacity of the <code>circular_buffer_space_optimized</code> will be set to the specified value and the - content of the <code>circular_buffer_space_optimized</code> will be removed and replaced with copies of - elements from the specified range. - \pre Valid range <code>[first, last)</code>.<br> - <code>first</code> and <code>last</code> have to meet the requirements of - <a href="https://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>. - \post <code>capacity() == capacity_ctrl \&\& size() \<= std::distance(first, last) \&\& - (*this)[0]== *(last - capacity) \&\& (*this)[1] == *(last - capacity + 1) \&\& ... \&\& - (*this)[capacity - 1] == *(last - 1)</code><br><br> - If the number of items to be copied from the range <code>[first, last)</code> is greater than the - specified <code>capacity</code> then only elements from the range <code>[last - capacity, last)</code> - will be copied.<br><br> The amount of allocated memory in the internal buffer is - <code>max[std::distance(first, last), capacity_ctrl.min_capacity()]</code>. - \param capacity_ctrl The new capacity controller. - \param first The beginning of the range to be copied. - \param last The end of the range to be copied. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept and - <code>InputIterator</code> is a move iterator. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in <code>std::distance(first, last)</code>; in - <code>min[capacity_ctrl.%capacity(), std::distance(first, last)]</code> if the <code>InputIterator</code> - is a <a href="https://www.boost.org/sgi/stl/RandomAccessIterator.html">RandomAccessIterator</a>). - \sa <code>\link operator=(const circular_buffer_space_optimized&) operator=\endlink</code>, - <code>\link assign(size_type, param_value_type) assign(size_type, const_reference)\endlink</code>, - <code>\link assign(capacity_type, size_type, param_value_type) - assign(capacity_type, size_type, const_reference)\endlink</code>, - <code>assign(InputIterator, InputIterator)</code> - */ - template <class InputIterator> - void assign(capacity_type capacity_ctrl, InputIterator first, InputIterator last) { - m_capacity_ctrl = capacity_ctrl; - circular_buffer<T, Alloc>::assign(capacity_ctrl, first, last); - } - - //! Swap the contents of two space-optimized circular-buffers. - /*! - \post <code>this</code> contains elements of <code>cb</code> and vice versa; the capacity and the amount of - allocated memory in the internal buffer of <code>this</code> equal to the capacity and the amount of - allocated memory of <code>cb</code> and vice versa. - \param cb The <code>circular_buffer_space_optimized</code> whose content will be swapped. - \throws Nothing. - \par Exception Safety - No-throw. - \par Iterator Invalidation - Invalidates all iterators of both <code>circular_buffer_space_optimized</code> containers. (On the other - hand the iterators still point to the same elements but within another container. If you want to rely on - this feature you have to turn the __debug_support off, - otherwise an assertion will report an error if such invalidated iterator is used.) - \par Complexity - Constant (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>swap(circular_buffer<T, Alloc>&, circular_buffer<T, Alloc>&)</code>, - <code>swap(circular_buffer_space_optimized<T, Alloc>&, circular_buffer_space_optimized<T, Alloc>&)</code> - - - */ - // Note link does not work right. Asked on Doxygen forum for advice 23 May 2103. - - void swap(circular_buffer_space_optimized<T, Alloc>& cb) BOOST_NOEXCEPT { - std::swap(m_capacity_ctrl, cb.m_capacity_ctrl); - circular_buffer<T, Alloc>::swap(cb); - } - - //! Insert a new element at the end of the space optimized circular buffer. - /*! - \post if <code>capacity().%capacity() > 0</code> then <code>back() == item</code><br> - If the <code>circular_buffer_space_optimized</code> is full, the first element will be removed. If the - capacity is <code>0</code>, nothing will be inserted.<br><br> - The amount of allocated memory in the internal buffer may be predictively increased. - \param item The element to be inserted. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>\link push_front() push_front(const_reference)\endlink</code>, <code>pop_back()</code>, - <code>pop_front()</code> - */ - void push_back(param_value_type item) { - check_low_capacity(); - circular_buffer<T, Alloc>::push_back(item); - } - - //! Insert a new element at the end of the space optimized circular buffer. - /*! - \post if <code>capacity().%capacity() > 0</code> then <code>back() == item</code><br> - If the <code>circular_buffer_space_optimized</code> is full, the first element will be removed. If the - capacity is <code>0</code>, nothing will be inserted.<br><br> - The amount of allocated memory in the internal buffer may be predictively increased. - \param item The element to be inserted. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>\link push_front() push_front(const_reference)\endlink</code>, <code>pop_back()</code>, - <code>pop_front()</code> - */ - void push_back(rvalue_type item) { - check_low_capacity(); - circular_buffer<T, Alloc>::push_back(boost::move(item)); - } - - //! Insert a new element at the end of the space optimized circular buffer. - /*! - \post if <code>capacity().%capacity() > 0</code> then <code>back() == item</code><br> - If the <code>circular_buffer_space_optimized</code> is full, the first element will be removed. If the - capacity is <code>0</code>, nothing will be inserted.<br><br> - The amount of allocated memory in the internal buffer may be predictively increased. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T()</code> throws. - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>\link push_front() push_front(const_reference)\endlink</code>, <code>pop_back()</code>, - <code>pop_front()</code> - */ - void push_back() { - check_low_capacity(); - circular_buffer<T, Alloc>::push_back(); - } - - //! Insert a new element at the beginning of the space optimized circular buffer. - /*! - \post if <code>capacity().%capacity() > 0</code> then <code>front() == item</code><br> - If the <code>circular_buffer_space_optimized</code> is full, the last element will be removed. If the - capacity is <code>0</code>, nothing will be inserted.<br><br> - The amount of allocated memory in the internal buffer may be predictively increased. - \param item The element to be inserted. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>\link push_back() push_back(const_reference)\endlink</code>, <code>pop_back()</code>, - <code>pop_front()</code> - */ - void push_front(param_value_type item) { - check_low_capacity(); - circular_buffer<T, Alloc>::push_front(item); - } - - //! Insert a new element at the beginning of the space optimized circular buffer. - /*! - \post if <code>capacity().%capacity() > 0</code> then <code>front() == item</code><br> - If the <code>circular_buffer_space_optimized</code> is full, the last element will be removed. If the - capacity is <code>0</code>, nothing will be inserted.<br><br> - The amount of allocated memory in the internal buffer may be predictively increased. - \param item The element to be inserted. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>\link push_back() push_back(const_reference)\endlink</code>, <code>pop_back()</code>, - <code>pop_front()</code> - */ - void push_front(rvalue_type item) { - check_low_capacity(); - circular_buffer<T, Alloc>::push_front(boost::move(item)); - } - - //! Insert a new element at the beginning of the space optimized circular buffer. - /*! - \post if <code>capacity().%capacity() > 0</code> then <code>front() == item</code><br> - If the <code>circular_buffer_space_optimized</code> is full, the last element will be removed. If the - capacity is <code>0</code>, nothing will be inserted.<br><br> - The amount of allocated memory in the internal buffer may be predictively increased. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T()</code> throws. - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>\link push_back() push_back(const_reference)\endlink</code>, <code>pop_back()</code>, - <code>pop_front()</code> - */ - void push_front() { - check_low_capacity(); - circular_buffer<T, Alloc>::push_front(); - } - - //! Remove the last element from the space optimized circular buffer. - /*! - \pre <code>!empty()</code> - \post The last element is removed from the <code>circular_buffer_space_optimized</code>.<br><br> - The amount of allocated memory in the internal buffer may be predictively decreased. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>pop_front()</code>, <code>\link push_back() push_back(const_reference)\endlink</code>, - <code>\link push_front() push_front(const_reference)\endlink</code> - */ - void pop_back() { - circular_buffer<T, Alloc>::pop_back(); - check_high_capacity(); - } - - //! Remove the first element from the space optimized circular buffer. - /*! - \pre <code>!empty()</code> - \post The first element is removed from the <code>circular_buffer_space_optimized</code>.<br><br> - The amount of allocated memory in the internal buffer may be predictively decreased. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>pop_back()</code>, <code>\link push_back() push_back(const_reference)\endlink</code>, - <code>\link push_front() push_front(const_reference)\endlink</code> - */ - void pop_front() { - circular_buffer<T, Alloc>::pop_front(); - check_high_capacity(); - } - - //! Insert an element at the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer_space_optimized</code> or its - end. - \post The <code>item</code> will be inserted at the position <code>pos</code>.<br> - If the <code>circular_buffer_space_optimized</code> is full, the first element will be overwritten. If - the <code>circular_buffer_space_optimized</code> is full and the <code>pos</code> points to - <code>begin()</code>, then the <code>item</code> will not be inserted. If the capacity is <code>0</code>, - nothing will be inserted.<br><br> - The amount of allocated memory in the internal buffer may be predictively increased. - \param pos An iterator specifying the position where the <code>item</code> will be inserted. - \param item The element to be inserted. - \return Iterator to the inserted element or <code>begin()</code> if the <code>item</code> is not inserted. (See - the <i>Effect</i>.) - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - Whatever <code>T::operator = (const T&)</code> throws. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code>, - <code>\link rinsert(iterator, param_value_type) rinsert(iterator, value_type)\endlink</code>, - <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code> - */ - iterator insert(iterator pos, param_value_type item) { - size_type index = pos - begin(); - check_low_capacity(); - return circular_buffer<T, Alloc>::insert(begin() + index, item); - } - - //! Insert an element at the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer_space_optimized</code> or its - end. - \post The <code>item</code> will be inserted at the position <code>pos</code>.<br> - If the <code>circular_buffer_space_optimized</code> is full, the first element will be overwritten. If - the <code>circular_buffer_space_optimized</code> is full and the <code>pos</code> points to - <code>begin()</code>, then the <code>item</code> will not be inserted. If the capacity is <code>0</code>, - nothing will be inserted.<br><br> - The amount of allocated memory in the internal buffer may be predictively increased. - \param pos An iterator specifying the position where the <code>item</code> will be inserted. - \param item The element to be inserted. - \return Iterator to the inserted element or <code>begin()</code> if the <code>item</code> is not inserted. (See - the <i>Effect</i>.) - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code>, - <code>\link rinsert(iterator, param_value_type) rinsert(iterator, value_type)\endlink</code>, - <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code> - */ - iterator insert(iterator pos, rvalue_type item) { - size_type index = pos - begin(); - check_low_capacity(); - return circular_buffer<T, Alloc>::insert(begin() + index, boost::move(item)); - } - - //! Insert an element at the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer_space_optimized</code> or its - end. - \post The <code>item</code> will be inserted at the position <code>pos</code>.<br> - If the <code>circular_buffer_space_optimized</code> is full, the first element will be overwritten. If - the <code>circular_buffer_space_optimized</code> is full and the <code>pos</code> points to - <code>begin()</code>, then the <code>item</code> will not be inserted. If the capacity is <code>0</code>, - nothing will be inserted.<br><br> - The amount of allocated memory in the internal buffer may be predictively increased. - \param pos An iterator specifying the position where the <code>item</code> will be inserted. - \return Iterator to the inserted element or <code>begin()</code> if the <code>item</code> is not inserted. (See - the <i>Effect</i>.) - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T()</code> throws. - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code>, - <code>\link rinsert(iterator, param_value_type) rinsert(iterator, value_type)\endlink</code>, - <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code> - */ - iterator insert(iterator pos) { - size_type index = pos - begin(); - check_low_capacity(); - return circular_buffer<T, Alloc>::insert(begin() + index); - } - - //! Insert <code>n</code> copies of the <code>item</code> at the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer_space_optimized</code> or its - end. - \post The number of <code>min[n, (pos - begin()) + reserve()]</code> elements will be inserted at the position - <code>pos</code>.<br>The number of <code>min[pos - begin(), max[0, n - reserve()]]</code> elements will - be overwritten at the beginning of the <code>circular_buffer_space_optimized</code>.<br>(See - <i>Example</i> for the explanation.)<br><br> - The amount of allocated memory in the internal buffer may be predictively increased. - \param pos An iterator specifying the position where the <code>item</code>s will be inserted. - \param n The number of <code>item</code>s the to be inserted. - \param item The element whose copies will be inserted. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - Whatever <code>T::operator = (const T&)</code> throws. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in <code>min[capacity().%capacity(), size() + n]</code>). - \par Example - Consider a <code>circular_buffer_space_optimized</code> with the capacity of 6 and the size of 4. Its - internal buffer may look like the one below.<br><br> - <code>|1|2|3|4| | |</code><br> - <code>p ___^</code><br><br>After inserting 5 elements at the position <code>p</code>:<br><br> - <code>insert(p, (size_t)5, 0);</code><br><br>actually only 4 elements get inserted and elements - <code>1</code> and <code>2</code> are overwritten. This is due to the fact the insert operation preserves - the capacity. After insertion the internal buffer looks like this:<br><br><code>|0|0|0|0|3|4|</code><br> - <br>For comparison if the capacity would not be preserved the internal buffer would then result in - <code>|1|2|0|0|0|0|0|3|4|</code>. - \sa <code>\link insert(iterator, param_value_type) insert(iterator, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code>, - <code>\link rinsert(iterator, param_value_type) rinsert(iterator, value_type)\endlink</code>, - <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code> - */ - void insert(iterator pos, size_type n, param_value_type item) { - size_type index = pos - begin(); - check_low_capacity(n); - circular_buffer<T, Alloc>::insert(begin() + index, n, item); - } - - //! Insert the range <code>[first, last)</code> at the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer_space_optimized</code> or its - end.<br>Valid range <code>[first, last)</code> where <code>first</code> and <code>last</code> meet the - requirements of an <a href="https://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>. - \post Elements from the range - <code>[first + max[0, distance(first, last) - (pos - begin()) - reserve()], last)</code> will be - inserted at the position <code>pos</code>.<br>The number of <code>min[pos - begin(), max[0, - distance(first, last) - reserve()]]</code> elements will be overwritten at the beginning of the - <code>circular_buffer_space_optimized</code>.<br>(See <i>Example</i> for the explanation.)<br><br> - The amount of allocated memory in the internal buffer may be predictively increased. - \param pos An iterator specifying the position where the range will be inserted. - \param first The beginning of the range to be inserted. - \param last The end of the range to be inserted. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in <code>[size() + std::distance(first, last)]</code>; in - <code>min[capacity().%capacity(), size() + std::distance(first, last)]</code> if the - <code>InputIterator</code> is a - <a href="https://www.boost.org/sgi/stl/RandomAccessIterator.html">RandomAccessIterator</a>). - \par Example - Consider a <code>circular_buffer_space_optimized</code> with the capacity of 6 and the size of 4. Its - internal buffer may look like the one below.<br><br> - <code>|1|2|3|4| | |</code><br> - <code>p ___^</code><br><br>After inserting a range of elements at the position <code>p</code>:<br><br> - <code>int array[] = { 5, 6, 7, 8, 9 };</code><br><code>insert(p, array, array + 5);</code><br><br> - actually only elements <code>6</code>, <code>7</code>, <code>8</code> and <code>9</code> from the - specified range get inserted and elements <code>1</code> and <code>2</code> are overwritten. This is due - to the fact the insert operation preserves the capacity. After insertion the internal buffer looks like - this:<br><br><code>|6|7|8|9|3|4|</code><br><br>For comparison if the capacity would not be preserved the - internal buffer would then result in <code>|1|2|5|6|7|8|9|3|4|</code>. - \sa <code>\link insert(iterator, param_value_type) insert(iterator, value_type)\endlink</code>, - <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, <code>\link rinsert(iterator, param_value_type) - rinsert(iterator, value_type)\endlink</code>, <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code> - */ - template <class InputIterator> - void insert(iterator pos, InputIterator first, InputIterator last) { - insert(pos, first, last, is_integral<InputIterator>()); - } - - //! Insert an element before the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer_space_optimized</code> or its - end. - \post The <code>item</code> will be inserted before the position <code>pos</code>.<br> - If the <code>circular_buffer_space_optimized</code> is full, the last element will be overwritten. If the - <code>circular_buffer_space_optimized</code> is full and the <code>pos</code> points to - <code>end()</code>, then the <code>item</code> will not be inserted. If the capacity is <code>0</code>, - nothing will be inserted.<br><br> - The amount of allocated memory in the internal buffer may be predictively increased. - \param pos An iterator specifying the position before which the <code>item</code> will be inserted. - \param item The element to be inserted. - \return Iterator to the inserted element or <code>end()</code> if the <code>item</code> is not inserted. (See - the <i>Effect</i>.) - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - Whatever <code>T::operator = (const T&)</code> throws. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code>, - <code>\link insert(iterator, param_value_type) insert(iterator, value_type)\endlink</code>, - <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code> - */ - iterator rinsert(iterator pos, param_value_type item) { - size_type index = pos - begin(); - check_low_capacity(); - return circular_buffer<T, Alloc>::rinsert(begin() + index, item); - } - - //! Insert an element before the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer_space_optimized</code> or its - end. - \post The <code>item</code> will be inserted before the position <code>pos</code>.<br> - If the <code>circular_buffer_space_optimized</code> is full, the last element will be overwritten. If the - <code>circular_buffer_space_optimized</code> is full and the <code>pos</code> points to - <code>end()</code>, then the <code>item</code> will not be inserted. If the capacity is <code>0</code>, - nothing will be inserted.<br><br> - The amount of allocated memory in the internal buffer may be predictively increased. - \param pos An iterator specifying the position before which the <code>item</code> will be inserted. - \param item The element to be inserted. - \return Iterator to the inserted element or <code>end()</code> if the <code>item</code> is not inserted. (See - the <i>Effect</i>.) - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code>, - <code>\link insert(iterator, param_value_type) insert(iterator, value_type)\endlink</code>, - <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code> - */ - iterator rinsert(iterator pos, rvalue_type item) { - size_type index = pos - begin(); - check_low_capacity(); - return circular_buffer<T, Alloc>::rinsert(begin() + index, boost::move(item)); - } - - //! Insert an element before the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer_space_optimized</code> or its - end. - \post The <code>item</code> will be inserted before the position <code>pos</code>.<br> - If the <code>circular_buffer_space_optimized</code> is full, the last element will be overwritten. If the - <code>circular_buffer_space_optimized</code> is full and the <code>pos</code> points to - <code>end()</code>, then the <code>item</code> will not be inserted. If the capacity is <code>0</code>, - nothing will be inserted.<br><br> - The amount of allocated memory in the internal buffer may be predictively increased. - \param pos An iterator specifying the position before which the <code>item</code> will be inserted. - \return Iterator to the inserted element or <code>end()</code> if the <code>item</code> is not inserted. (See - the <i>Effect</i>.) - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T()</code> throws. - Whatever <code>T::T(const T&)</code> throws or nothing if <code>T::T(T&&)</code> is noexcept. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code>, - <code>\link insert(iterator, param_value_type) insert(iterator, value_type)\endlink</code>, - <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code> - */ - iterator rinsert(iterator pos) { - size_type index = pos - begin(); - check_low_capacity(); - return circular_buffer<T, Alloc>::rinsert(begin() + index); - } - - //! Insert <code>n</code> copies of the <code>item</code> before the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer_space_optimized</code> or its - end. - \post The number of <code>min[n, (end() - pos) + reserve()]</code> elements will be inserted before the - position <code>pos</code>.<br>The number of <code>min[end() - pos, max[0, n - reserve()]]</code> elements - will be overwritten at the end of the <code>circular_buffer_space_optimized</code>.<br>(See - <i>Example</i> for the explanation.)<br><br> - The amount of allocated memory in the internal buffer may be predictively increased. - \param pos An iterator specifying the position where the <code>item</code>s will be inserted. - \param n The number of <code>item</code>s the to be inserted. - \param item The element whose copies will be inserted. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - Whatever <code>T::operator = (const T&)</code> throws. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in <code>min[capacity().%capacity(), size() + n]</code>). - \par Example - Consider a <code>circular_buffer_space_optimized</code> with the capacity of 6 and the size of 4. Its - internal buffer may look like the one below.<br><br> - <code>|1|2|3|4| | |</code><br> - <code>p ___^</code><br><br>After inserting 5 elements before the position <code>p</code>:<br><br> - <code>rinsert(p, (size_t)5, 0);</code><br><br>actually only 4 elements get inserted and elements - <code>3</code> and <code>4</code> are overwritten. This is due to the fact the rinsert operation preserves - the capacity. After insertion the internal buffer looks like this:<br><br><code>|1|2|0|0|0|0|</code><br> - <br>For comparison if the capacity would not be preserved the internal buffer would then result in - <code>|1|2|0|0|0|0|0|3|4|</code>. - \sa <code>\link rinsert(iterator, param_value_type) rinsert(iterator, value_type)\endlink</code>, - <code>rinsert(iterator, InputIterator, InputIterator)</code>, - <code>\link insert(iterator, param_value_type) insert(iterator, value_type)\endlink</code>, - <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code> - */ - void rinsert(iterator pos, size_type n, param_value_type item) { - size_type index = pos - begin(); - check_low_capacity(n); - circular_buffer<T, Alloc>::rinsert(begin() + index, n, item); - } - - //! Insert the range <code>[first, last)</code> before the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer_space_optimized</code> or its - end.<br> - Valid range <code>[first, last)</code> where <code>first</code> and <code>last</code> meet the - requirements of an <a href="https://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>. - \post Elements from the range - <code>[first, last - max[0, distance(first, last) - (end() - pos) - reserve()])</code> will be inserted - before the position <code>pos</code>.<br>The number of <code>min[end() - pos, max[0, - distance(first, last) - reserve()]]</code> elements will be overwritten at the end of the - <code>circular_buffer</code>.<br>(See <i>Example</i> for the explanation.)<br><br> - The amount of allocated memory in the internal buffer may be predictively increased. - \param pos An iterator specifying the position where the range will be inserted. - \param first The beginning of the range to be inserted. - \param last The end of the range to be inserted. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::T(const T&)</code> throws. - Whatever <code>T::operator = (const T&)</code> throws. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in <code>[size() + std::distance(first, last)]</code>; in - <code>min[capacity().%capacity(), size() + std::distance(first, last)]</code> if the - <code>InputIterator</code> is a - <a href="https://www.boost.org/sgi/stl/RandomAccessIterator.html">RandomAccessIterator</a>). - \par Example - Consider a <code>circular_buffer_space_optimized</code> with the capacity of 6 and the size of 4. Its - internal buffer may look like the one below.<br><br> - <code>|1|2|3|4| | |</code><br> - <code>p ___^</code><br><br>After inserting a range of elements before the position <code>p</code>:<br><br> - <code>int array[] = { 5, 6, 7, 8, 9 };</code><br><code>insert(p, array, array + 5);</code><br><br> - actually only elements <code>5</code>, <code>6</code>, <code>7</code> and <code>8</code> from the - specified range get inserted and elements <code>3</code> and <code>4</code> are overwritten. This is due - to the fact the rinsert operation preserves the capacity. After insertion the internal buffer looks like - this:<br><br><code>|1|2|5|6|7|8|</code><br><br>For comparison if the capacity would not be preserved the - internal buffer would then result in <code>|1|2|5|6|7|8|9|3|4|</code>. - \sa <code>\link rinsert(iterator, param_value_type) rinsert(iterator, value_type)\endlink</code>, - <code>\link rinsert(iterator, size_type, param_value_type) - rinsert(iterator, size_type, value_type)\endlink</code>, <code>\link insert(iterator, param_value_type) - insert(iterator, value_type)\endlink</code>, <code>\link insert(iterator, size_type, param_value_type) - insert(iterator, size_type, value_type)\endlink</code>, - <code>insert(iterator, InputIterator, InputIterator)</code> - */ - template <class InputIterator> - void rinsert(iterator pos, InputIterator first, InputIterator last) { - rinsert(pos, first, last, is_integral<InputIterator>()); - } - - //! Remove an element at the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer_space_optimized</code> (but not - an <code>end()</code>). - \post The element at the position <code>pos</code> is removed.<br><br> - The amount of allocated memory in the internal buffer may be predictively decreased. - \param pos An iterator pointing at the element to be removed. - \return Iterator to the first element remaining beyond the removed element or <code>end()</code> if no such - element exists. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::operator = (const T&)</code> throws or - nothing if <code>T::operator = (T&&)</code> is noexcept. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>erase(iterator, iterator)</code>, <code>rerase(iterator)</code>, - <code>rerase(iterator, iterator)</code>, <code>clear()</code> - */ - iterator erase(iterator pos) { - iterator it = circular_buffer<T, Alloc>::erase(pos); - size_type index = it - begin(); - check_high_capacity(); - return begin() + index; - } - - //! Erase the range <code>[first, last)</code>. - /*! - \pre Valid range <code>[first, last)</code>. - \post The elements from the range <code>[first, last)</code> are removed. (If <code>first == last</code> - nothing is removed.)<br><br> - The amount of allocated memory in the internal buffer may be predictively decreased. - \param first The beginning of the range to be removed. - \param last The end of the range to be removed. - \return Iterator to the first element remaining beyond the removed elements or <code>end()</code> if no such - element exists. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::operator = (const T&)</code> throws or - nothing if <code>T::operator = (T&&)</code> is noexcept. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>erase(iterator)</code>, <code>rerase(iterator)</code>, <code>rerase(iterator, iterator)</code>, - <code>clear()</code> - */ - iterator erase(iterator first, iterator last) { - iterator it = circular_buffer<T, Alloc>::erase(first, last); - size_type index = it - begin(); - check_high_capacity(); - return begin() + index; - } - - //! Remove an element at the specified position. - /*! - \pre <code>pos</code> is a valid iterator pointing to the <code>circular_buffer_space_optimized</code> (but not - an <code>end()</code>).<br><br> - The amount of allocated memory in the internal buffer may be predictively decreased. - \post The element at the position <code>pos</code> is removed. - \param pos An iterator pointing at the element to be removed. - \return Iterator to the first element remaining in front of the removed element or <code>begin()</code> if no - such element exists. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::operator = (const T&)</code> throws or - nothing if <code>T::operator = (T&&)</code> is noexcept. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \note Basically there is no difference between <code>erase(iterator)</code> and this method. It is implemented - only for consistency with the base <code>circular_buffer</code>. - \sa <code>erase(iterator)</code>, <code>erase(iterator, iterator)</code>, - <code>rerase(iterator, iterator)</code>, <code>clear()</code> - */ - iterator rerase(iterator pos) { - iterator it = circular_buffer<T, Alloc>::rerase(pos); - size_type index = it - begin(); - check_high_capacity(); - return begin() + index; - } - - //! Erase the range <code>[first, last)</code>. - /*! - \pre Valid range <code>[first, last)</code>. - \post The elements from the range <code>[first, last)</code> are removed. (If <code>first == last</code> - nothing is removed.)<br><br> - The amount of allocated memory in the internal buffer may be predictively decreased. - \param first The beginning of the range to be removed. - \param last The end of the range to be removed. - \return Iterator to the first element remaining in front of the removed elements or <code>begin()</code> if no - such element exists. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - Whatever <code>T::operator = (const T&)</code> throws or - nothing if <code>T::operator = (T&&)</code> is noexcept. - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \note Basically there is no difference between <code>erase(iterator, iterator)</code> and this method. It is - implemented only for consistency with the base - <code><circular_buffer</code>. - \sa <code>erase(iterator)</code>, <code>erase(iterator, iterator)</code>, <code>rerase(iterator)</code>, - <code>clear()</code> - */ - iterator rerase(iterator first, iterator last) { - iterator it = circular_buffer<T, Alloc>::rerase(first, last); - size_type index = it - begin(); - check_high_capacity(); - return begin() + index; - } - - //! Remove all stored elements from the space optimized circular buffer. - /*! - \post <code>size() == 0</code><br><br> - The amount of allocated memory in the internal buffer may be predictively decreased. - \throws "An allocation error" if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is - used). - \par Exception Safety - Basic. - \par Iterator Invalidation - Invalidates all iterators pointing to the <code>circular_buffer_space_optimized</code> (except iterators - equal to <code>end()</code>). - \par Complexity - Linear (in the size of the <code>circular_buffer_space_optimized</code>). - \sa <code>~circular_buffer_space_optimized()</code>, <code>erase(iterator)</code>, - <code>erase(iterator, iterator)</code>, <code>rerase(iterator)</code>, - <code>rerase(iterator, iterator)</code> - */ - void clear() { erase(begin(), end()); } - -private: -// Helper methods - - /*! INTERNAL ONLY */ - void adjust_min_capacity() { - if (m_capacity_ctrl.min_capacity() > circular_buffer<T, Alloc>::capacity()) - circular_buffer<T, Alloc>::set_capacity(m_capacity_ctrl.min_capacity()); - else - check_high_capacity(); - } - - /*! INTERNAL ONLY */ - size_type ensure_reserve(size_type new_capacity, size_type buffer_size) const { - if (buffer_size + new_capacity / 5 >= new_capacity) - new_capacity *= 2; // ensure at least 20% reserve - if (new_capacity > m_capacity_ctrl) - return m_capacity_ctrl; - return new_capacity; - } - - /*! INTERNAL ONLY */ - void check_low_capacity(size_type n = 1) { - size_type new_size = size() + n; - size_type new_capacity = circular_buffer<T, Alloc>::capacity(); - if (new_size > new_capacity) { - if (new_capacity == 0) - new_capacity = 1; - for (; new_size > new_capacity; new_capacity *= 2) {} - circular_buffer<T, Alloc>::set_capacity( - ensure_reserve(new_capacity, new_size)); - } -#if BOOST_CB_ENABLE_DEBUG - this->invalidate_iterators_except(end()); -#endif - } - - /*! INTERNAL ONLY */ - void check_high_capacity() { - size_type new_capacity = circular_buffer<T, Alloc>::capacity(); - while (new_capacity / 3 >= size()) { // (new_capacity / 3) -> avoid oscillations - new_capacity /= 2; - if (new_capacity <= m_capacity_ctrl.min_capacity()) { - new_capacity = m_capacity_ctrl.min_capacity(); - break; - } - } - circular_buffer<T, Alloc>::set_capacity( - ensure_reserve(new_capacity, size())); -#if BOOST_CB_ENABLE_DEBUG - this->invalidate_iterators_except(end()); -#endif - } - - /*! INTERNAL ONLY */ - void reduce_capacity(const true_type&) { - circular_buffer<T, Alloc>::set_capacity((std::max)(m_capacity_ctrl.min_capacity(), size())); - } - - /*! INTERNAL ONLY */ - void reduce_capacity(const false_type&) {} - - /*! INTERNAL ONLY */ - static size_type init_capacity(const capacity_type& capacity_ctrl, size_type n) { - BOOST_CB_ASSERT(capacity_ctrl.capacity() >= n); // check for capacity lower than n - return (std::max)(capacity_ctrl.min_capacity(), n); - } - - /*! INTERNAL ONLY */ - template <class IntegralType> - static size_type init_capacity(const capacity_type& capacity_ctrl, IntegralType n, IntegralType, - const true_type&) { - return init_capacity(capacity_ctrl, static_cast<size_type>(n)); - } - - /*! INTERNAL ONLY */ - template <class Iterator> - static size_type init_capacity(const capacity_type& capacity_ctrl, Iterator first, Iterator last, - const false_type&) { - BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); // check for invalid iterator type -#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x581)) - return init_capacity(capacity_ctrl, first, last, std::iterator_traits<Iterator>::iterator_category()); -#else - return init_capacity( - capacity_ctrl, first, last, BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::iterator_category()); -#endif - } - - /*! INTERNAL ONLY */ - template <class InputIterator> - static size_type init_capacity(const capacity_type& capacity_ctrl, InputIterator, InputIterator, - const std::input_iterator_tag&) { - return capacity_ctrl.capacity(); - } - - /*! INTERNAL ONLY */ - template <class ForwardIterator> - static size_type init_capacity(const capacity_type& capacity_ctrl, ForwardIterator first, ForwardIterator last, - const std::forward_iterator_tag&) { - BOOST_CB_ASSERT(std::distance(first, last) >= 0); // check for wrong range - return (std::max)(capacity_ctrl.min_capacity(), - (std::min)(capacity_ctrl.capacity(), static_cast<size_type>(std::distance(first, last)))); - } - - /*! INTERNAL ONLY */ - template <class IntegralType> - void insert(const iterator& pos, IntegralType n, IntegralType item, const true_type&) { - insert(pos, static_cast<size_type>(n), static_cast<value_type>(item)); - } - - /*! INTERNAL ONLY */ - template <class Iterator> - void insert(const iterator& pos, Iterator first, Iterator last, const false_type&) { - size_type index = pos - begin(); - check_low_capacity(std::distance(first, last)); - circular_buffer<T, Alloc>::insert(begin() + index, first, last); - } - - /*! INTERNAL ONLY */ - template <class IntegralType> - void rinsert(const iterator& pos, IntegralType n, IntegralType item, const true_type&) { - rinsert(pos, static_cast<size_type>(n), static_cast<value_type>(item)); - } - - /*! INTERNAL ONLY */ - template <class Iterator> - void rinsert(const iterator& pos, Iterator first, Iterator last, const false_type&) { - size_type index = pos - begin(); - check_low_capacity(std::distance(first, last)); - circular_buffer<T, Alloc>::rinsert(begin() + index, first, last); - } -}; - -// Non-member functions - -//! Test two space optimized circular buffers for equality. -template <class T, class Alloc> -inline bool operator == (const circular_buffer_space_optimized<T, Alloc>& lhs, - const circular_buffer_space_optimized<T, Alloc>& rhs) { - return lhs.size() == rhs.size() && - std::equal(lhs.begin(), lhs.end(), rhs.begin()); -} - -//! Lexicographical comparison. -template <class T, class Alloc> -inline bool operator < (const circular_buffer_space_optimized<T, Alloc>& lhs, - const circular_buffer_space_optimized<T, Alloc>& rhs) { - return std::lexicographical_compare( - lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); -} - -#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) || BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) - -//! Test two space optimized circular buffers for non-equality. -template <class T, class Alloc> -inline bool operator != (const circular_buffer_space_optimized<T, Alloc>& lhs, - const circular_buffer_space_optimized<T, Alloc>& rhs) { - return !(lhs == rhs); -} - -//! Lexicographical comparison. -template <class T, class Alloc> -inline bool operator > (const circular_buffer_space_optimized<T, Alloc>& lhs, - const circular_buffer_space_optimized<T, Alloc>& rhs) { - return rhs < lhs; -} - -//! Lexicographical comparison. -template <class T, class Alloc> -inline bool operator <= (const circular_buffer_space_optimized<T, Alloc>& lhs, - const circular_buffer_space_optimized<T, Alloc>& rhs) { - return !(rhs < lhs); -} - -//! Lexicographical comparison. -template <class T, class Alloc> -inline bool operator >= (const circular_buffer_space_optimized<T, Alloc>& lhs, - const circular_buffer_space_optimized<T, Alloc>& rhs) { - return !(lhs < rhs); -} - -//! Swap the contents of two space optimized circular buffers. -template <class T, class Alloc> -inline void swap(circular_buffer_space_optimized<T, Alloc>& lhs, - circular_buffer_space_optimized<T, Alloc>& rhs) BOOST_NOEXCEPT { - lhs.swap(rhs); -} - -#endif // #if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) || BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) - -} // namespace boost - -#endif // #if !defined(BOOST_CIRCULAR_BUFFER_SPACE_OPTIMIZED_HPP) diff --git a/contrib/restricted/boost/boost/circular_buffer_fwd.hpp b/contrib/restricted/boost/boost/circular_buffer_fwd.hpp deleted file mode 100644 index 621fb953e2..0000000000 --- a/contrib/restricted/boost/boost/circular_buffer_fwd.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Forward declaration of the circular buffer and its adaptor. - -// Copyright (c) 2003-2008 Jan Gaspar - -// Use, modification, and distribution is subject to the Boost Software -// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// See www.boost.org/libs/circular_buffer for documentation. - -#if !defined(BOOST_CIRCULAR_BUFFER_FWD_HPP) -#define BOOST_CIRCULAR_BUFFER_FWD_HPP - -#if defined(_MSC_VER) - #pragma once -#endif - -#include <boost/config.hpp> -#if !defined(BOOST_NO_STD_ALLOCATOR) - #include <memory> -#else - #include <vector> -#endif - -namespace boost { - -#if !defined(BOOST_NO_STD_ALLOCATOR) - #define BOOST_CB_DEFAULT_ALLOCATOR(T) std::allocator<T> -#else - #define BOOST_CB_DEFAULT_ALLOCATOR(T) BOOST_DEDUCED_TYPENAME std::vector<T>::allocator_type -#endif - -template <class T, class Alloc = BOOST_CB_DEFAULT_ALLOCATOR(T)> -class circular_buffer; - -template <class T, class Alloc = BOOST_CB_DEFAULT_ALLOCATOR(T)> -class circular_buffer_space_optimized; - -#undef BOOST_CB_DEFAULT_ALLOCATOR - -} // namespace boost - -#endif // #if !defined(BOOST_CIRCULAR_BUFFER_FWD_HPP) diff --git a/contrib/restricted/boost/circular_buffer/CMakeLists.txt b/contrib/restricted/boost/circular_buffer/CMakeLists.txt new file mode 100644 index 0000000000..9040d39487 --- /dev/null +++ b/contrib/restricted/boost/circular_buffer/CMakeLists.txt @@ -0,0 +1,25 @@ + +# This file was gererated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(restricted-boost-circular_buffer INTERFACE) +target_include_directories(restricted-boost-circular_buffer INTERFACE + ${CMAKE_SOURCE_DIR}/contrib/restricted/boost/circular_buffer/include +) +target_link_libraries(restricted-boost-circular_buffer INTERFACE + contrib-libs-cxxsupp + yutil + restricted-boost-assert + restricted-boost-concept_check + restricted-boost-config + restricted-boost-core + restricted-boost-move + restricted-boost-static_assert + restricted-boost-throw_exception + restricted-boost-type_traits +) |