mirror of
https://github.com/boostorg/circular_buffer.git
synced 2026-02-03 09:02:12 +00:00
Compare commits
58 Commits
boost-1.63
...
boost-1.86
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a08a5b55ee | ||
|
|
05a83223e4 | ||
|
|
6c5ebd98a0 | ||
|
|
d99ba9ae43 | ||
|
|
d4fbf446b9 | ||
|
|
9579999506 | ||
|
|
adf0d87681 | ||
|
|
2b15dc6044 | ||
|
|
59640fa9dc | ||
|
|
50d29f7e70 | ||
|
|
eed21df804 | ||
|
|
01788c32e0 | ||
|
|
e77766b4a6 | ||
|
|
dae0d6638e | ||
|
|
466b40ab55 | ||
|
|
57a6351e25 | ||
|
|
8e23f4229f | ||
|
|
7808ab19dc | ||
|
|
7be41ca8f9 | ||
|
|
6ccd04cd89 | ||
|
|
7e56abf99b | ||
|
|
0818faec5c | ||
|
|
7cdb7b260c | ||
|
|
81e4b9590f | ||
|
|
3d3b5bffd4 | ||
|
|
03a5c8494e | ||
|
|
14379c5eac | ||
|
|
061ac223a1 | ||
|
|
3dc0e1c56b | ||
|
|
b07fbd056a | ||
|
|
d1e113f441 | ||
|
|
c084535786 | ||
|
|
2433adc0ec | ||
|
|
f10876014a | ||
|
|
187f4db314 | ||
|
|
37a7b2c0d5 | ||
|
|
2b7cb8fe8b | ||
|
|
fc3e2cd1bc | ||
|
|
28e32ba5e8 | ||
|
|
ca3d6678ee | ||
|
|
c0b613f8bb | ||
|
|
97ef4e0e19 | ||
|
|
a3317ecd15 | ||
|
|
7572374d3b | ||
|
|
f66c723e1e | ||
|
|
bad3f6a8ec | ||
|
|
78735e27a0 | ||
|
|
541a0e99fb | ||
|
|
3b9280c0e0 | ||
|
|
4ef6e8d1f6 | ||
|
|
14b50f574a | ||
|
|
5c5bef6cee | ||
|
|
2a3e26ff63 | ||
|
|
e655fa6c4d | ||
|
|
70664ea403 | ||
|
|
a2a85b57d4 | ||
|
|
ef8c59c4a6 | ||
|
|
31aa9939b3 |
286
.travis.yml
Normal file
286
.travis.yml
Normal file
@@ -0,0 +1,286 @@
|
||||
# Copyright 2018 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
dist: trusty
|
||||
|
||||
python: "2.7"
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BOGUS_JOB=true
|
||||
|
||||
matrix:
|
||||
|
||||
exclude:
|
||||
- env: BOGUS_JOB=true
|
||||
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.4
|
||||
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.4
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.6
|
||||
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.7
|
||||
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.8
|
||||
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.9
|
||||
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-8
|
||||
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:
|
||||
- g++-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
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
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.5
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.5
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.6
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.6
|
||||
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
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.9
|
||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.9
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.9
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-4.0
|
||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-4.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-4.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-5.0
|
||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-5.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-5.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-6.0
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
sources:
|
||||
- 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
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
|
||||
install:
|
||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
- cd ..
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost
|
||||
- cd boost
|
||||
- git submodule update --init tools/build
|
||||
- git submodule update --init libs/config
|
||||
- git submodule update --init tools/boostdep
|
||||
- mkdir -p libs/circular_buffer
|
||||
- cp -r $TRAVIS_BUILD_DIR/* libs/circular_buffer
|
||||
- python tools/boostdep/depinst/depinst.py circular_buffer
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- ./b2 -j 3 libs/circular_buffer/test toolset=$TOOLSET cxxstd=$CXXSTD
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: always
|
||||
26
CMakeLists.txt
Normal file
26
CMakeLists.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
# Copyright 2018 Glen Joseph Fernandes
|
||||
# (glenjofe@gmail.com)
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.20)
|
||||
|
||||
project(boost_circular_buffer VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
add_library(boost_circular_buffer INTERFACE)
|
||||
|
||||
add_library(Boost::circular_buffer ALIAS boost_circular_buffer)
|
||||
|
||||
target_include_directories(boost_circular_buffer INTERFACE include)
|
||||
|
||||
target_link_libraries(boost_circular_buffer INTERFACE
|
||||
Boost::assert
|
||||
Boost::concept_check
|
||||
Boost::config
|
||||
Boost::core
|
||||
Boost::move
|
||||
Boost::static_assert
|
||||
Boost::throw_exception
|
||||
Boost::type_traits
|
||||
)
|
||||
48
appveyor.yml
Normal file
48
appveyor.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
# Copyright 2018 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
version: 1.0.{build}-{branch}
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-9.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-10.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-11.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-12.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-14.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
CXXSTD: 14,17
|
||||
|
||||
install:
|
||||
- set BOOST_BRANCH=develop
|
||||
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
|
||||
- cd ..
|
||||
- git clone -b %BOOST_BRANCH% https://github.com/boostorg/boost.git boost
|
||||
- cd boost
|
||||
- git submodule update --init tools/build
|
||||
- git submodule update --init libs/config
|
||||
- git submodule update --init tools/boostdep
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\circular_buffer\
|
||||
- python tools/boostdep/depinst/depinst.py circular_buffer
|
||||
- cmd /c bootstrap
|
||||
- b2 headers
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- b2 -j 3 libs/circular_buffer/test toolset=%TOOLSET% %CXXSTD%
|
||||
@@ -46,7 +46,7 @@
|
||||
[def __min_capacity [memberref boost::circular_buffer_space_optimized::min_capacity() min_capacity]]
|
||||
[def __capacity_control [memberref boost::circular_buffer_space_optimized::capacity_control () capacity_control ]]
|
||||
|
||||
[def __debug_support [link circular_buffer.implmentation.debug_support debug support]]
|
||||
[def __debug_support [link circular_buffer.implementation.debug_support debug support]]
|
||||
|
||||
[include ../../../tools/auto_index/include/auto_index_helpers.qbk]
|
||||
[/ Must be first included file!]
|
||||
@@ -67,8 +67,8 @@ new data is written starting at the beginning of the buffer and overwriting the
|
||||
|
||||
[classref boost::circular_buffer] is a STL compliant container.
|
||||
|
||||
It is a kind of sequence similar to [@http://www.sgi.com/tech/stl/List.html std::list]
|
||||
or [@http://www.sgi.com/tech/stl/Deque.html std::deque].
|
||||
It is a kind of sequence similar to [@https://www.boost.org/sgi/stl/List.html std::list]
|
||||
or [@https://www.boost.org/sgi/stl/Deque.html std::deque].
|
||||
It supports random access iterators, constant time insert and erase operations
|
||||
at the beginning or the end of the buffer and interoperability with std algorithms.
|
||||
|
||||
@@ -114,7 +114,7 @@ Here is a simple example to introduce the class __cb.
|
||||
|
||||
[circular_buffer_example_1]
|
||||
|
||||
This example shows contruction, inserting elements, overwriting and popping.
|
||||
This example shows construction, inserting elements, overwriting and popping.
|
||||
|
||||
[circular_buffer_example_2]
|
||||
|
||||
@@ -363,7 +363,7 @@ The __cb is compatible with the [@boost:libs/interprocess/index.html Boost.Inte
|
||||
[/ This should be in @boost:libs/interprocess/doc/index.html ]
|
||||
library used for interprocess communication.
|
||||
Considering that the circular_buffer's debug support relies on 'raw' pointers
|
||||
(which is not permited by the Interprocess library)
|
||||
(which is not permitted by the Interprocess library)
|
||||
the code has to compiled with debug support disabled (i.e. with `BOOST_CB_ENABLE_DEBUG` macro not defined or defined to 0).
|
||||
Not doing that will cause the compilation to fail.
|
||||
|
||||
@@ -470,9 +470,9 @@ The __cbso is defined in the file [@boost:boost/circular_buffer/space_optimized.
|
||||
|
||||
[section:concepts Modelled Concepts]
|
||||
|
||||
[@http://www.sgi.com/tech/stl/RandomAccessContainer.html Random Access Container],
|
||||
[@http://www.sgi.com/tech/stl/FrontInsertionSequence.html Front Insertion Sequence], and
|
||||
[@http://www.sgi.com/tech/stl/BackInsertionSequence.html Back Insertion sequence]
|
||||
[@https://www.boost.org/sgi/stl/RandomAccessContainer.html Random Access Container],
|
||||
[@https://www.boost.org/sgi/stl/FrontInsertionSequence.html Front Insertion Sequence], and
|
||||
[@https://www.boost.org/sgi/stl/BackInsertionSequence.html Back Insertion sequence]
|
||||
|
||||
[endsect] [/section:concepts Modelled Concepts]
|
||||
|
||||
@@ -483,10 +483,10 @@ The __cbso is defined in the file [@boost:boost/circular_buffer/space_optimized.
|
||||
[[T] [The type of the elements stored in the circular_buffer.
|
||||
The T has to be [@boost:libs/utility/Assignable.html Assignable]
|
||||
and [@boost:libs/utility/CopyConstructible.html CopyConstructible].
|
||||
Moreover T has to be [@http://www.sgi.com/tech/stl/DefaultConstructible.html DefaultConstructible]
|
||||
Moreover T has to be [@https://www.boost.org/sgi/stl/DefaultConstructible.html DefaultConstructible]
|
||||
if supplied as a default parameter when invoking some of the circular_buffer's methods,
|
||||
e.g. `insert(iterator pos, const value_type& item = value_type())`.
|
||||
And [@http://www.sgi.com/tech/stl/EqualityComparable.html EqualityComparable]
|
||||
And [@https://www.boost.org/sgi/stl/EqualityComparable.html EqualityComparable]
|
||||
and/or [@boost:libs/utility/LessThanComparable.html LessThanComparable]
|
||||
if the circular_buffer will be compared with another container.]]
|
||||
[[Alloc] [The allocator type used for all internal memory management.
|
||||
@@ -538,7 +538,7 @@ Type: Patches
|
||||
|
||||
[h4 Boost 1.56]
|
||||
|
||||
* C++11 allocator model support implemented by Glen Fernandes using Boost allocator_traits.
|
||||
* C++11 allocator model support implemented by Glen Fernandes.
|
||||
|
||||
[h4 Boost 1.55]
|
||||
|
||||
|
||||
@@ -29,8 +29,6 @@ doxygen autodoc
|
||||
[ glob ../../../boost/circular_buffer.hpp ]
|
||||
[ glob ../../../boost/circular_buffer/base.hpp ]
|
||||
[ glob ../../../boost/circular_buffer/space_optimized.hpp ]
|
||||
[ glob ../../../boost/circular_buffer/details.hpp ] # Needed for capacity_control at least.
|
||||
[ glob ../../../boost/circular_buffer/debug.hpp ] # not needed?
|
||||
|
||||
:
|
||||
# Pass some setting parameters to Doxygen.
|
||||
@@ -83,8 +81,8 @@ doxygen autodoc
|
||||
|
||||
# The syntax hoops to jump through are 'interesting' for more than one PREDEFINED,
|
||||
# and to permit spaces within definitions (use double quotes).
|
||||
# Don't forget that every double quote " needs a preceeding \trip character!
|
||||
# and that each trailing continuation \ needs a preceeding \trip character too!
|
||||
# Don't forget that every double quote " needs a preceding \trip character!
|
||||
# and that each trailing continuation \ needs a preceding \trip character too!
|
||||
# And finally that if more than one item is included (as here) the whole is
|
||||
# enclosed in "PREDEFINED=... ", but without a leading \. Go figure...
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/condition.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/timer/timer.hpp>
|
||||
#include <boost/call_traits.hpp>
|
||||
#include <boost/progress.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <deque>
|
||||
#include <list>
|
||||
@@ -229,11 +229,11 @@ template<class Buffer>
|
||||
void fifo_test(Buffer* buffer) {
|
||||
|
||||
// Start of measurement
|
||||
boost::progress_timer progress;
|
||||
boost::timer::auto_cpu_timer progress;
|
||||
|
||||
// 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());
|
||||
|
||||
@@ -19,6 +19,7 @@ as an underlying container of the bounded buffer.
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include <boost/timer/timer.hpp> // for auto_cpu_timer
|
||||
#include <iostream>
|
||||
|
||||
template <class T>
|
||||
class bounded_buffer
|
||||
@@ -135,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());
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
// Create a circular buffer with a capacity for 3 integers.
|
||||
boost::circular_buffer<int> cb(3);
|
||||
|
||||
// Insert threee elements into the buffer.
|
||||
// Insert three elements into the buffer.
|
||||
cb.push_back(1);
|
||||
cb.push_back(2);
|
||||
cb.push_back(3);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
echo off
|
||||
rem quickbook doxgen auto-index docs template circular_buffer_html_index.bat
|
||||
rem quickbook doxygen auto-index docs template circular_buffer_html_index.bat
|
||||
rem echo circular_buffer_html_index_%date%_%time:~0,2%_%time:~3,2%.log
|
||||
rem The DOS time format is assumed 12:34 and the : separator is not used.
|
||||
set t=%time% /T
|
||||
|
||||
@@ -35,7 +35,7 @@ project
|
||||
<toolset>msvc:<cxxflags>/wd4305
|
||||
;
|
||||
|
||||
run bounded_buffer_comparison.cpp ;
|
||||
run bounded_buffer_comparison.cpp ../../timer/build//boost_timer ;
|
||||
run circular_buffer_iter_example.cpp ;
|
||||
run circular_buffer_sum_example.cpp ;
|
||||
run circular_buffer_bound_example.cpp ../../thread/build//boost_thread ../../timer/build//boost_timer ;
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
|
||||
// See www.boost.org/libs/circular_buffer for documentation.
|
||||
|
||||
/*! @file
|
||||
Includes <boost/circular_buffer/base.hpp>
|
||||
*/
|
||||
|
||||
#if !defined(BOOST_CIRCULAR_BUFFER_HPP)
|
||||
#define BOOST_CIRCULAR_BUFFER_HPP
|
||||
|
||||
@@ -16,15 +20,15 @@
|
||||
#endif
|
||||
|
||||
#include <boost/circular_buffer_fwd.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
// BOOST_CB_ENABLE_DEBUG: Debug support control.
|
||||
/*! Debug support control. */
|
||||
#if !defined(BOOST_CB_ENABLE_DEBUG)
|
||||
#define BOOST_CB_ENABLE_DEBUG 0
|
||||
#endif
|
||||
|
||||
// BOOST_CB_ASSERT: Runtime assertion.
|
||||
/*! INTERNAL ONLY */
|
||||
#if BOOST_CB_ENABLE_DEBUG
|
||||
#include <boost/assert.hpp>
|
||||
#define BOOST_CB_ASSERT(Expr) BOOST_ASSERT(Expr)
|
||||
@@ -32,18 +36,17 @@
|
||||
#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)
|
||||
/*! INTERNAL ONLY */
|
||||
#if BOOST_WORKAROUND(BOOST_BORLANDC, <= 0x0550) || BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||
#define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) ((void)0)
|
||||
#else
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <iterator>
|
||||
#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_STATIC_ASSERT((is_convertible<typename std::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.
|
||||
/*! INTERNAL ONLY */
|
||||
#if defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
|
||||
#define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS BOOST_STATIC_ASSERT(false);
|
||||
#else
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,9 @@
|
||||
// Helper classes and functions for the circular buffer.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
// Copyright (c) 2014 Glen Fernandes // C++11 allocator model support.
|
||||
|
||||
// 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
|
||||
@@ -15,11 +17,11 @@
|
||||
#endif
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/container/allocator_traits.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/utility/addressof.hpp>
|
||||
#include <boost/detail/no_exceptions_support.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <iterator>
|
||||
|
||||
// Silence MS /W4 warnings like C4913:
|
||||
@@ -34,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(
|
||||
@@ -50,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 Traits::const_reference reference;
|
||||
typedef typename Traits::size_type size_type;
|
||||
typedef typename Traits::difference_type difference_type;
|
||||
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<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 Traits::reference reference;
|
||||
typedef typename Traits::size_type size_type;
|
||||
typedef typename Traits::difference_type difference_type;
|
||||
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<Traits> nonconst_self;
|
||||
typedef nonconst_traits<Alloc> nonconst_self;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -112,7 +114,7 @@ private:
|
||||
*/
|
||||
template <class Value, class Alloc>
|
||||
struct assign_n {
|
||||
typedef typename boost::container::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;
|
||||
@@ -194,46 +196,33 @@ public:
|
||||
for iterating from begin() to end() of the circular buffer.
|
||||
*/
|
||||
template <class Buff, class Traits>
|
||||
struct iterator :
|
||||
public std::iterator<
|
||||
std::random_access_iterator_tag,
|
||||
typename Traits::value_type,
|
||||
typename Traits::difference_type,
|
||||
typename Traits::pointer,
|
||||
typename Traits::reference>
|
||||
struct iterator
|
||||
#if BOOST_CB_ENABLE_DEBUG
|
||||
, public debug_iterator_base
|
||||
: public debug_iterator_base
|
||||
#endif // #if BOOST_CB_ENABLE_DEBUG
|
||||
{
|
||||
// Helper types
|
||||
|
||||
//! Base iterator.
|
||||
typedef std::iterator<
|
||||
std::random_access_iterator_tag,
|
||||
typename Traits::value_type,
|
||||
typename Traits::difference_type,
|
||||
typename Traits::pointer,
|
||||
typename Traits::reference> base_iterator;
|
||||
|
||||
//! 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 base_iterator::value_type value_type;
|
||||
typedef typename Traits::value_type value_type;
|
||||
|
||||
//! Pointer to the element.
|
||||
typedef typename base_iterator::pointer pointer;
|
||||
typedef typename Traits::pointer pointer;
|
||||
|
||||
//! Reference to the element.
|
||||
typedef typename base_iterator::reference reference;
|
||||
typedef typename Traits::reference reference;
|
||||
|
||||
//! Size type.
|
||||
typedef typename Traits::size_type size_type;
|
||||
|
||||
//! Difference type.
|
||||
typedef typename base_iterator::difference_type difference_type;
|
||||
typedef typename Traits::difference_type difference_type;
|
||||
|
||||
// Member variables
|
||||
|
||||
@@ -270,7 +259,10 @@ struct iterator :
|
||||
#endif // #if BOOST_CB_ENABLE_DEBUG
|
||||
|
||||
//! Assign operator.
|
||||
iterator& operator = (const iterator& it) {
|
||||
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
|
||||
iterator& operator=(const iterator&) = default;
|
||||
#else
|
||||
iterator& operator=(const iterator& it) {
|
||||
if (this == &it)
|
||||
return *this;
|
||||
#if BOOST_CB_ENABLE_DEBUG
|
||||
@@ -280,6 +272,7 @@ struct iterator :
|
||||
m_it = it.m_it;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Random access iterator methods
|
||||
|
||||
@@ -435,10 +428,10 @@ inline ForwardIterator uninitialized_copy(InputIterator first, InputIterator las
|
||||
ForwardIterator next = dest;
|
||||
BOOST_TRY {
|
||||
for (; first != last; ++first, ++dest)
|
||||
boost::container::allocator_traits<Alloc>::construct(a, boost::addressof(*dest), *first);
|
||||
boost::allocator_construct(a, boost::to_address(dest), *first);
|
||||
} BOOST_CATCH(...) {
|
||||
for (; next != dest; ++next)
|
||||
boost::container::allocator_traits<Alloc>::destroy(a, boost::addressof(*next));
|
||||
boost::allocator_destroy(a, boost::to_address(next));
|
||||
BOOST_RETHROW
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
@@ -449,7 +442,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)
|
||||
boost::container::allocator_traits<Alloc>::construct(a, boost::addressof(*dest), boost::move(*first));
|
||||
boost::allocator_construct(a, boost::to_address(dest), boost::move(*first));
|
||||
return dest;
|
||||
}
|
||||
|
||||
@@ -465,7 +458,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 boost::container::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());
|
||||
}
|
||||
|
||||
@@ -478,10 +471,10 @@ inline void uninitialized_fill_n_with_alloc(ForwardIterator first, Diff n, const
|
||||
ForwardIterator next = first;
|
||||
BOOST_TRY {
|
||||
for (; n > 0; ++first, --n)
|
||||
boost::container::allocator_traits<Alloc>::construct(alloc, boost::addressof(*first), item);
|
||||
boost::allocator_construct(alloc, boost::to_address(first), item);
|
||||
} BOOST_CATCH(...) {
|
||||
for (; next != first; ++next)
|
||||
boost::container::allocator_traits<Alloc>::destroy(alloc, boost::addressof(*next));
|
||||
boost::allocator_destroy(alloc, boost::to_address(next));
|
||||
BOOST_RETHROW
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#endif
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -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
|
||||
@@ -453,7 +453,7 @@ public:
|
||||
/*!
|
||||
\pre Valid range <code>[first, last)</code>.<br>
|
||||
<code>first</code> and <code>last</code> have to meet the requirements of
|
||||
<a href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>.
|
||||
<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>
|
||||
@@ -478,7 +478,7 @@ public:
|
||||
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="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>.
|
||||
<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>
|
||||
@@ -499,7 +499,7 @@ public:
|
||||
\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="http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>).
|
||||
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,
|
||||
@@ -509,7 +509,7 @@ 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 std::iterator_traits<InputIterator>::iterator_category, std::input_iterator_tag >());
|
||||
}
|
||||
|
||||
#if defined(BOOST_CB_NEVER_DEFINED)
|
||||
@@ -579,7 +579,7 @@ public:
|
||||
*/
|
||||
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()) // temprary that holds initial `cb` allocator
|
||||
circular_buffer<T, Alloc>(get_allocator()) // temporary that holds initial `cb` allocator
|
||||
.swap(cb); // makes `cb` empty
|
||||
return *this;
|
||||
}
|
||||
@@ -655,7 +655,7 @@ public:
|
||||
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="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>.
|
||||
<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>
|
||||
@@ -692,7 +692,7 @@ public:
|
||||
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="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>.
|
||||
<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>
|
||||
@@ -715,7 +715,7 @@ public:
|
||||
\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="http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>).
|
||||
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)
|
||||
@@ -1114,7 +1114,7 @@ public:
|
||||
/*!
|
||||
\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="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>.
|
||||
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,
|
||||
@@ -1136,7 +1136,7 @@ public:
|
||||
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="http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</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>
|
||||
@@ -1326,7 +1326,7 @@ public:
|
||||
\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="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>.
|
||||
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,
|
||||
@@ -1349,7 +1349,7 @@ public:
|
||||
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="http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</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>
|
||||
@@ -1522,7 +1522,7 @@ public:
|
||||
private:
|
||||
// Helper methods
|
||||
|
||||
//! Adjust the amount of allocated memory.
|
||||
/*! 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());
|
||||
@@ -1530,7 +1530,7 @@ private:
|
||||
check_high_capacity();
|
||||
}
|
||||
|
||||
//! Ensure the reserve for possible growth up.
|
||||
/*! 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
|
||||
@@ -1539,10 +1539,7 @@ private:
|
||||
return new_capacity;
|
||||
}
|
||||
|
||||
//! Check for low capacity.
|
||||
/*
|
||||
\post If the capacity is low it will be increased.
|
||||
*/
|
||||
/*! 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();
|
||||
@@ -1558,10 +1555,7 @@ private:
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Check for high capacity.
|
||||
/*
|
||||
\post If the capacity is high it will be decreased.
|
||||
*/
|
||||
/*! 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
|
||||
@@ -1578,48 +1572,48 @@ private:
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Specialized method for reducing the capacity.
|
||||
/*! INTERNAL ONLY */
|
||||
void reduce_capacity(const true_type&) {
|
||||
circular_buffer<T, Alloc>::set_capacity((std::max)(m_capacity_ctrl.min_capacity(), size()));
|
||||
}
|
||||
|
||||
//! Specialized method for reducing the capacity.
|
||||
/*! INTERNAL ONLY */
|
||||
void reduce_capacity(const false_type&) {}
|
||||
|
||||
//! Determine the initial capacity.
|
||||
/*! 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);
|
||||
}
|
||||
|
||||
//! Specialized method for determining the initial capacity.
|
||||
/*! 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));
|
||||
}
|
||||
|
||||
//! Specialized method for determining the initial capacity.
|
||||
/*! 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(__BORLANDC__, BOOST_TESTED_AT(0x581))
|
||||
return init_capacity(capacity_ctrl, first, last, iterator_category<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 iterator_category<Iterator>::type());
|
||||
capacity_ctrl, first, last, BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::iterator_category());
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Specialized method for determining the initial capacity.
|
||||
/*! 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();
|
||||
}
|
||||
|
||||
//! Specialized method for determining the initial 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&) {
|
||||
@@ -1628,13 +1622,13 @@ private:
|
||||
(std::min)(capacity_ctrl.capacity(), static_cast<size_type>(std::distance(first, last))));
|
||||
}
|
||||
|
||||
//! Specialized insert method.
|
||||
/*! 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));
|
||||
}
|
||||
|
||||
//! Specialized insert method.
|
||||
/*! INTERNAL ONLY */
|
||||
template <class Iterator>
|
||||
void insert(const iterator& pos, Iterator first, Iterator last, const false_type&) {
|
||||
size_type index = pos - begin();
|
||||
@@ -1642,13 +1636,13 @@ private:
|
||||
circular_buffer<T, Alloc>::insert(begin() + index, first, last);
|
||||
}
|
||||
|
||||
//! Specialized rinsert method.
|
||||
/*! 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));
|
||||
}
|
||||
|
||||
//! Specialized rinsert method.
|
||||
/*! INTERNAL ONLY */
|
||||
template <class Iterator>
|
||||
void rinsert(const iterator& pos, Iterator first, Iterator last, const false_type&) {
|
||||
size_type index = pos - begin();
|
||||
|
||||
@@ -10,5 +10,6 @@
|
||||
],
|
||||
"maintainers": [
|
||||
"Jan Gaspar <jano_gaspar -at- yahoo.com>"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,8 +11,8 @@
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/timer/timer.hpp>
|
||||
#include <boost/call_traits.hpp>
|
||||
#include <boost/progress.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <deque>
|
||||
#include <list>
|
||||
@@ -229,11 +229,11 @@ template<class Buffer>
|
||||
void fifo_test(Buffer* buffer) {
|
||||
|
||||
// Start of measurement
|
||||
boost::progress_timer progress;
|
||||
boost::timer::auto_cpu_timer progress;
|
||||
|
||||
// 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());
|
||||
|
||||
1754
test/common.ipp
1754
test/common.ipp
File diff suppressed because it is too large
Load Diff
@@ -25,35 +25,35 @@ void erase_begin_test() {
|
||||
|
||||
cb1.erase_begin(2);
|
||||
|
||||
BOOST_CHECK(cb1.size() == 3);
|
||||
BOOST_CHECK(cb1[0] == 4);
|
||||
BOOST_CHECK(cb1[1] == 5);
|
||||
BOOST_CHECK(cb1[2] == 6);
|
||||
BOOST_TEST(cb1.size() == 3);
|
||||
BOOST_TEST(cb1[0] == 4);
|
||||
BOOST_TEST(cb1[1] == 5);
|
||||
BOOST_TEST(cb1[2] == 6);
|
||||
|
||||
cb1.erase_begin(3);
|
||||
BOOST_CHECK(cb1.empty());
|
||||
BOOST_CHECK(*p == 2);
|
||||
BOOST_CHECK(*(p + 1) == 3);
|
||||
BOOST_CHECK(*(p + 2) == 4);
|
||||
BOOST_TEST(cb1.empty());
|
||||
BOOST_TEST(*p == 2);
|
||||
BOOST_TEST(*(p + 1) == 3);
|
||||
BOOST_TEST(*(p + 2) == 4);
|
||||
|
||||
cb1.push_back(10);
|
||||
cb1.push_back(11);
|
||||
cb1.push_back(12);
|
||||
|
||||
BOOST_CHECK(cb1.size() == 3);
|
||||
BOOST_CHECK(cb1[0] == 10);
|
||||
BOOST_CHECK(cb1[1] == 11);
|
||||
BOOST_CHECK(cb1[2] == 12);
|
||||
BOOST_TEST(cb1.size() == 3);
|
||||
BOOST_TEST(cb1[0] == 10);
|
||||
BOOST_TEST(cb1[1] == 11);
|
||||
BOOST_TEST(cb1[2] == 12);
|
||||
|
||||
circular_buffer<InstanceCounter> cb2(5, InstanceCounter());
|
||||
|
||||
BOOST_CHECK(cb2.size() == 5);
|
||||
BOOST_CHECK(InstanceCounter::count() == 5);
|
||||
BOOST_TEST(cb2.size() == 5);
|
||||
BOOST_TEST(InstanceCounter::count() == 5);
|
||||
|
||||
cb2.erase_begin(2);
|
||||
|
||||
BOOST_CHECK(cb2.size() == 3);
|
||||
BOOST_CHECK(InstanceCounter::count() == 3);
|
||||
BOOST_TEST(cb2.size() == 3);
|
||||
BOOST_TEST(InstanceCounter::count() == 3);
|
||||
|
||||
circular_buffer<MyInteger> cb3(5);
|
||||
cb3.push_back(1);
|
||||
@@ -64,10 +64,10 @@ void erase_begin_test() {
|
||||
cb3.push_back(6);
|
||||
cb3.erase_begin(2);
|
||||
|
||||
BOOST_CHECK(cb3.size() == 3);
|
||||
BOOST_CHECK(cb3[0] == 4);
|
||||
BOOST_CHECK(cb3[1] == 5);
|
||||
BOOST_CHECK(cb3[2] == 6);
|
||||
BOOST_TEST(cb3.size() == 3);
|
||||
BOOST_TEST(cb3[0] == 4);
|
||||
BOOST_TEST(cb3[1] == 5);
|
||||
BOOST_TEST(cb3[2] == 6);
|
||||
}
|
||||
|
||||
void erase_end_test() {
|
||||
@@ -84,35 +84,35 @@ void erase_end_test() {
|
||||
|
||||
cb1.erase_end(2);
|
||||
|
||||
BOOST_CHECK(cb1.size() == 3);
|
||||
BOOST_CHECK(cb1[0] == 2);
|
||||
BOOST_CHECK(cb1[1] == 3);
|
||||
BOOST_CHECK(cb1[2] ==4);
|
||||
BOOST_TEST(cb1.size() == 3);
|
||||
BOOST_TEST(cb1[0] == 2);
|
||||
BOOST_TEST(cb1[1] == 3);
|
||||
BOOST_TEST(cb1[2] ==4);
|
||||
|
||||
cb1.erase_end(3);
|
||||
BOOST_CHECK(cb1.empty());
|
||||
BOOST_CHECK(*p == 5);
|
||||
BOOST_CHECK(*(p - 1) == 4);
|
||||
BOOST_CHECK(*(p - 2) == 3);
|
||||
BOOST_TEST(cb1.empty());
|
||||
BOOST_TEST(*p == 5);
|
||||
BOOST_TEST(*(p - 1) == 4);
|
||||
BOOST_TEST(*(p - 2) == 3);
|
||||
|
||||
cb1.push_back(10);
|
||||
cb1.push_back(11);
|
||||
cb1.push_back(12);
|
||||
|
||||
BOOST_CHECK(cb1.size() == 3);
|
||||
BOOST_CHECK(cb1[0] == 10);
|
||||
BOOST_CHECK(cb1[1] == 11);
|
||||
BOOST_CHECK(cb1[2] == 12);
|
||||
BOOST_TEST(cb1.size() == 3);
|
||||
BOOST_TEST(cb1[0] == 10);
|
||||
BOOST_TEST(cb1[1] == 11);
|
||||
BOOST_TEST(cb1[2] == 12);
|
||||
|
||||
circular_buffer<InstanceCounter> cb2(5, InstanceCounter());
|
||||
|
||||
BOOST_CHECK(cb2.size() == 5);
|
||||
BOOST_CHECK(InstanceCounter::count() == 5);
|
||||
BOOST_TEST(cb2.size() == 5);
|
||||
BOOST_TEST(InstanceCounter::count() == 5);
|
||||
|
||||
cb2.erase_end(2);
|
||||
|
||||
BOOST_CHECK(cb2.size() == 3);
|
||||
BOOST_CHECK(InstanceCounter::count() == 3);
|
||||
BOOST_TEST(cb2.size() == 3);
|
||||
BOOST_TEST(InstanceCounter::count() == 3);
|
||||
|
||||
circular_buffer<MyInteger> cb3(5);
|
||||
cb3.push_back(1);
|
||||
@@ -123,10 +123,10 @@ void erase_end_test() {
|
||||
cb3.push_back(6);
|
||||
cb3.erase_end(2);
|
||||
|
||||
BOOST_CHECK(cb3.size() == 3);
|
||||
BOOST_CHECK(cb3[0] == 2);
|
||||
BOOST_CHECK(cb3[1] == 3);
|
||||
BOOST_CHECK(cb3[2] == 4);
|
||||
BOOST_TEST(cb3.size() == 3);
|
||||
BOOST_TEST(cb3[0] == 2);
|
||||
BOOST_TEST(cb3[1] == 3);
|
||||
BOOST_TEST(cb3[2] == 4);
|
||||
}
|
||||
|
||||
void clear_test() {
|
||||
@@ -143,22 +143,22 @@ void clear_test() {
|
||||
|
||||
cb1.clear();
|
||||
|
||||
BOOST_CHECK(cb1.empty());
|
||||
BOOST_CHECK(*p == 2);
|
||||
BOOST_CHECK(*(p + 1) == 3);
|
||||
BOOST_CHECK(*(p + 2) == 4);
|
||||
BOOST_CHECK(*(p + 3) == 5);
|
||||
BOOST_CHECK(*(p - 1) == 6);
|
||||
BOOST_TEST(cb1.empty());
|
||||
BOOST_TEST(*p == 2);
|
||||
BOOST_TEST(*(p + 1) == 3);
|
||||
BOOST_TEST(*(p + 2) == 4);
|
||||
BOOST_TEST(*(p + 3) == 5);
|
||||
BOOST_TEST(*(p - 1) == 6);
|
||||
|
||||
circular_buffer<InstanceCounter> cb2(5, InstanceCounter());
|
||||
|
||||
BOOST_CHECK(cb2.size() == 5);
|
||||
BOOST_CHECK(InstanceCounter::count() == 5);
|
||||
BOOST_TEST(cb2.size() == 5);
|
||||
BOOST_TEST(InstanceCounter::count() == 5);
|
||||
|
||||
cb2.clear();
|
||||
|
||||
BOOST_CHECK(cb2.empty());
|
||||
BOOST_CHECK(InstanceCounter::count() == 0);
|
||||
BOOST_TEST(cb2.empty());
|
||||
BOOST_TEST(InstanceCounter::count() == 0);
|
||||
|
||||
circular_buffer<MyInteger> cb3(5);
|
||||
cb3.push_back(1);
|
||||
@@ -169,17 +169,14 @@ void clear_test() {
|
||||
cb3.push_back(6);
|
||||
cb3.clear();
|
||||
|
||||
BOOST_CHECK(cb3.empty());
|
||||
BOOST_TEST(cb3.empty());
|
||||
}
|
||||
|
||||
// test main
|
||||
test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[]) {
|
||||
|
||||
test_suite* tests = BOOST_TEST_SUITE("Unit tests for erase_begin/end and clear methods of the circular_buffer.");
|
||||
|
||||
tests->add(BOOST_TEST_CASE(&erase_begin_test));
|
||||
tests->add(BOOST_TEST_CASE(&erase_end_test));
|
||||
tests->add(BOOST_TEST_CASE(&clear_test));
|
||||
|
||||
return tests;
|
||||
int main()
|
||||
{
|
||||
erase_begin_test();
|
||||
erase_end_test();
|
||||
clear_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ void validity_example_test() {
|
||||
|
||||
circular_buffer<int>::iterator it = cb.begin();
|
||||
|
||||
BOOST_CHECK(*it == 1);
|
||||
BOOST_TEST(*it == 1);
|
||||
|
||||
cb.push_back(4);
|
||||
|
||||
BOOST_CHECK(*it == 4);
|
||||
BOOST_TEST(*it == 4);
|
||||
}
|
||||
|
||||
void validity_insert_test() {
|
||||
@@ -46,13 +46,13 @@ void validity_insert_test() {
|
||||
|
||||
// memory placement: { 1, 4, 2, 3 }
|
||||
// circular buffer: { 1, 4, 2, 3 }
|
||||
BOOST_CHECK(*it1 == 1);
|
||||
BOOST_CHECK(*it2 == 4);
|
||||
BOOST_CHECK(*it3 == 2);
|
||||
BOOST_CHECK(cb[0] == 1);
|
||||
BOOST_CHECK(cb[1] == 4);
|
||||
BOOST_CHECK(cb[2] == 2);
|
||||
BOOST_CHECK(cb[3] == 3);
|
||||
BOOST_TEST(*it1 == 1);
|
||||
BOOST_TEST(*it2 == 4);
|
||||
BOOST_TEST(*it3 == 2);
|
||||
BOOST_TEST(cb[0] == 1);
|
||||
BOOST_TEST(cb[1] == 4);
|
||||
BOOST_TEST(cb[2] == 2);
|
||||
BOOST_TEST(cb[3] == 3);
|
||||
|
||||
// it4 -> 3
|
||||
circular_buffer<int>::iterator it4 = it1 + 3;
|
||||
@@ -61,14 +61,14 @@ void validity_insert_test() {
|
||||
|
||||
// memory placement: { 3, 5, 4, 2 }
|
||||
// circular buffer: { 5, 4, 2, 3 }
|
||||
BOOST_CHECK(*it1 == 3);
|
||||
BOOST_CHECK(*it2 == 5);
|
||||
BOOST_CHECK(*it3 == 4);
|
||||
BOOST_CHECK(*it4 == 2);
|
||||
BOOST_CHECK(cb[0] == 5);
|
||||
BOOST_CHECK(cb[1] == 4);
|
||||
BOOST_CHECK(cb[2] == 2);
|
||||
BOOST_CHECK(cb[3] == 3);
|
||||
BOOST_TEST(*it1 == 3);
|
||||
BOOST_TEST(*it2 == 5);
|
||||
BOOST_TEST(*it3 == 4);
|
||||
BOOST_TEST(*it4 == 2);
|
||||
BOOST_TEST(cb[0] == 5);
|
||||
BOOST_TEST(cb[1] == 4);
|
||||
BOOST_TEST(cb[2] == 2);
|
||||
BOOST_TEST(cb[3] == 3);
|
||||
}
|
||||
|
||||
void validity_insert_n_test() {
|
||||
@@ -89,14 +89,14 @@ void validity_insert_n_test() {
|
||||
|
||||
// memory placement: { 1, 4, 4, 2, 3 }
|
||||
// circular buffer: { 1, 4, 4, 2, 3 }
|
||||
BOOST_CHECK(*it1 == 1);
|
||||
BOOST_CHECK(*it2 == 4);
|
||||
BOOST_CHECK(*it3 == 4);
|
||||
BOOST_CHECK(cb[0] == 1);
|
||||
BOOST_CHECK(cb[1] == 4);
|
||||
BOOST_CHECK(cb[2] == 4);
|
||||
BOOST_CHECK(cb[3] == 2);
|
||||
BOOST_CHECK(cb[4] == 3);
|
||||
BOOST_TEST(*it1 == 1);
|
||||
BOOST_TEST(*it2 == 4);
|
||||
BOOST_TEST(*it3 == 4);
|
||||
BOOST_TEST(cb[0] == 1);
|
||||
BOOST_TEST(cb[1] == 4);
|
||||
BOOST_TEST(cb[2] == 4);
|
||||
BOOST_TEST(cb[3] == 2);
|
||||
BOOST_TEST(cb[4] == 3);
|
||||
|
||||
// it4 -> 2, it5 -> 3
|
||||
circular_buffer<int>::iterator it4 = it1 + 3;
|
||||
@@ -106,16 +106,16 @@ void validity_insert_n_test() {
|
||||
|
||||
// memory placement: { 3, 5, 4, 4, 2 } - 5 inserted only once
|
||||
// circular buffer: { 5, 4, 4, 2, 3 }
|
||||
BOOST_CHECK(*it1 == 3);
|
||||
BOOST_CHECK(*it2 == 5);
|
||||
BOOST_CHECK(*it3 == 4);
|
||||
BOOST_CHECK(*it4 == 4);
|
||||
BOOST_CHECK(*it5 == 2);
|
||||
BOOST_CHECK(cb[0] == 5);
|
||||
BOOST_CHECK(cb[1] == 4);
|
||||
BOOST_CHECK(cb[2] == 4);
|
||||
BOOST_CHECK(cb[3] == 2);
|
||||
BOOST_CHECK(cb[4] == 3);
|
||||
BOOST_TEST(*it1 == 3);
|
||||
BOOST_TEST(*it2 == 5);
|
||||
BOOST_TEST(*it3 == 4);
|
||||
BOOST_TEST(*it4 == 4);
|
||||
BOOST_TEST(*it5 == 2);
|
||||
BOOST_TEST(cb[0] == 5);
|
||||
BOOST_TEST(cb[1] == 4);
|
||||
BOOST_TEST(cb[2] == 4);
|
||||
BOOST_TEST(cb[3] == 2);
|
||||
BOOST_TEST(cb[4] == 3);
|
||||
}
|
||||
|
||||
void validity_insert_range_test() {
|
||||
@@ -145,14 +145,14 @@ void validity_insert_range_test() {
|
||||
|
||||
// memory placement: { 1, 4, 5, 2, 3 }
|
||||
// circular buffer: { 1, 4, 5, 2, 3 }
|
||||
BOOST_CHECK(*it11 == 1);
|
||||
BOOST_CHECK(*it12 == 4);
|
||||
BOOST_CHECK(*it13 == 5);
|
||||
BOOST_CHECK(cb1[0] == 1);
|
||||
BOOST_CHECK(cb1[1] == 4);
|
||||
BOOST_CHECK(cb1[2] == 5);
|
||||
BOOST_CHECK(cb1[3] == 2);
|
||||
BOOST_CHECK(cb1[4] == 3);
|
||||
BOOST_TEST(*it11 == 1);
|
||||
BOOST_TEST(*it12 == 4);
|
||||
BOOST_TEST(*it13 == 5);
|
||||
BOOST_TEST(cb1[0] == 1);
|
||||
BOOST_TEST(cb1[1] == 4);
|
||||
BOOST_TEST(cb1[2] == 5);
|
||||
BOOST_TEST(cb1[3] == 2);
|
||||
BOOST_TEST(cb1[4] == 3);
|
||||
|
||||
// it14 -> 2, it15 -> 3
|
||||
circular_buffer<int>::iterator it14 = it11 + 3;
|
||||
@@ -162,16 +162,16 @@ void validity_insert_range_test() {
|
||||
|
||||
// memory placement: { 3, 7, 4, 5, 2 } - 7 inserted only
|
||||
// circular buffer: { 7, 4, 5, 2, 3 }
|
||||
BOOST_CHECK(*it11 == 3);
|
||||
BOOST_CHECK(*it12 == 7);
|
||||
BOOST_CHECK(*it13 == 4);
|
||||
BOOST_CHECK(*it14 == 5);
|
||||
BOOST_CHECK(*it15 == 2);
|
||||
BOOST_CHECK(cb1[0] == 7);
|
||||
BOOST_CHECK(cb1[1] == 4);
|
||||
BOOST_CHECK(cb1[2] == 5);
|
||||
BOOST_CHECK(cb1[3] == 2);
|
||||
BOOST_CHECK(cb1[4] == 3);
|
||||
BOOST_TEST(*it11 == 3);
|
||||
BOOST_TEST(*it12 == 7);
|
||||
BOOST_TEST(*it13 == 4);
|
||||
BOOST_TEST(*it14 == 5);
|
||||
BOOST_TEST(*it15 == 2);
|
||||
BOOST_TEST(cb1[0] == 7);
|
||||
BOOST_TEST(cb1[1] == 4);
|
||||
BOOST_TEST(cb1[2] == 5);
|
||||
BOOST_TEST(cb1[3] == 2);
|
||||
BOOST_TEST(cb1[4] == 3);
|
||||
|
||||
// memory placement: { 1, 2, 3 }
|
||||
// circular buffer: { 1, 2, 3 }
|
||||
@@ -189,14 +189,14 @@ void validity_insert_range_test() {
|
||||
|
||||
// memory placement: { 1, 4, 5, 2, 3 }
|
||||
// circular buffer: { 1, 4, 5, 2, 3 }
|
||||
BOOST_CHECK(*it21 == 1);
|
||||
BOOST_CHECK(*it22 == 4);
|
||||
BOOST_CHECK(*it23 == 5);
|
||||
BOOST_CHECK(cb2[0] == 1);
|
||||
BOOST_CHECK(cb2[1] == 4);
|
||||
BOOST_CHECK(cb2[2] == 5);
|
||||
BOOST_CHECK(cb2[3] == 2);
|
||||
BOOST_CHECK(cb2[4] == 3);
|
||||
BOOST_TEST(*it21 == 1);
|
||||
BOOST_TEST(*it22 == 4);
|
||||
BOOST_TEST(*it23 == 5);
|
||||
BOOST_TEST(cb2[0] == 1);
|
||||
BOOST_TEST(cb2[1] == 4);
|
||||
BOOST_TEST(cb2[2] == 5);
|
||||
BOOST_TEST(cb2[3] == 2);
|
||||
BOOST_TEST(cb2[4] == 3);
|
||||
|
||||
// it24 -> 2, it25 -> 3
|
||||
circular_buffer<int>::iterator it24 = it21 + 3;
|
||||
@@ -206,16 +206,16 @@ void validity_insert_range_test() {
|
||||
|
||||
// memory placement: { 2, 3, 7, 4, 5 } - using input iterator inserts all items even if they are later replaced
|
||||
// circular buffer: { 7, 4, 5, 2, 3 }
|
||||
BOOST_CHECK(*it21 == 2);
|
||||
BOOST_CHECK(*it22 == 3);
|
||||
BOOST_CHECK(*it23 == 7);
|
||||
BOOST_CHECK(*it24 == 4);
|
||||
BOOST_CHECK(*it25 == 5);
|
||||
BOOST_CHECK(cb2[0] == 7);
|
||||
BOOST_CHECK(cb2[1] == 4);
|
||||
BOOST_CHECK(cb2[2] == 5);
|
||||
BOOST_CHECK(cb2[3] == 2);
|
||||
BOOST_CHECK(cb2[4] == 3);
|
||||
BOOST_TEST(*it21 == 2);
|
||||
BOOST_TEST(*it22 == 3);
|
||||
BOOST_TEST(*it23 == 7);
|
||||
BOOST_TEST(*it24 == 4);
|
||||
BOOST_TEST(*it25 == 5);
|
||||
BOOST_TEST(cb2[0] == 7);
|
||||
BOOST_TEST(cb2[1] == 4);
|
||||
BOOST_TEST(cb2[2] == 5);
|
||||
BOOST_TEST(cb2[3] == 2);
|
||||
BOOST_TEST(cb2[4] == 3);
|
||||
}
|
||||
|
||||
void validity_rinsert_test() {
|
||||
@@ -235,13 +235,13 @@ void validity_rinsert_test() {
|
||||
|
||||
// memory placement: { 2, 4, 3, 1 }
|
||||
// circular buffer: { 1, 2, 4, 3 }
|
||||
BOOST_CHECK(*it1 == 2);
|
||||
BOOST_CHECK(*it2 == 4);
|
||||
BOOST_CHECK(*it3 == 3);
|
||||
BOOST_CHECK(cb[0] == 1);
|
||||
BOOST_CHECK(cb[1] == 2);
|
||||
BOOST_CHECK(cb[2] == 4);
|
||||
BOOST_CHECK(cb[3] == 3);
|
||||
BOOST_TEST(*it1 == 2);
|
||||
BOOST_TEST(*it2 == 4);
|
||||
BOOST_TEST(*it3 == 3);
|
||||
BOOST_TEST(cb[0] == 1);
|
||||
BOOST_TEST(cb[1] == 2);
|
||||
BOOST_TEST(cb[2] == 4);
|
||||
BOOST_TEST(cb[3] == 3);
|
||||
|
||||
// it4 -> 1
|
||||
circular_buffer<int>::iterator it4 = it1 - 1;
|
||||
@@ -250,14 +250,14 @@ void validity_rinsert_test() {
|
||||
|
||||
// memory placement: { 5, 4, 1, 2 }
|
||||
// circular buffer: { 1, 2, 5, 4 }
|
||||
BOOST_CHECK(*it1 == 5);
|
||||
BOOST_CHECK(*it2 == 4);
|
||||
BOOST_CHECK(*it3 == 1);
|
||||
BOOST_CHECK(*it4 == 2);
|
||||
BOOST_CHECK(cb[0] == 1);
|
||||
BOOST_CHECK(cb[1] == 2);
|
||||
BOOST_CHECK(cb[2] == 5);
|
||||
BOOST_CHECK(cb[3] == 4);
|
||||
BOOST_TEST(*it1 == 5);
|
||||
BOOST_TEST(*it2 == 4);
|
||||
BOOST_TEST(*it3 == 1);
|
||||
BOOST_TEST(*it4 == 2);
|
||||
BOOST_TEST(cb[0] == 1);
|
||||
BOOST_TEST(cb[1] == 2);
|
||||
BOOST_TEST(cb[2] == 5);
|
||||
BOOST_TEST(cb[3] == 4);
|
||||
}
|
||||
|
||||
void validity_rinsert_n_test() {
|
||||
@@ -278,14 +278,14 @@ void validity_rinsert_n_test() {
|
||||
|
||||
// memory placement: { 4, 4, 3, 1, 2 }
|
||||
// circular buffer: { 1, 2, 4, 4, 3 }
|
||||
BOOST_CHECK(*it1 == 4);
|
||||
BOOST_CHECK(*it2 == 4);
|
||||
BOOST_CHECK(*it3 == 3);
|
||||
BOOST_CHECK(cb[0] == 1);
|
||||
BOOST_CHECK(cb[1] == 2);
|
||||
BOOST_CHECK(cb[2] == 4);
|
||||
BOOST_CHECK(cb[3] == 4);
|
||||
BOOST_CHECK(cb[4] == 3);
|
||||
BOOST_TEST(*it1 == 4);
|
||||
BOOST_TEST(*it2 == 4);
|
||||
BOOST_TEST(*it3 == 3);
|
||||
BOOST_TEST(cb[0] == 1);
|
||||
BOOST_TEST(cb[1] == 2);
|
||||
BOOST_TEST(cb[2] == 4);
|
||||
BOOST_TEST(cb[3] == 4);
|
||||
BOOST_TEST(cb[4] == 3);
|
||||
|
||||
// it4 -> 1, it5 -> 2
|
||||
circular_buffer<int>::iterator it4 = it1 - 2;
|
||||
@@ -295,16 +295,16 @@ void validity_rinsert_n_test() {
|
||||
|
||||
// memory placement: { 4, 5, 1, 2, 4 } - 5 inserted only once
|
||||
// circular buffer: { 1, 2, 4, 4, 5 }
|
||||
BOOST_CHECK(*it1 == 4);
|
||||
BOOST_CHECK(*it2 == 5);
|
||||
BOOST_CHECK(*it3 == 1);
|
||||
BOOST_CHECK(*it4 == 2);
|
||||
BOOST_CHECK(*it5 == 4);
|
||||
BOOST_CHECK(cb[0] == 1);
|
||||
BOOST_CHECK(cb[1] == 2);
|
||||
BOOST_CHECK(cb[2] == 4);
|
||||
BOOST_CHECK(cb[3] == 4);
|
||||
BOOST_CHECK(cb[4] == 5);
|
||||
BOOST_TEST(*it1 == 4);
|
||||
BOOST_TEST(*it2 == 5);
|
||||
BOOST_TEST(*it3 == 1);
|
||||
BOOST_TEST(*it4 == 2);
|
||||
BOOST_TEST(*it5 == 4);
|
||||
BOOST_TEST(cb[0] == 1);
|
||||
BOOST_TEST(cb[1] == 2);
|
||||
BOOST_TEST(cb[2] == 4);
|
||||
BOOST_TEST(cb[3] == 4);
|
||||
BOOST_TEST(cb[4] == 5);
|
||||
}
|
||||
|
||||
void validity_rinsert_range_test() {
|
||||
@@ -334,14 +334,14 @@ void validity_rinsert_range_test() {
|
||||
|
||||
// memory placement: { 4, 5, 3, 1, 2 }
|
||||
// circular buffer: { 1, 2, 4, 5, 3 }
|
||||
BOOST_CHECK(*it11 == 4);
|
||||
BOOST_CHECK(*it12 == 5);
|
||||
BOOST_CHECK(*it13 == 3);
|
||||
BOOST_CHECK(cb1[0] == 1);
|
||||
BOOST_CHECK(cb1[1] == 2);
|
||||
BOOST_CHECK(cb1[2] == 4);
|
||||
BOOST_CHECK(cb1[3] == 5);
|
||||
BOOST_CHECK(cb1[4] == 3);
|
||||
BOOST_TEST(*it11 == 4);
|
||||
BOOST_TEST(*it12 == 5);
|
||||
BOOST_TEST(*it13 == 3);
|
||||
BOOST_TEST(cb1[0] == 1);
|
||||
BOOST_TEST(cb1[1] == 2);
|
||||
BOOST_TEST(cb1[2] == 4);
|
||||
BOOST_TEST(cb1[3] == 5);
|
||||
BOOST_TEST(cb1[4] == 3);
|
||||
|
||||
// it14 -> 1, it15 -> 2
|
||||
circular_buffer<int>::iterator it14 = it11 - 2;
|
||||
@@ -351,16 +351,16 @@ void validity_rinsert_range_test() {
|
||||
|
||||
// memory placement: { 5, 6, 1, 2, 4 } - 6 inserted only
|
||||
// circular buffer: { 1, 2, 4, 5, 6 }
|
||||
BOOST_CHECK(*it11 == 5);
|
||||
BOOST_CHECK(*it12 == 6);
|
||||
BOOST_CHECK(*it13 == 1);
|
||||
BOOST_CHECK(*it14 == 2);
|
||||
BOOST_CHECK(*it15 == 4);
|
||||
BOOST_CHECK(cb1[0] == 1);
|
||||
BOOST_CHECK(cb1[1] == 2);
|
||||
BOOST_CHECK(cb1[2] == 4);
|
||||
BOOST_CHECK(cb1[3] == 5);
|
||||
BOOST_CHECK(cb1[4] == 6);
|
||||
BOOST_TEST(*it11 == 5);
|
||||
BOOST_TEST(*it12 == 6);
|
||||
BOOST_TEST(*it13 == 1);
|
||||
BOOST_TEST(*it14 == 2);
|
||||
BOOST_TEST(*it15 == 4);
|
||||
BOOST_TEST(cb1[0] == 1);
|
||||
BOOST_TEST(cb1[1] == 2);
|
||||
BOOST_TEST(cb1[2] == 4);
|
||||
BOOST_TEST(cb1[3] == 5);
|
||||
BOOST_TEST(cb1[4] == 6);
|
||||
|
||||
// memory placement: { 1, 2, 3 }
|
||||
// circular buffer: { 1, 2, 3 }
|
||||
@@ -378,14 +378,14 @@ void validity_rinsert_range_test() {
|
||||
|
||||
// memory placement: { 4, 5, 3, 1, 2 }
|
||||
// circular buffer: { 1, 2, 4, 5, 3 }
|
||||
BOOST_CHECK(*it21 == 4);
|
||||
BOOST_CHECK(*it22 == 5);
|
||||
BOOST_CHECK(*it23 == 3);
|
||||
BOOST_CHECK(cb2[0] == 1);
|
||||
BOOST_CHECK(cb2[1] == 2);
|
||||
BOOST_CHECK(cb2[2] == 4);
|
||||
BOOST_CHECK(cb2[3] == 5);
|
||||
BOOST_CHECK(cb2[4] == 3);
|
||||
BOOST_TEST(*it21 == 4);
|
||||
BOOST_TEST(*it22 == 5);
|
||||
BOOST_TEST(*it23 == 3);
|
||||
BOOST_TEST(cb2[0] == 1);
|
||||
BOOST_TEST(cb2[1] == 2);
|
||||
BOOST_TEST(cb2[2] == 4);
|
||||
BOOST_TEST(cb2[3] == 5);
|
||||
BOOST_TEST(cb2[4] == 3);
|
||||
|
||||
// it24 -> 1, it25 -> 2
|
||||
circular_buffer<int>::iterator it24 = it21 - 2;
|
||||
@@ -395,16 +395,16 @@ void validity_rinsert_range_test() {
|
||||
|
||||
// memory placement: { 5, 6, 1, 2, 4 }
|
||||
// circular buffer: { 1, 2, 4, 5, 6 }
|
||||
BOOST_CHECK(*it21 == 5);
|
||||
BOOST_CHECK(*it22 == 6);
|
||||
BOOST_CHECK(*it23 == 1);
|
||||
BOOST_CHECK(*it24 == 2);
|
||||
BOOST_CHECK(*it25 == 4);
|
||||
BOOST_CHECK(cb2[0] == 1);
|
||||
BOOST_CHECK(cb2[1] == 2);
|
||||
BOOST_CHECK(cb2[2] == 4);
|
||||
BOOST_CHECK(cb2[3] == 5);
|
||||
BOOST_CHECK(cb2[4] == 6);
|
||||
BOOST_TEST(*it21 == 5);
|
||||
BOOST_TEST(*it22 == 6);
|
||||
BOOST_TEST(*it23 == 1);
|
||||
BOOST_TEST(*it24 == 2);
|
||||
BOOST_TEST(*it25 == 4);
|
||||
BOOST_TEST(cb2[0] == 1);
|
||||
BOOST_TEST(cb2[1] == 2);
|
||||
BOOST_TEST(cb2[2] == 4);
|
||||
BOOST_TEST(cb2[3] == 5);
|
||||
BOOST_TEST(cb2[4] == 6);
|
||||
}
|
||||
|
||||
void validity_erase_test() {
|
||||
@@ -430,14 +430,14 @@ void validity_erase_test() {
|
||||
|
||||
// memory placement: { 5, X, 1, 3, 4 }
|
||||
// circular buffer: { 1, 3, 4, 5 }
|
||||
BOOST_CHECK(*it1 == 1);
|
||||
BOOST_CHECK(*it2 == 3);
|
||||
BOOST_CHECK(*it3 == 4);
|
||||
BOOST_CHECK(*it4 == 5);
|
||||
BOOST_CHECK(cb[0] == 1);
|
||||
BOOST_CHECK(cb[1] == 3);
|
||||
BOOST_CHECK(cb[2] == 4);
|
||||
BOOST_CHECK(cb[3] == 5);
|
||||
BOOST_TEST(*it1 == 1);
|
||||
BOOST_TEST(*it2 == 3);
|
||||
BOOST_TEST(*it3 == 4);
|
||||
BOOST_TEST(*it4 == 5);
|
||||
BOOST_TEST(cb[0] == 1);
|
||||
BOOST_TEST(cb[1] == 3);
|
||||
BOOST_TEST(cb[2] == 4);
|
||||
BOOST_TEST(cb[3] == 5);
|
||||
}
|
||||
|
||||
void validity_erase_range_test() {
|
||||
@@ -465,14 +465,14 @@ void validity_erase_range_test() {
|
||||
|
||||
// memory placement: { 6, X, X, 1, 2, 5 }
|
||||
// circular buffer: { 1, 2, 5, 6 }
|
||||
BOOST_CHECK(*it1 == 1);
|
||||
BOOST_CHECK(*it2 == 2);
|
||||
BOOST_CHECK(*it3 == 5);
|
||||
BOOST_CHECK(*it4 == 6);
|
||||
BOOST_CHECK(cb[0] == 1);
|
||||
BOOST_CHECK(cb[1] == 2);
|
||||
BOOST_CHECK(cb[2] == 5);
|
||||
BOOST_CHECK(cb[3] == 6);
|
||||
BOOST_TEST(*it1 == 1);
|
||||
BOOST_TEST(*it2 == 2);
|
||||
BOOST_TEST(*it3 == 5);
|
||||
BOOST_TEST(*it4 == 6);
|
||||
BOOST_TEST(cb[0] == 1);
|
||||
BOOST_TEST(cb[1] == 2);
|
||||
BOOST_TEST(cb[2] == 5);
|
||||
BOOST_TEST(cb[3] == 6);
|
||||
}
|
||||
|
||||
void validity_rerase_test() {
|
||||
@@ -498,14 +498,14 @@ void validity_rerase_test() {
|
||||
|
||||
// memory placement: { 4, 5, X, 1, 3 }
|
||||
// circular buffer: { 1, 3, 4, 5 }
|
||||
BOOST_CHECK(*it1 == 1);
|
||||
BOOST_CHECK(*it2 == 3);
|
||||
BOOST_CHECK(*it3 == 4);
|
||||
BOOST_CHECK(*it4 == 5);
|
||||
BOOST_CHECK(cb[0] == 1);
|
||||
BOOST_CHECK(cb[1] == 3);
|
||||
BOOST_CHECK(cb[2] == 4);
|
||||
BOOST_CHECK(cb[3] == 5);
|
||||
BOOST_TEST(*it1 == 1);
|
||||
BOOST_TEST(*it2 == 3);
|
||||
BOOST_TEST(*it3 == 4);
|
||||
BOOST_TEST(*it4 == 5);
|
||||
BOOST_TEST(cb[0] == 1);
|
||||
BOOST_TEST(cb[1] == 3);
|
||||
BOOST_TEST(cb[2] == 4);
|
||||
BOOST_TEST(cb[3] == 5);
|
||||
}
|
||||
|
||||
void validity_rerase_range_test() {
|
||||
@@ -533,14 +533,14 @@ void validity_rerase_range_test() {
|
||||
|
||||
// memory placement: { 2, 5, 6, X, X, 1 }
|
||||
// circular buffer: { 1, 2, 5, 6 }
|
||||
BOOST_CHECK(*it1 == 1);
|
||||
BOOST_CHECK(*it2 == 2);
|
||||
BOOST_CHECK(*it3 == 5);
|
||||
BOOST_CHECK(*it4 == 6);
|
||||
BOOST_CHECK(cb[0] == 1);
|
||||
BOOST_CHECK(cb[1] == 2);
|
||||
BOOST_CHECK(cb[2] == 5);
|
||||
BOOST_CHECK(cb[3] == 6);
|
||||
BOOST_TEST(*it1 == 1);
|
||||
BOOST_TEST(*it2 == 2);
|
||||
BOOST_TEST(*it3 == 5);
|
||||
BOOST_TEST(*it4 == 6);
|
||||
BOOST_TEST(cb[0] == 1);
|
||||
BOOST_TEST(cb[1] == 2);
|
||||
BOOST_TEST(cb[2] == 5);
|
||||
BOOST_TEST(cb[3] == 6);
|
||||
}
|
||||
|
||||
void validity_linearize_test() {
|
||||
@@ -562,12 +562,12 @@ void validity_linearize_test() {
|
||||
|
||||
// memory placement: { 1, 2, 3 }
|
||||
// circular buffer: { 1, 2, 3 }
|
||||
BOOST_CHECK(*it1 == 2);
|
||||
BOOST_CHECK(*it2 == 3);
|
||||
BOOST_CHECK(*it3 == 1);
|
||||
BOOST_CHECK(cb[0] == 1);
|
||||
BOOST_CHECK(cb[1] == 2);
|
||||
BOOST_CHECK(cb[2] == 3);
|
||||
BOOST_TEST(*it1 == 2);
|
||||
BOOST_TEST(*it2 == 3);
|
||||
BOOST_TEST(*it3 == 1);
|
||||
BOOST_TEST(cb[0] == 1);
|
||||
BOOST_TEST(cb[1] == 2);
|
||||
BOOST_TEST(cb[2] == 3);
|
||||
}
|
||||
|
||||
void validity_swap_test() {
|
||||
@@ -600,20 +600,20 @@ void validity_swap_test() {
|
||||
cb1.swap(cb2);
|
||||
|
||||
// Although iterators refer to the original elements,
|
||||
// their interal state is inconsistent and no other operation
|
||||
// their internal state is inconsistent and no other operation
|
||||
// (except dereferencing) can be invoked on them any more.
|
||||
BOOST_CHECK(*it11 == 1);
|
||||
BOOST_CHECK(*it12 == 2);
|
||||
BOOST_CHECK(*it13 == 3);
|
||||
BOOST_CHECK(*it21 == 4);
|
||||
BOOST_CHECK(*it22 == 5);
|
||||
BOOST_CHECK(*it23 == 6);
|
||||
BOOST_CHECK(cb1[0] == 4);
|
||||
BOOST_CHECK(cb1[1] == 5);
|
||||
BOOST_CHECK(cb1[2] == 6);
|
||||
BOOST_CHECK(cb2[0] == 1);
|
||||
BOOST_CHECK(cb2[1] == 2);
|
||||
BOOST_CHECK(cb2[2] == 3);
|
||||
BOOST_TEST(*it11 == 1);
|
||||
BOOST_TEST(*it12 == 2);
|
||||
BOOST_TEST(*it13 == 3);
|
||||
BOOST_TEST(*it21 == 4);
|
||||
BOOST_TEST(*it22 == 5);
|
||||
BOOST_TEST(*it23 == 6);
|
||||
BOOST_TEST(cb1[0] == 4);
|
||||
BOOST_TEST(cb1[1] == 5);
|
||||
BOOST_TEST(cb1[2] == 6);
|
||||
BOOST_TEST(cb2[0] == 1);
|
||||
BOOST_TEST(cb2[1] == 2);
|
||||
BOOST_TEST(cb2[2] == 3);
|
||||
}
|
||||
|
||||
void validity_push_back_test() {
|
||||
@@ -635,12 +635,12 @@ void validity_push_back_test() {
|
||||
|
||||
// memory placement: { 3, 4, 2 }
|
||||
// circular buffer: { 2, 3, 4 }
|
||||
BOOST_CHECK(*it1 == 4);
|
||||
BOOST_CHECK(*it2 == 2);
|
||||
BOOST_CHECK(*it3 == 3);
|
||||
BOOST_CHECK(cb[0] == 2);
|
||||
BOOST_CHECK(cb[1] == 3);
|
||||
BOOST_CHECK(cb[2] == 4);
|
||||
BOOST_TEST(*it1 == 4);
|
||||
BOOST_TEST(*it2 == 2);
|
||||
BOOST_TEST(*it3 == 3);
|
||||
BOOST_TEST(cb[0] == 2);
|
||||
BOOST_TEST(cb[1] == 3);
|
||||
BOOST_TEST(cb[2] == 4);
|
||||
}
|
||||
|
||||
void validity_push_front_test() {
|
||||
@@ -662,12 +662,12 @@ void validity_push_front_test() {
|
||||
|
||||
// memory placement: { 4, 1, 2 }
|
||||
// circular buffer: { 4, 1, 2 }
|
||||
BOOST_CHECK(*it1 == 1);
|
||||
BOOST_CHECK(*it2 == 2);
|
||||
BOOST_CHECK(*it3 == 4);
|
||||
BOOST_CHECK(cb[0] == 4);
|
||||
BOOST_CHECK(cb[1] == 1);
|
||||
BOOST_CHECK(cb[2] == 2);
|
||||
BOOST_TEST(*it1 == 1);
|
||||
BOOST_TEST(*it2 == 2);
|
||||
BOOST_TEST(*it3 == 4);
|
||||
BOOST_TEST(cb[0] == 4);
|
||||
BOOST_TEST(cb[1] == 1);
|
||||
BOOST_TEST(cb[2] == 2);
|
||||
}
|
||||
|
||||
void validity_pop_back_test() {
|
||||
@@ -688,10 +688,10 @@ void validity_pop_back_test() {
|
||||
|
||||
// memory placement: { X, 1, 2 }
|
||||
// circular buffer: { 1, 2 }
|
||||
BOOST_CHECK(*it1 == 1);
|
||||
BOOST_CHECK(*it2 == 2);
|
||||
BOOST_CHECK(cb[0] == 1);
|
||||
BOOST_CHECK(cb[1] == 2);
|
||||
BOOST_TEST(*it1 == 1);
|
||||
BOOST_TEST(*it2 == 2);
|
||||
BOOST_TEST(cb[0] == 1);
|
||||
BOOST_TEST(cb[1] == 2);
|
||||
}
|
||||
|
||||
void validity_pop_front_test() {
|
||||
@@ -712,34 +712,31 @@ void validity_pop_front_test() {
|
||||
|
||||
// memory placement: { 3, X, 2 }
|
||||
// circular buffer: { 2, 3 }
|
||||
BOOST_CHECK(*it1 == 2);
|
||||
BOOST_CHECK(*it2 == 3);
|
||||
BOOST_CHECK(cb[0] == 2);
|
||||
BOOST_CHECK(cb[1] == 3);
|
||||
BOOST_TEST(*it1 == 2);
|
||||
BOOST_TEST(*it2 == 3);
|
||||
BOOST_TEST(cb[0] == 2);
|
||||
BOOST_TEST(cb[1] == 3);
|
||||
}
|
||||
|
||||
// test main
|
||||
test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[]) {
|
||||
|
||||
test_suite* tests = BOOST_TEST_SUITE("Unit tests for the iterator of the circular_buffer.");
|
||||
|
||||
tests->add(BOOST_TEST_CASE(&validity_example_test));
|
||||
tests->add(BOOST_TEST_CASE(&validity_insert_test));
|
||||
tests->add(BOOST_TEST_CASE(&validity_insert_n_test));
|
||||
tests->add(BOOST_TEST_CASE(&validity_insert_range_test));
|
||||
tests->add(BOOST_TEST_CASE(&validity_rinsert_test));
|
||||
tests->add(BOOST_TEST_CASE(&validity_rinsert_n_test));
|
||||
tests->add(BOOST_TEST_CASE(&validity_rinsert_range_test));
|
||||
tests->add(BOOST_TEST_CASE(&validity_erase_test));
|
||||
tests->add(BOOST_TEST_CASE(&validity_erase_range_test));
|
||||
tests->add(BOOST_TEST_CASE(&validity_rerase_test));
|
||||
tests->add(BOOST_TEST_CASE(&validity_rerase_range_test));
|
||||
tests->add(BOOST_TEST_CASE(&validity_linearize_test));
|
||||
tests->add(BOOST_TEST_CASE(&validity_swap_test));
|
||||
tests->add(BOOST_TEST_CASE(&validity_push_back_test));
|
||||
tests->add(BOOST_TEST_CASE(&validity_push_front_test));
|
||||
tests->add(BOOST_TEST_CASE(&validity_pop_back_test));
|
||||
tests->add(BOOST_TEST_CASE(&validity_pop_front_test));
|
||||
|
||||
return tests;
|
||||
int main()
|
||||
{
|
||||
validity_example_test();
|
||||
validity_insert_test();
|
||||
validity_insert_n_test();
|
||||
validity_insert_range_test();
|
||||
validity_rinsert_test();
|
||||
validity_rinsert_n_test();
|
||||
validity_rinsert_range_test();
|
||||
validity_erase_test();
|
||||
validity_erase_range_test();
|
||||
validity_rerase_test();
|
||||
validity_rerase_range_test();
|
||||
validity_linearize_test();
|
||||
validity_swap_test();
|
||||
validity_push_back_test();
|
||||
validity_push_front_test();
|
||||
validity_pop_back_test();
|
||||
validity_pop_front_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -29,33 +29,33 @@ void min_capacity_test() {
|
||||
cb_space_optimized cb2(capacity_ctrl(10, 5), 1);
|
||||
cb_space_optimized cb3(capacity_ctrl(20, 10), v.begin(), v.end());
|
||||
|
||||
BOOST_CHECK(cb1.size() == 0);
|
||||
BOOST_CHECK(cb1.capacity().capacity() == 10);
|
||||
BOOST_CHECK(cb1.capacity().min_capacity() == 10);
|
||||
BOOST_CHECK(cb2[0] == 1);
|
||||
BOOST_CHECK(cb2.size() == 10);
|
||||
BOOST_CHECK(cb2.capacity() == 10);
|
||||
BOOST_CHECK(cb2.capacity().min_capacity() == 5);
|
||||
BOOST_CHECK(cb3[0] == 1);
|
||||
BOOST_CHECK(cb3.size() == 5);
|
||||
BOOST_CHECK(cb3.capacity() == 20);
|
||||
BOOST_CHECK(cb3.capacity().min_capacity() == 10);
|
||||
BOOST_CHECK(cb1.capacity().min_capacity() <= cb1.internal_capacity());
|
||||
BOOST_CHECK(cb2.capacity().min_capacity() <= cb2.internal_capacity());
|
||||
BOOST_CHECK(cb3.capacity().min_capacity() <= cb3.internal_capacity());
|
||||
BOOST_TEST(cb1.size() == 0);
|
||||
BOOST_TEST(cb1.capacity().capacity() == 10);
|
||||
BOOST_TEST(cb1.capacity().min_capacity() == 10);
|
||||
BOOST_TEST(cb2[0] == 1);
|
||||
BOOST_TEST(cb2.size() == 10);
|
||||
BOOST_TEST(cb2.capacity() == 10);
|
||||
BOOST_TEST(cb2.capacity().min_capacity() == 5);
|
||||
BOOST_TEST(cb3[0] == 1);
|
||||
BOOST_TEST(cb3.size() == 5);
|
||||
BOOST_TEST(cb3.capacity() == 20);
|
||||
BOOST_TEST(cb3.capacity().min_capacity() == 10);
|
||||
BOOST_TEST(cb1.capacity().min_capacity() <= cb1.internal_capacity());
|
||||
BOOST_TEST(cb2.capacity().min_capacity() <= cb2.internal_capacity());
|
||||
BOOST_TEST(cb3.capacity().min_capacity() <= cb3.internal_capacity());
|
||||
|
||||
cb2.erase(cb2.begin() + 2, cb2.end());
|
||||
|
||||
BOOST_CHECK(cb2.size() == 2);
|
||||
BOOST_CHECK(cb2.capacity().min_capacity() <= cb2.internal_capacity());
|
||||
BOOST_TEST(cb2.size() == 2);
|
||||
BOOST_TEST(cb2.capacity().min_capacity() <= cb2.internal_capacity());
|
||||
|
||||
cb2.clear();
|
||||
cb3.clear();
|
||||
|
||||
BOOST_CHECK(cb2.empty());
|
||||
BOOST_CHECK(cb3.empty());
|
||||
BOOST_CHECK(cb2.capacity().min_capacity() <= cb2.internal_capacity());
|
||||
BOOST_CHECK(cb3.capacity().min_capacity() <= cb3.internal_capacity());
|
||||
BOOST_TEST(cb2.empty());
|
||||
BOOST_TEST(cb3.empty());
|
||||
BOOST_TEST(cb2.capacity().min_capacity() <= cb2.internal_capacity());
|
||||
BOOST_TEST(cb3.capacity().min_capacity() <= cb3.internal_capacity());
|
||||
}
|
||||
|
||||
void capacity_control_test() {
|
||||
@@ -65,33 +65,33 @@ void capacity_control_test() {
|
||||
circular_buffer_space_optimized<int>::capacity_type(20, 5);
|
||||
circular_buffer_space_optimized<int>::capacity_type c3 = c2;
|
||||
|
||||
BOOST_CHECK(c1.capacity() == 10);
|
||||
BOOST_CHECK(c1.min_capacity() == 0);
|
||||
BOOST_CHECK(c2.capacity() == 20);
|
||||
BOOST_CHECK(c2.min_capacity() == 5);
|
||||
BOOST_CHECK(c3.capacity() == 20);
|
||||
BOOST_CHECK(c3.min_capacity() == 5);
|
||||
BOOST_TEST(c1.capacity() == 10);
|
||||
BOOST_TEST(c1.min_capacity() == 0);
|
||||
BOOST_TEST(c2.capacity() == 20);
|
||||
BOOST_TEST(c2.min_capacity() == 5);
|
||||
BOOST_TEST(c3.capacity() == 20);
|
||||
BOOST_TEST(c3.min_capacity() == 5);
|
||||
|
||||
c1 = c2;
|
||||
|
||||
BOOST_CHECK(c1.capacity() == 20);
|
||||
BOOST_CHECK(c1.min_capacity() == 5);
|
||||
BOOST_TEST(c1.capacity() == 20);
|
||||
BOOST_TEST(c1.min_capacity() == 5);
|
||||
}
|
||||
|
||||
void specific_constructors_test() {
|
||||
|
||||
cb_space_optimized cb1;
|
||||
BOOST_CHECK(cb1.capacity() == 0);
|
||||
BOOST_CHECK(cb1.capacity().min_capacity() == 0);
|
||||
BOOST_CHECK(cb1.internal_capacity() == 0);
|
||||
BOOST_CHECK(cb1.size() == 0);
|
||||
BOOST_TEST(cb1.capacity() == 0);
|
||||
BOOST_TEST(cb1.capacity().min_capacity() == 0);
|
||||
BOOST_TEST(cb1.internal_capacity() == 0);
|
||||
BOOST_TEST(cb1.size() == 0);
|
||||
|
||||
cb1.push_back(1);
|
||||
cb1.push_back(2);
|
||||
cb1.push_back(3);
|
||||
|
||||
BOOST_CHECK(cb1.size() == 0);
|
||||
BOOST_CHECK(cb1.capacity() == 0);
|
||||
BOOST_TEST(cb1.size() == 0);
|
||||
BOOST_TEST(cb1.capacity() == 0);
|
||||
|
||||
vector<int> v;
|
||||
v.push_back(1);
|
||||
@@ -100,9 +100,9 @@ void specific_constructors_test() {
|
||||
|
||||
cb_space_optimized cb2(v.begin(), v.end());
|
||||
|
||||
BOOST_CHECK(cb2.capacity() == 3);
|
||||
BOOST_CHECK(cb2.capacity().min_capacity() == 0);
|
||||
BOOST_CHECK(cb2.size() == 3);
|
||||
BOOST_TEST(cb2.capacity() == 3);
|
||||
BOOST_TEST(cb2.capacity().min_capacity() == 0);
|
||||
BOOST_TEST(cb2.size() == 3);
|
||||
}
|
||||
|
||||
void shrink_to_fit_test() {
|
||||
@@ -112,15 +112,15 @@ void shrink_to_fit_test() {
|
||||
cb.push_back(2);
|
||||
cb.push_back(3);
|
||||
|
||||
BOOST_CHECK(cb.size() == 3);
|
||||
BOOST_CHECK(cb.capacity() == 1000);
|
||||
BOOST_TEST(cb.size() == 3);
|
||||
BOOST_TEST(cb.capacity() == 1000);
|
||||
|
||||
size_t internal_capacity = cb.internal_capacity();
|
||||
cb_space_optimized(cb).swap(cb);
|
||||
|
||||
BOOST_CHECK(cb.size() == 3);
|
||||
BOOST_CHECK(cb.capacity() == 1000);
|
||||
BOOST_CHECK(internal_capacity >= cb.internal_capacity());
|
||||
BOOST_TEST(cb.size() == 3);
|
||||
BOOST_TEST(cb.capacity() == 1000);
|
||||
BOOST_TEST(internal_capacity >= cb.internal_capacity());
|
||||
}
|
||||
|
||||
void iterator_invalidation_test() {
|
||||
@@ -136,33 +136,33 @@ void iterator_invalidation_test() {
|
||||
cb_space_optimized::iterator it3 = cb1.begin() + 6;
|
||||
|
||||
cb1.set_capacity(10);
|
||||
BOOST_CHECK(it1.is_valid(&cb1));
|
||||
BOOST_CHECK(!it2.is_valid(&cb1));
|
||||
BOOST_CHECK(!it3.is_valid(&cb1));
|
||||
BOOST_TEST(it1.is_valid(&cb1));
|
||||
BOOST_TEST(!it2.is_valid(&cb1));
|
||||
BOOST_TEST(!it3.is_valid(&cb1));
|
||||
|
||||
it1 = cb1.end();
|
||||
it2 = cb1.begin();
|
||||
it3 = cb1.begin() + 6;
|
||||
cb1.rset_capacity(10);
|
||||
BOOST_CHECK(it1.is_valid(&cb1));
|
||||
BOOST_CHECK(!it2.is_valid(&cb1));
|
||||
BOOST_CHECK(!it3.is_valid(&cb1));
|
||||
BOOST_TEST(it1.is_valid(&cb1));
|
||||
BOOST_TEST(!it2.is_valid(&cb1));
|
||||
BOOST_TEST(!it3.is_valid(&cb1));
|
||||
|
||||
it1 = cb1.end();
|
||||
it2 = cb1.begin();
|
||||
it3 = cb1.begin() + 6;
|
||||
cb1.resize(10);
|
||||
BOOST_CHECK(it1.is_valid(&cb1));
|
||||
BOOST_CHECK(!it2.is_valid(&cb1));
|
||||
BOOST_CHECK(!it3.is_valid(&cb1));
|
||||
BOOST_TEST(it1.is_valid(&cb1));
|
||||
BOOST_TEST(!it2.is_valid(&cb1));
|
||||
BOOST_TEST(!it3.is_valid(&cb1));
|
||||
|
||||
it1 = cb1.end();
|
||||
it2 = cb1.begin();
|
||||
it3 = cb1.begin() + 6;
|
||||
cb1.rresize(10);
|
||||
BOOST_CHECK(it1.is_valid(&cb1));
|
||||
BOOST_CHECK(!it2.is_valid(&cb1));
|
||||
BOOST_CHECK(!it3.is_valid(&cb1));
|
||||
BOOST_TEST(it1.is_valid(&cb1));
|
||||
BOOST_TEST(!it2.is_valid(&cb1));
|
||||
BOOST_TEST(!it3.is_valid(&cb1));
|
||||
|
||||
{
|
||||
cb_space_optimized cb2(10, 1);
|
||||
@@ -173,24 +173,21 @@ void iterator_invalidation_test() {
|
||||
it2 = cb2.begin();
|
||||
it3 = cb2.begin() + 6;
|
||||
}
|
||||
BOOST_CHECK(!it1.is_valid(&cb1));
|
||||
BOOST_CHECK(!it2.is_valid(&cb1));
|
||||
BOOST_CHECK(!it3.is_valid(&cb1));
|
||||
BOOST_TEST(!it1.is_valid(&cb1));
|
||||
BOOST_TEST(!it2.is_valid(&cb1));
|
||||
BOOST_TEST(!it3.is_valid(&cb1));
|
||||
|
||||
#endif // #if BOOST_CB_ENABLE_DEBUG
|
||||
}
|
||||
|
||||
// test main
|
||||
test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[]) {
|
||||
|
||||
test_suite* tests = BOOST_TEST_SUITE("Unit tests for the circular_buffer_space_optimized.");
|
||||
add_common_tests(tests);
|
||||
|
||||
tests->add(BOOST_TEST_CASE(&min_capacity_test));
|
||||
tests->add(BOOST_TEST_CASE(&capacity_control_test));
|
||||
tests->add(BOOST_TEST_CASE(&specific_constructors_test));
|
||||
tests->add(BOOST_TEST_CASE(&shrink_to_fit_test));
|
||||
tests->add(BOOST_TEST_CASE(&iterator_invalidation_test));
|
||||
|
||||
return tests;
|
||||
int main()
|
||||
{
|
||||
run_common_tests();
|
||||
min_capacity_test();
|
||||
capacity_control_test();
|
||||
specific_constructors_test();
|
||||
shrink_to_fit_test();
|
||||
iterator_invalidation_test();
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
#define BOOST_CB_TEST
|
||||
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#include <boost/iterator.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <iterator>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
@@ -72,6 +71,11 @@ class InstanceCounter {
|
||||
public:
|
||||
InstanceCounter() { increment(); }
|
||||
InstanceCounter(const InstanceCounter& y) { y.increment(); }
|
||||
InstanceCounter& operator=(const InstanceCounter& y) {
|
||||
decrement();
|
||||
y.increment();
|
||||
return *this;
|
||||
}
|
||||
~InstanceCounter() { decrement(); }
|
||||
static int count() { return ms_count; }
|
||||
private:
|
||||
@@ -90,6 +94,7 @@ public:
|
||||
eVirtual
|
||||
};
|
||||
Dummy() : m_n(eVar) {}
|
||||
virtual ~Dummy() {}
|
||||
DummyEnum fnc() { return eFnc; }
|
||||
DummyEnum const_fnc() const { return eConst; }
|
||||
virtual DummyEnum virtual_fnc() { return eVirtual; }
|
||||
@@ -97,21 +102,18 @@ public:
|
||||
};
|
||||
|
||||
// simulator of an input iterator
|
||||
struct MyInputIterator
|
||||
: boost::iterator<std::input_iterator_tag, int, ptrdiff_t, int*, int&> {
|
||||
struct MyInputIterator {
|
||||
typedef std::vector<int>::iterator vector_iterator;
|
||||
typedef std::input_iterator_tag iterator_category;
|
||||
typedef int value_type;
|
||||
typedef int* pointer;
|
||||
typedef int& reference;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
explicit MyInputIterator(const vector_iterator& it) : m_it(it) {}
|
||||
MyInputIterator& operator = (const MyInputIterator& it) {
|
||||
if (this == &it)
|
||||
return *this;
|
||||
m_it = it.m_it;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Default assignment operator
|
||||
|
||||
reference operator * () const { return *m_it; }
|
||||
pointer operator -> () const { return &(operator*()); }
|
||||
MyInputIterator& operator ++ () {
|
||||
@@ -139,7 +141,6 @@ inline ptrdiff_t* distance_type(const MyInputIterator&) { return 0; }
|
||||
|
||||
#endif // #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR)
|
||||
|
||||
using boost::unit_test::test_suite;
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user