mirror of
https://github.com/boostorg/circular_buffer.git
synced 2026-02-03 09:02:12 +00:00
Compare commits
1 Commits
20131209-m
...
boost-1.55
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aca434d344 |
@@ -11,13 +11,12 @@
|
||||
#if !defined(BOOST_CIRCULAR_BUFFER_HPP)
|
||||
#define BOOST_CIRCULAR_BUFFER_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1200
|
||||
#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(NDEBUG) || defined(BOOST_CB_DISABLE_DEBUG)
|
||||
@@ -34,20 +33,29 @@
|
||||
#define BOOST_CB_ASSERT(Expr) ((void)0)
|
||||
#endif
|
||||
|
||||
// BOOST_CB_STATIC_ASSERT: Compile time assertion.
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
#define BOOST_CB_STATIC_ASSERT(Expr) ((void)0)
|
||||
#else
|
||||
#include <boost/static_assert.hpp>
|
||||
#define BOOST_CB_STATIC_ASSERT(Expr) BOOST_STATIC_ASSERT(Expr)
|
||||
#endif
|
||||
|
||||
// BOOST_CB_IS_CONVERTIBLE: Check if Iterator::value_type is convertible to Type.
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x0550) || BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x0550) || BOOST_WORKAROUND(__MWERKS__, <= 0x2407) || \
|
||||
BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
#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))
|
||||
BOOST_CB_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);
|
||||
#define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS BOOST_CB_STATIC_ASSERT(false);
|
||||
#else
|
||||
#define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS ((void)0);
|
||||
#endif
|
||||
@@ -59,6 +67,7 @@
|
||||
|
||||
#undef BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS
|
||||
#undef BOOST_CB_IS_CONVERTIBLE
|
||||
#undef BOOST_CB_STATIC_ASSERT
|
||||
#undef BOOST_CB_ASSERT
|
||||
#undef BOOST_CB_ENABLE_DEBUG
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#if !defined(BOOST_CIRCULAR_BUFFER_BASE_HPP)
|
||||
#define BOOST_CIRCULAR_BUFFER_BASE_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1200
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -1150,6 +1150,25 @@ public:
|
||||
}
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
|
||||
/*! \cond */
|
||||
template <class InputIterator>
|
||||
circular_buffer(InputIterator first, InputIterator last)
|
||||
: m_alloc(allocator_type()) {
|
||||
initialize(first, last, is_integral<InputIterator>());
|
||||
}
|
||||
|
||||
template <class InputIterator>
|
||||
circular_buffer(capacity_type capacity, InputIterator first, InputIterator last)
|
||||
: m_alloc(allocator_type()) {
|
||||
initialize(capacity, first, last, is_integral<InputIterator>());
|
||||
}
|
||||
/*! \endcond */
|
||||
|
||||
#else
|
||||
|
||||
//! Create a full <code>circular_buffer</code> filled with a copy of the range.
|
||||
/*!
|
||||
\pre Valid range <code>[first, last)</code>.<br>
|
||||
@@ -1202,6 +1221,8 @@ public:
|
||||
initialize(buffer_capacity, first, last, is_integral<InputIterator>());
|
||||
}
|
||||
|
||||
#endif // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
|
||||
//! The destructor.
|
||||
/*!
|
||||
Destroys the <code>circular_buffer</code>.
|
||||
@@ -2533,9 +2554,9 @@ private:
|
||||
void initialize(Iterator first, Iterator last, const false_type&) {
|
||||
BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); // check for invalid iterator type
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
initialize(first, last, iterator_category<Iterator>::type());
|
||||
initialize(first, last, BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#else
|
||||
initialize(first, last, BOOST_DEDUCED_TYPENAME iterator_category<Iterator>::type());
|
||||
initialize(first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2572,9 +2593,9 @@ private:
|
||||
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(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
initialize(buffer_capacity, first, last, iterator_category<Iterator>::type());
|
||||
initialize(buffer_capacity, first, last, BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#else
|
||||
initialize(buffer_capacity, first, last, BOOST_DEDUCED_TYPENAME iterator_category<Iterator>::type());
|
||||
initialize(buffer_capacity, first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2666,9 +2687,9 @@ private:
|
||||
void assign(Iterator first, Iterator last, const false_type&) {
|
||||
BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); // check for invalid iterator type
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
assign(first, last, iterator_category<Iterator>::type());
|
||||
assign(first, last, BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#else
|
||||
assign(first, last, BOOST_DEDUCED_TYPENAME iterator_category<Iterator>::type());
|
||||
assign(first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2703,9 +2724,9 @@ private:
|
||||
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(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
assign(new_capacity, first, last, iterator_category<Iterator>::type());
|
||||
assign(new_capacity, first, last, BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#else
|
||||
assign(new_capacity, first, last, BOOST_DEDUCED_TYPENAME iterator_category<Iterator>::type());
|
||||
assign(new_capacity, first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2716,7 +2737,12 @@ private:
|
||||
clear();
|
||||
insert(begin(), first, last);
|
||||
} else {
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
circular_buffer<value_type, allocator_type> tmp(new_capacity, m_alloc);
|
||||
tmp.insert(begin(), first, last);
|
||||
#else
|
||||
circular_buffer<value_type, allocator_type> tmp(new_capacity, first, last, m_alloc);
|
||||
#endif
|
||||
tmp.swap(*this);
|
||||
}
|
||||
}
|
||||
@@ -2812,9 +2838,9 @@ private:
|
||||
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(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
insert(pos, first, last, iterator_category<Iterator>::type());
|
||||
insert(pos, first, last, BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#else
|
||||
insert(pos, first, last, BOOST_DEDUCED_TYPENAME iterator_category<Iterator>::type());
|
||||
insert(pos, first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2903,9 +2929,9 @@ private:
|
||||
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(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
rinsert(pos, first, last, iterator_category<Iterator>::type());
|
||||
rinsert(pos, first, last, BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#else
|
||||
rinsert(pos, first, last, BOOST_DEDUCED_TYPENAME iterator_category<Iterator>::type());
|
||||
rinsert(pos, first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#if !defined(BOOST_CIRCULAR_BUFFER_DEBUG_HPP)
|
||||
#define BOOST_CIRCULAR_BUFFER_DEBUG_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1200
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#if !defined(BOOST_CIRCULAR_BUFFER_DETAILS_HPP)
|
||||
#define BOOST_CIRCULAR_BUFFER_DETAILS_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1200
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -423,6 +423,24 @@ operator + (typename Traits::difference_type n, const iterator<Buff, Traits>& it
|
||||
return it + n;
|
||||
}
|
||||
|
||||
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR)
|
||||
|
||||
//! Iterator category.
|
||||
template <class Buff, class Traits>
|
||||
inline std::random_access_iterator_tag iterator_category(const iterator<Buff, Traits>&) {
|
||||
return std::random_access_iterator_tag();
|
||||
}
|
||||
|
||||
//! The type of the elements stored in the circular buffer.
|
||||
template <class Buff, class Traits>
|
||||
inline typename Traits::value_type* value_type(const iterator<Buff, Traits>&) { return 0; }
|
||||
|
||||
//! Distance type.
|
||||
template <class Buff, class Traits>
|
||||
inline typename Traits::difference_type* distance_type(const iterator<Buff, Traits>&) { return 0; }
|
||||
|
||||
#endif // #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR)
|
||||
|
||||
/*!
|
||||
\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.
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#if !defined(BOOST_CIRCULAR_BUFFER_SPACE_OPTIMIZED_HPP)
|
||||
#define BOOST_CIRCULAR_BUFFER_SPACE_OPTIMIZED_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1200
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
@@ -416,6 +416,31 @@ public:
|
||||
: circular_buffer<T, Alloc>(init_capacity(capacity_ctrl, n), n, item, alloc)
|
||||
, m_capacity_ctrl(capacity_ctrl) {}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
|
||||
/*! \cond */
|
||||
circular_buffer_space_optimized(const circular_buffer_space_optimized<T, Alloc>& cb)
|
||||
: circular_buffer<T, Alloc>(cb.begin(), cb.end())
|
||||
, m_capacity_ctrl(cb.m_capacity_ctrl) {}
|
||||
|
||||
template <class InputIterator>
|
||||
circular_buffer_space_optimized(InputIterator first, InputIterator last)
|
||||
: circular_buffer<T, Alloc>(first, last)
|
||||
, m_capacity_ctrl(circular_buffer<T, Alloc>::capacity()) {}
|
||||
|
||||
template <class InputIterator>
|
||||
circular_buffer_space_optimized(capacity_type capacity_ctrl, InputIterator first, InputIterator last)
|
||||
: circular_buffer<T, Alloc>(
|
||||
init_capacity(capacity_ctrl, first, last, is_integral<InputIterator>()),
|
||||
first, last)
|
||||
, m_capacity_ctrl(capacity_ctrl) {
|
||||
reduce_capacity(
|
||||
is_same< BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<InputIterator>::type, std::input_iterator_tag >());
|
||||
}
|
||||
/*! \endcond */
|
||||
|
||||
#else
|
||||
|
||||
//! The copy constructor.
|
||||
/*!
|
||||
Creates a copy of the specified <code>circular_buffer_space_optimized</code>.
|
||||
@@ -509,9 +534,11 @@ public:
|
||||
first, last, alloc)
|
||||
, m_capacity_ctrl(capacity_ctrl) {
|
||||
reduce_capacity(
|
||||
is_same< BOOST_DEDUCED_TYPENAME iterator_category<InputIterator>::type, std::input_iterator_tag >());
|
||||
is_same< BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<InputIterator>::type, std::input_iterator_tag >());
|
||||
}
|
||||
|
||||
#endif // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
|
||||
#if defined(BOOST_CB_NEVER_DEFINED)
|
||||
// This section will never be compiled - the default destructor will be generated instead.
|
||||
// Declared only for documentation purpose.
|
||||
@@ -1605,10 +1632,10 @@ private:
|
||||
const false_type&) {
|
||||
BOOST_CB_IS_CONVERTIBLE(Iterator, value_type); // check for invalid iterator type
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
return init_capacity(capacity_ctrl, first, last, iterator_category<Iterator>::type());
|
||||
return init_capacity(capacity_ctrl, first, last, BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#else
|
||||
return init_capacity(
|
||||
capacity_ctrl, first, last, BOOST_DEDUCED_TYPENAME iterator_category<Iterator>::type());
|
||||
capacity_ctrl, first, last, BOOST_DEDUCED_TYPENAME BOOST_ITERATOR_CATEGORY<Iterator>::type());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user