mirror of
https://github.com/boostorg/circular_buffer.git
synced 2026-02-03 21:12:21 +00:00
Compare commits
12 Commits
boost-1.71
...
boost-1.76
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59640fa9dc | ||
|
|
50d29f7e70 | ||
|
|
eed21df804 | ||
|
|
01788c32e0 | ||
|
|
e77766b4a6 | ||
|
|
dae0d6638e | ||
|
|
466b40ab55 | ||
|
|
57a6351e25 | ||
|
|
8e23f4229f | ||
|
|
7808ab19dc | ||
|
|
7be41ca8f9 | ||
|
|
6ccd04cd89 |
60
.travis.yml
60
.travis.yml
@@ -5,6 +5,8 @@ language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
dist: trusty
|
||||
|
||||
python: "2.7"
|
||||
|
||||
branches:
|
||||
@@ -97,7 +99,6 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
@@ -109,7 +110,17 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: g++-8
|
||||
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17
|
||||
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-8
|
||||
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -121,6 +132,22 @@ matrix:
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: /usr/bin/clang++
|
||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.3
|
||||
|
||||
- os: linux
|
||||
compiler: /usr/bin/clang++
|
||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.4
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.5
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
|
||||
@@ -131,6 +158,7 @@ matrix:
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.5
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.6
|
||||
@@ -139,9 +167,20 @@ matrix:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.6
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.6
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.7
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.8
|
||||
@@ -153,6 +192,7 @@ matrix:
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.9
|
||||
@@ -164,6 +204,7 @@ matrix:
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.9
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-4.0
|
||||
@@ -189,7 +230,7 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-6.0
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -198,6 +239,17 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-6.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-7
|
||||
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
|
||||
|
||||
@@ -233,7 +233,7 @@ void fifo_test(Buffer* buffer) {
|
||||
|
||||
// Initialize the buffer with some values before launching producer and consumer threads.
|
||||
for (unsigned long i = QUEUE_SIZE / 2L; i > 0; --i) {
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x581))
|
||||
buffer->push_front(Buffer::value_type());
|
||||
#else
|
||||
buffer->push_front(BOOST_DEDUCED_TYPENAME Buffer::value_type());
|
||||
|
||||
@@ -136,7 +136,7 @@ void fifo_test(Buffer* buffer)
|
||||
// Initialize the buffer with some values before launching producer and consumer threads.
|
||||
for (unsigned long i = queue_size / 2L; i > 0; --i)
|
||||
{
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x581))
|
||||
buffer->push_front(Buffer::value_type());
|
||||
#else
|
||||
buffer->push_front(BOOST_DEDUCED_TYPENAME Buffer::value_type());
|
||||
|
||||
@@ -37,7 +37,7 @@ Includes <boost/circular_buffer/base.hpp>
|
||||
#endif
|
||||
|
||||
/*! INTERNAL ONLY */
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x0550) || BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, <= 0x0550) || BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||
#define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) ((void)0)
|
||||
#else
|
||||
#include <iterator>
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
// Copyright 2018 Glen Joseph Fernandes
|
||||
// (glenjofe@gmail.com)
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
#ifndef BOOST_CIRCULAR_BUFFER_ALLOCATORS_HPP
|
||||
#define BOOST_CIRCULAR_BUFFER_ALLOCATORS_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#define BOOST_CB_NO_CXX11_ALLOCATOR
|
||||
#elif defined(BOOST_LIBSTDCXX_VERSION) && (BOOST_LIBSTDCXX_VERSION < 40800)
|
||||
#define BOOST_CB_NO_CXX11_ALLOCATOR
|
||||
#endif
|
||||
#include <limits>
|
||||
#if !defined(BOOST_CB_NO_CXX11_ALLOCATOR)
|
||||
#include <memory>
|
||||
#else
|
||||
#include <new>
|
||||
#endif
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace cb_details {
|
||||
|
||||
#if !defined(BOOST_CB_NO_CXX11_ALLOCATOR)
|
||||
template<class A>
|
||||
struct allocator_traits
|
||||
: std::allocator_traits<A> {
|
||||
using typename std::allocator_traits<A>::value_type;
|
||||
using typename std::allocator_traits<A>::size_type;
|
||||
|
||||
static size_type max_size(const A&) BOOST_NOEXCEPT {
|
||||
return (std::numeric_limits<size_type>::max)() / sizeof(value_type);
|
||||
}
|
||||
};
|
||||
#else
|
||||
template<class A>
|
||||
struct allocator_traits {
|
||||
typedef typename A::value_type value_type;
|
||||
typedef typename A::pointer pointer;
|
||||
typedef typename A::const_pointer const_pointer;
|
||||
typedef typename A::difference_type difference_type;
|
||||
typedef typename A::size_type size_type;
|
||||
|
||||
static size_type max_size(const A&) BOOST_NOEXCEPT {
|
||||
return (std::numeric_limits<size_type>::max)() / sizeof(value_type);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class U, class... Args>
|
||||
static void construct(const A&, U* ptr, Args&&... args) {
|
||||
::new((void*)ptr) U(std::forward<Args>(args)...);
|
||||
}
|
||||
#else
|
||||
template<class U, class V>
|
||||
static void construct(const A&, U* ptr, V&& value) {
|
||||
::new((void*)ptr) U(std::forward<V>(value));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
template<class U, class V>
|
||||
static void construct(const A&, U* ptr, const V& value) {
|
||||
::new((void*)ptr) U(value);
|
||||
}
|
||||
|
||||
template<class U, class V>
|
||||
static void construct(const A&, U* ptr, V& value) {
|
||||
::new((void*)ptr) U(value);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class U>
|
||||
static void destroy(const A&, U* ptr) {
|
||||
(void)ptr;
|
||||
ptr->~U();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
} // cb_details
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -21,7 +21,7 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/circular_buffer/allocators.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>
|
||||
@@ -99,13 +99,13 @@ public:
|
||||
typedef circular_buffer<T, Alloc> this_type;
|
||||
|
||||
//! The type of elements stored in the <code>circular_buffer</code>.
|
||||
typedef typename cb_details::allocator_traits<Alloc>::value_type value_type;
|
||||
typedef typename Alloc::value_type value_type;
|
||||
|
||||
//! A pointer to an element.
|
||||
typedef typename cb_details::allocator_traits<Alloc>::pointer pointer;
|
||||
typedef typename allocator_pointer<Alloc>::type pointer;
|
||||
|
||||
//! A const pointer to the element.
|
||||
typedef typename cb_details::allocator_traits<Alloc>::const_pointer const_pointer;
|
||||
typedef typename allocator_const_pointer<Alloc>::type const_pointer;
|
||||
|
||||
//! A reference to an element.
|
||||
typedef value_type& reference;
|
||||
@@ -117,13 +117,13 @@ public:
|
||||
/*!
|
||||
(A signed integral type used to represent the distance between two iterators.)
|
||||
*/
|
||||
typedef typename cb_details::allocator_traits<Alloc>::difference_type difference_type;
|
||||
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 cb_details::allocator_traits<Alloc>::size_type size_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;
|
||||
@@ -131,10 +131,10 @@ public:
|
||||
// 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<cb_details::allocator_traits<Alloc> > > const_iterator;
|
||||
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<cb_details::allocator_traits<Alloc> > > iterator;
|
||||
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;
|
||||
@@ -287,6 +287,7 @@ public:
|
||||
*/
|
||||
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>
|
||||
@@ -303,6 +304,7 @@ public:
|
||||
*/
|
||||
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>.
|
||||
@@ -666,7 +668,7 @@ public:
|
||||
break;
|
||||
}
|
||||
if (is_uninitialized(dest)) {
|
||||
cb_details::allocator_traits<Alloc>::construct(alloc(), boost::to_address(dest), boost::move_if_noexcept(*src));
|
||||
boost::allocator_construct(alloc(), boost::to_address(dest), boost::move_if_noexcept(*src));
|
||||
++constructed;
|
||||
} else {
|
||||
value_type tmp = boost::move_if_noexcept(*src);
|
||||
@@ -787,7 +789,7 @@ public:
|
||||
\sa <code>size()</code>, <code>capacity()</code>, <code>reserve()</code>
|
||||
*/
|
||||
size_type max_size() const BOOST_NOEXCEPT {
|
||||
return (std::min<size_type>)(cb_details::allocator_traits<Alloc>::max_size(alloc()), (std::numeric_limits<difference_type>::max)());
|
||||
return (std::min<size_type>)(boost::allocator_max_size(alloc()), (std::numeric_limits<difference_type>::max)());
|
||||
}
|
||||
|
||||
//! Is the <code>circular_buffer</code> empty?
|
||||
@@ -1424,7 +1426,7 @@ private:
|
||||
increment(m_last);
|
||||
m_first = m_last;
|
||||
} else {
|
||||
cb_details::allocator_traits<Alloc>::construct(alloc(), boost::to_address(m_last), static_cast<ValT>(item));
|
||||
boost::allocator_construct(alloc(), boost::to_address(m_last), static_cast<ValT>(item));
|
||||
increment(m_last);
|
||||
++m_size;
|
||||
}
|
||||
@@ -1442,7 +1444,7 @@ private:
|
||||
m_last = m_first;
|
||||
} else {
|
||||
decrement(m_first);
|
||||
cb_details::allocator_traits<Alloc>::construct(alloc(), boost::to_address(m_first), static_cast<ValT>(item));
|
||||
boost::allocator_construct(alloc(), boost::to_address(m_first), static_cast<ValT>(item));
|
||||
++m_size;
|
||||
}
|
||||
} BOOST_CATCH(...) {
|
||||
@@ -2427,7 +2429,7 @@ private:
|
||||
/*! INTERNAL ONLY */
|
||||
void construct_or_replace(bool construct, pointer pos, param_value_type item) {
|
||||
if (construct)
|
||||
cb_details::allocator_traits<Alloc>::construct(alloc(), boost::to_address(pos), item);
|
||||
boost::allocator_construct(alloc(), boost::to_address(pos), item);
|
||||
else
|
||||
replace(pos, item);
|
||||
}
|
||||
@@ -2435,14 +2437,14 @@ private:
|
||||
/*! INTERNAL ONLY */
|
||||
void construct_or_replace(bool construct, pointer pos, rvalue_type item) {
|
||||
if (construct)
|
||||
cb_details::allocator_traits<Alloc>::construct(alloc(), boost::to_address(pos), boost::move(item));
|
||||
boost::allocator_construct(alloc(), boost::to_address(pos), boost::move(item));
|
||||
else
|
||||
replace(pos, boost::move(item));
|
||||
}
|
||||
|
||||
/*! INTERNAL ONLY */
|
||||
void destroy_item(pointer p) {
|
||||
cb_details::allocator_traits<Alloc>::destroy(alloc(), boost::to_address(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));
|
||||
@@ -2517,7 +2519,7 @@ private:
|
||||
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(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
#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());
|
||||
@@ -2556,7 +2558,7 @@ private:
|
||||
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(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
#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());
|
||||
@@ -2575,7 +2577,7 @@ private:
|
||||
if (buffer_capacity == 0)
|
||||
return;
|
||||
while (first != last && !full()) {
|
||||
cb_details::allocator_traits<Alloc>::construct(alloc(), boost::to_address(m_last), *first++);
|
||||
boost::allocator_construct(alloc(), boost::to_address(m_last), *first++);
|
||||
increment(m_last);
|
||||
++m_size;
|
||||
}
|
||||
@@ -2650,7 +2652,7 @@ private:
|
||||
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(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
#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());
|
||||
@@ -2687,7 +2689,7 @@ private:
|
||||
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(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
#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());
|
||||
@@ -2796,7 +2798,7 @@ private:
|
||||
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(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
#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());
|
||||
@@ -2840,7 +2842,7 @@ private:
|
||||
pointer p = m_last;
|
||||
BOOST_TRY {
|
||||
for (; ii < construct; ++ii, increment(p))
|
||||
cb_details::allocator_traits<Alloc>::construct(alloc(), boost::to_address(p), *wrapper());
|
||||
boost::allocator_construct(alloc(), boost::to_address(p), *wrapper());
|
||||
for (;ii < n; ++ii, increment(p))
|
||||
replace(p, *wrapper());
|
||||
} BOOST_CATCH(...) {
|
||||
@@ -2887,7 +2889,7 @@ private:
|
||||
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(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
#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());
|
||||
@@ -2934,7 +2936,7 @@ private:
|
||||
for (;ii > construct; --ii, increment(p))
|
||||
replace(p, *wrapper());
|
||||
for (; ii > 0; --ii, increment(p))
|
||||
cb_details::allocator_traits<Alloc>::construct(alloc(), boost::to_address(p), *wrapper());
|
||||
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);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#endif
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/circular_buffer/allocators.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>
|
||||
@@ -36,7 +36,7 @@ namespace boost {
|
||||
|
||||
namespace cb_details {
|
||||
|
||||
template <class Traits> struct nonconst_traits;
|
||||
template <class Alloc> struct nonconst_traits;
|
||||
|
||||
template<class ForwardIterator, class Diff, class T, class Alloc>
|
||||
void uninitialized_fill_n_with_alloc(
|
||||
@@ -52,34 +52,34 @@ ForwardIterator uninitialized_move_if_noexcept(InputIterator first, InputIterato
|
||||
\struct const_traits
|
||||
\brief Defines the data types for a const iterator.
|
||||
*/
|
||||
template <class Traits>
|
||||
template <class Alloc>
|
||||
struct const_traits {
|
||||
// Basic types
|
||||
typedef typename Traits::value_type value_type;
|
||||
typedef typename Traits::const_pointer pointer;
|
||||
typedef typename Alloc::value_type value_type;
|
||||
typedef typename boost::allocator_const_pointer<Alloc>::type pointer;
|
||||
typedef const value_type& reference;
|
||||
typedef typename Traits::size_type size_type;
|
||||
typedef typename Traits::difference_type difference_type;
|
||||
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<Traits> nonconst_self;
|
||||
typedef nonconst_traits<Alloc> nonconst_self;
|
||||
};
|
||||
|
||||
/*!
|
||||
\struct nonconst_traits
|
||||
\brief Defines the data types for a non-const iterator.
|
||||
*/
|
||||
template <class Traits>
|
||||
template <class Alloc>
|
||||
struct nonconst_traits {
|
||||
// Basic types
|
||||
typedef typename Traits::value_type value_type;
|
||||
typedef typename Traits::pointer pointer;
|
||||
typedef typename Alloc::value_type value_type;
|
||||
typedef typename boost::allocator_pointer<Alloc>::type pointer;
|
||||
typedef value_type& reference;
|
||||
typedef typename Traits::size_type size_type;
|
||||
typedef typename Traits::difference_type difference_type;
|
||||
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<Traits> nonconst_self;
|
||||
typedef nonconst_traits<Alloc> nonconst_self;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -114,7 +114,7 @@ private:
|
||||
*/
|
||||
template <class Value, class Alloc>
|
||||
struct assign_n {
|
||||
typedef typename allocator_traits<Alloc>::size_type size_type;
|
||||
typedef typename boost::allocator_size_type<Alloc>::type size_type;
|
||||
size_type m_n;
|
||||
Value m_item;
|
||||
Alloc& m_alloc;
|
||||
@@ -424,10 +424,10 @@ inline ForwardIterator uninitialized_copy(InputIterator first, InputIterator las
|
||||
ForwardIterator next = dest;
|
||||
BOOST_TRY {
|
||||
for (; first != last; ++first, ++dest)
|
||||
allocator_traits<Alloc>::construct(a, boost::to_address(dest), *first);
|
||||
boost::allocator_construct(a, boost::to_address(dest), *first);
|
||||
} BOOST_CATCH(...) {
|
||||
for (; next != dest; ++next)
|
||||
allocator_traits<Alloc>::destroy(a, boost::to_address(next));
|
||||
boost::allocator_destroy(a, boost::to_address(next));
|
||||
BOOST_RETHROW
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
@@ -438,7 +438,7 @@ 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)
|
||||
allocator_traits<Alloc>::construct(a, boost::to_address(dest), boost::move(*first));
|
||||
boost::allocator_construct(a, boost::to_address(dest), boost::move(*first));
|
||||
return dest;
|
||||
}
|
||||
|
||||
@@ -454,7 +454,7 @@ ForwardIterator uninitialized_move_if_noexcept_impl(InputIterator first, InputIt
|
||||
*/
|
||||
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 allocator_traits<Alloc>::value_type>::type tag_t;
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -467,10 +467,10 @@ inline void uninitialized_fill_n_with_alloc(ForwardIterator first, Diff n, const
|
||||
ForwardIterator next = first;
|
||||
BOOST_TRY {
|
||||
for (; n > 0; ++first, --n)
|
||||
allocator_traits<Alloc>::construct(alloc, boost::to_address(first), item);
|
||||
boost::allocator_construct(alloc, boost::to_address(first), item);
|
||||
} BOOST_CATCH(...) {
|
||||
for (; next != first; ++next)
|
||||
allocator_traits<Alloc>::destroy(alloc, boost::to_address(next));
|
||||
boost::allocator_destroy(alloc, boost::to_address(next));
|
||||
BOOST_RETHROW
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
|
||||
@@ -121,7 +121,7 @@ public:<br>
|
||||
using circular_buffer<T, Alloc>::max_size;
|
||||
using circular_buffer<T, Alloc>::empty;
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
#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
|
||||
@@ -1598,7 +1598,7 @@ private:
|
||||
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(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
#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(
|
||||
|
||||
@@ -17,6 +17,7 @@ void iterator_constructor_and_assign_test() {
|
||||
|
||||
circular_buffer<MyInteger> cb(4, 3);
|
||||
circular_buffer<MyInteger>::iterator it = cb.begin();
|
||||
circular_buffer<MyInteger>::const_iterator cit2 = cb.cbegin();
|
||||
circular_buffer<MyInteger>::iterator itCopy;
|
||||
itCopy = it;
|
||||
it = it;
|
||||
@@ -24,12 +25,15 @@ void iterator_constructor_and_assign_test() {
|
||||
cit = it;
|
||||
circular_buffer<MyInteger>::const_iterator end1 = cb.end();
|
||||
circular_buffer<MyInteger>::const_iterator end2 = end1;
|
||||
circular_buffer<MyInteger>::const_iterator end3 = cb.cend();
|
||||
|
||||
BOOST_TEST(itCopy == it);
|
||||
BOOST_TEST(cit == it);
|
||||
BOOST_TEST(end1 == end2);
|
||||
BOOST_TEST(it != end1);
|
||||
BOOST_TEST(cit != end2);
|
||||
BOOST_TEST(cit2 == it);
|
||||
BOOST_TEST(end3 == end1);
|
||||
}
|
||||
|
||||
void iterator_reference_test() {
|
||||
|
||||
@@ -233,7 +233,7 @@ void fifo_test(Buffer* buffer) {
|
||||
|
||||
// Initialize the buffer with some values before launching producer and consumer threads.
|
||||
for (unsigned long i = QUEUE_SIZE / 2L; i > 0; --i) {
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x581))
|
||||
buffer->push_front(Buffer::value_type());
|
||||
#else
|
||||
buffer->push_front(BOOST_DEDUCED_TYPENAME Buffer::value_type());
|
||||
|
||||
@@ -236,6 +236,9 @@ public:
|
||||
void destroy(value_type* ptr)
|
||||
{ ptr->~value_type(); }
|
||||
|
||||
size_type max_size() const {
|
||||
return ~static_cast<size_type>(0) / sizeof(size_type);
|
||||
}
|
||||
};
|
||||
|
||||
void allocator_test() {
|
||||
@@ -254,7 +257,7 @@ void allocator_test() {
|
||||
generic_test(cb_a);
|
||||
}
|
||||
|
||||
#if !defined(BOOST_CB_NO_CXX11_ALLOCATOR)
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<class T>
|
||||
class cxx11_allocator {
|
||||
public:
|
||||
@@ -2487,7 +2490,7 @@ void run_common_tests()
|
||||
move_container_on_cpp11();
|
||||
move_container_values_noexcept();
|
||||
check_containers_exception_specifications();
|
||||
#if !defined(BOOST_CB_NO_CXX11_ALLOCATOR)
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
cxx11_allocator_test();
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user