mirror of
https://github.com/boostorg/circular_buffer.git
synced 2026-02-03 09:02:12 +00:00
Compare commits
1 Commits
boost-1.72
...
boost-1.49
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c478e1884 |
286
.travis.yml
286
.travis.yml
@@ -1,286 +0,0 @@
|
||||
# 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
|
||||
@@ -1,25 +0,0 @@
|
||||
# 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)
|
||||
|
||||
project(BoostCircularBuffer 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
48
appveyor.yml
@@ -1,48 +0,0 @@
|
||||
# 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%
|
||||
227
doc/Doxyfile
Normal file
227
doc/Doxyfile
Normal file
@@ -0,0 +1,227 @@
|
||||
# Doxygen configuration file.
|
||||
#
|
||||
# Copyright (c) 2003-2008 Jan Gaspar
|
||||
#
|
||||
# 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)
|
||||
#
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = "Circular Buffer"
|
||||
PROJECT_NUMBER = 3.7
|
||||
OUTPUT_DIRECTORY = srcdoc
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
USE_WINDOWS_ENCODING = NO
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF =
|
||||
ALWAYS_DETAILED_SEC = YES
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = NO
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
TAB_SIZE = 8
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
SUBGROUPING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = YES
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = NO
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = NO
|
||||
SHOW_DIRECTORIES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = YES
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = ../../../boost/circular_buffer
|
||||
FILE_PATTERNS = *.hpp
|
||||
RECURSIVE = YES
|
||||
EXCLUDE = ../../../boost/circular_buffer/debug.hpp \
|
||||
../../../boost/circular_buffer/details.hpp
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = NO
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
VERBATIM_HEADERS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = NO
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = NO
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = NO
|
||||
TREEVIEW_WIDTH = 250
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = NO
|
||||
USE_PDFLATEX = NO
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = YES
|
||||
XML_OUTPUT = .
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = NO
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = NO
|
||||
PERL_PATH =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = NO
|
||||
HIDE_UNDOC_RELATIONS = NO
|
||||
HAVE_DOT = NO
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = YES
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
||||
52
doc/HOWTO-srcdoc
Normal file
52
doc/HOWTO-srcdoc
Normal file
@@ -0,0 +1,52 @@
|
||||
################################################################################
|
||||
# HOW-TO documentation about generating/updating source code documentation for #
|
||||
# the Circular Buffer library. #
|
||||
# #
|
||||
# Copyright (c) 2003-2008 Jan Gaspar #
|
||||
# #
|
||||
# Use, modification, and distribution is subject to the Boost Software #
|
||||
# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at #
|
||||
# http://www.boost.org/LICENSE_1_0.txt) #
|
||||
################################################################################
|
||||
|
||||
The source code documentation (i.e. documentation of functions, classes and
|
||||
their methods, etc.) is part of the source code. This makes it convenient for
|
||||
a developer when browsing source files or developing new (documented) code.
|
||||
The source code documentation is included in the larger, more detailed library
|
||||
documentation as well which makes it more convenient for the user of the
|
||||
library. In order to make it easier for the developer, the source code
|
||||
documentation included in the library documentation is generated from the source
|
||||
files. Which means the developer does not have to write the same source
|
||||
documentation twice.
|
||||
|
||||
Prerequisites:
|
||||
|
||||
1) Unix/Linux shell (with sed editor) available.
|
||||
(The script can be easily converted into Windows batch file if you do not
|
||||
have access to Unix/Linux shell.)
|
||||
2) Installed Doxygen http://www.doxygen.org.
|
||||
(Source documentation generation was tested with the Doxygen version
|
||||
1.4.6.)
|
||||
3) Installed xsltproc http://xmlsoft.org/XSLT/xsltproc2.html.
|
||||
4) Installed HTML Tidy http://tidy.sourceforge.net. (Tested with version
|
||||
released on 1 September 2005.)
|
||||
|
||||
|
||||
Updating source code documentation:
|
||||
|
||||
The source code documentation of the Circular Buffer library obeys the Doxygen
|
||||
syntax. The library documentation is written in HTML (files circular_buffer.html
|
||||
and space_optimized.html). The generation of the source code documentation is
|
||||
performed by executing the update_srcdoc.sh script which relies mainly on
|
||||
Doxygen and several XSL transformations.
|
||||
|
||||
After editing the source code documentation in the source file(s), update the
|
||||
library documentation by executing:
|
||||
|
||||
$>./update_srcdoc.sh circular_buffer
|
||||
|
||||
for the circular_buffer or/and
|
||||
|
||||
$>./update_srcdoc.sh circular_buffer_space_optimized
|
||||
|
||||
for the circular_buffer_space_optimized.
|
||||
18
doc/Tidy.conf
Normal file
18
doc/Tidy.conf
Normal file
@@ -0,0 +1,18 @@
|
||||
# HTML Tidy configuration file.
|
||||
#
|
||||
# Copyright (c) 2003-2008 Jan Gaspar
|
||||
#
|
||||
# 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)
|
||||
#
|
||||
bare: yes
|
||||
char-encoding: latin1
|
||||
doctype: transitional
|
||||
indent: yes
|
||||
indent-attributes: no
|
||||
quiet: yes
|
||||
show-warnings: no
|
||||
tidy-mark: no
|
||||
wrap: 120
|
||||
write-back: yes
|
||||
7436
doc/circular_buffer.html
Normal file
7436
doc/circular_buffer.html
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,22 +0,0 @@
|
||||
# circular_buffer.idx index script file
|
||||
# for Boost.circular_buffer Quickbook Doxygen documentation Auto-indexing forcircular_buffer library.
|
||||
|
||||
# Copyright (c) 2011 Paul A. Bristow
|
||||
# Copyright (c) 2003 - 2008 Jan Gaspar
|
||||
|
||||
# boost-no-inspect
|
||||
|
||||
# Use, modification and distribution is subject to the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt
|
||||
# or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# All header files, recursing down to include sub-folders.
|
||||
!scan-path "boost/circular_buffer" ".*\.hpp" true
|
||||
|
||||
# All example source files, assuming no sub-folders.
|
||||
!scan-path "libs/circular_buffer/example" ".*\.cpp"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
@@ -1,626 +0,0 @@
|
||||
[article Boost.Circular Buffer
|
||||
[quickbook 1.6]
|
||||
[id circular_buffer]
|
||||
[copyright 2003-2013 Jan Gaspar]
|
||||
[license
|
||||
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])
|
||||
]
|
||||
[authors [Gaspar, Jan]]
|
||||
[source-mode c++]
|
||||
]
|
||||
|
||||
[/ Links - by (most common) convention, prefixed with double underscore so not confused with other names.]
|
||||
[def __alert [$./images/alert.png]] [/ Examples of your own images (in doc/html/images/ .]
|
||||
[def __tip [$./images/tip.png]]
|
||||
[/ If you provide a file type like .png, you will probably find that the file is missing in the pdf version.]
|
||||
[/ This is because the default file type specified is .png in html, but .svg for pdf version.]
|
||||
|
||||
[/ Some links to external sources.]
|
||||
[/ You often want to link more than once, so using a def ensures you always refer to the same location.]
|
||||
[def __boost [@http://www.boost.org/ Boost]] [/Boost.org]
|
||||
[def __boostroot [@boost: Boost root]] [/ Your boost root]
|
||||
[/Note the custom boost root url schema for linking to files within the Boost distribution.]
|
||||
[/Note It can't be used for images, nor for pdf, so not so useful.]
|
||||
[/def __boostlicense [@http://www.boost.org/LICENSE_1_0.txt Boost License]]
|
||||
[/ Or refer to your most recent version of Boost.]
|
||||
[def __boostlicense [@boost:/LICENSE_1_0.txt Boost License]]
|
||||
[def __boostbook [@http://www.boost.org/doc/html/boostbook.html BoostBook]]
|
||||
[def __boostbook_docs [@http://www.boost.org/doc/libs/1_53_0/doc/html/boostbook.html BoostBook documentation]]
|
||||
[def __quickbook [@http://www.boost.org/doc/tools/quickbook/index.html Quickbook]]
|
||||
[def __quickbook_syntax [@http://www.boost.org/doc/libs/1_53_0/doc/html/quickbook/ref.html Quickbook Syntax Compendium]]
|
||||
[def __docbook [@http://www.docbook.org/ DocBook]]
|
||||
[def __doxygen [@http://www.doxygen.org/ Doxygen]]
|
||||
[def __autoindex [@boost:/tools/auto_index/doc/html/index.html AutoIndex]]
|
||||
[def __pdf [@http://www.adobe.com/products/acrobat/adobepdf.html PDF]]
|
||||
[def __textpad [@http://www.textpad.com Textpad]]
|
||||
[def __emacs [@http://www.gnu.org/software/emacs/ GNU emacs]]
|
||||
[def __css [@http://en.wikipedia.org/wiki/Cascading_Style_Sheets Cascading Style Sheet]]
|
||||
[def __intro [link circular_buffer.intro Introduction]] [/Link to a Quickbook section (see below).]
|
||||
|
||||
[def __docbook_params [@http://docbook.sourceforge.net/release/xsl/current/doc/ Docbook xsl:param format options]]
|
||||
|
||||
[def __cb [classref boost::circular_buffer circular_buffer]]
|
||||
[def __cbso [classref boost::circular_buffer_space_optimized circular_buffer_space_optimized]]
|
||||
[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.implementation.debug_support debug support]]
|
||||
|
||||
[include ../../../tools/auto_index/include/auto_index_helpers.qbk]
|
||||
[/ Must be first included file!]
|
||||
|
||||
[note A printer-friendly PDF version of this manual is also available.]
|
||||
|
||||
[section:intro Introduction]
|
||||
|
||||
A Circular Buffer.
|
||||
|
||||
[h2 Description]
|
||||
|
||||
The term [@http://en.wikipedia.org/wiki/Circular_buffer circular buffer]
|
||||
(also called a ['ring] or ['cyclic buffer])
|
||||
refers to an area in memory which is used to store incoming data.
|
||||
When the buffer is filled,
|
||||
new data is written starting at the beginning of the buffer and overwriting the old.
|
||||
|
||||
[classref boost::circular_buffer] is a STL compliant container.
|
||||
|
||||
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.
|
||||
|
||||
The __cb is especially designed to provide [*fixed capacity] storage.
|
||||
When its capacity is exhausted, newly inserted elements will cause elements
|
||||
to be overwritten, either at the beginning or end of the buffer
|
||||
(depending on what insert operation is used).
|
||||
|
||||
The __cb only allocates memory when created,
|
||||
when the capacity is adjusted explicitly,
|
||||
or as necessary to accommodate resizing or assign operations.
|
||||
|
||||
[$../../libs/circular_buffer/doc/images/circular_buffer.png]
|
||||
|
||||
There is also a __cbso version available.
|
||||
|
||||
[$../../libs/circular_buffer/doc/images/space_optimized.png]
|
||||
|
||||
__cbso is an adaptation of the __cb
|
||||
which [*does not allocate memory all at once when created],
|
||||
instead it allocates memory as needed.
|
||||
|
||||
The predictive memory allocation is similar to typical `std::vector` implementation.
|
||||
Memory is automatically freed as the size of the container decreases.
|
||||
|
||||
The memory allocation process of the space-optimized circular buffer.
|
||||
The __min_capacity of the capacity controller represents
|
||||
the minimal guaranteed amount of allocated memory.
|
||||
The allocated memory will never drop under this value.
|
||||
The default value of the `min_capacity` is set to 0.
|
||||
The `min_capacity` can be set using the constructor parameter __capacity_control
|
||||
or the function `set_capacity`.
|
||||
|
||||
The space-optimized version is, of course, a little slower.
|
||||
|
||||
[endsect] [/section:intro Introduction]
|
||||
|
||||
[section:example Circular_buffer example]
|
||||
|
||||
Here is a simple example to introduce the class __cb.
|
||||
|
||||
[import ../example/circular_buffer_example.cpp]
|
||||
|
||||
[circular_buffer_example_1]
|
||||
|
||||
This example shows construction, inserting elements, overwriting and popping.
|
||||
|
||||
[circular_buffer_example_2]
|
||||
|
||||
[/circular_buffer_example_output - there is no output for this example]
|
||||
|
||||
You can see the full example code at [@boost:libs/circular_buffer/example/circular_buffer_example.cpp circular_buffer_example.cpp].
|
||||
|
||||
The full annotated description is in the C++ Reference section.
|
||||
|
||||
[endsect] [/section:example circular_buffer example]
|
||||
|
||||
[section:rationale Rationale]
|
||||
|
||||
The basic motivation behind the __cb was to create a container which would [*work seamlessly with STL].
|
||||
|
||||
Additionally, the design of the __cb was guided by the following principles:
|
||||
|
||||
* Maximum ['efficiency] for envisaged applications.
|
||||
* Suitable for ['general purpose use].
|
||||
* The behaviour of the buffer as ['intuitive] as possible.
|
||||
* Suitable for ['specialization] by means of adaptors. (The __cbso is such an example of the adaptor.)
|
||||
* Easy to ['debug]. (See Debug Support for details.)
|
||||
|
||||
In order to achieve maximum efficiency, the __cb and __cbso store their elements in a
|
||||
[*contiguous region of memory], which then enables:
|
||||
|
||||
* Use of fixed memory and no implicit or unexpected memory allocation.
|
||||
* Fast constant-time insertion and removal of elements from the front and back.
|
||||
* Fast constant-time random access of elements.
|
||||
* Suitability for real-time and performance critical applications.
|
||||
|
||||
Possible applications of the circular buffer include:
|
||||
|
||||
* Storage of the ['most recently received samples], overwriting the oldest as new samples arrive.
|
||||
* As an underlying container for a ['bounded buffer]
|
||||
(see the Bounded Buffer example, code at [@boost:libs/circular_buffer/example/circular_buffer_bound_example.cpp circular_buffer_bound_example.cpp]).
|
||||
* A kind of ['cache] storing a specified number of last inserted elements.
|
||||
* Efficient fixed capacity ['FIFO (First In, First Out)],
|
||||
* Efficient fixed capacity ['LIFO (Last In, First Out)] queue which removes the oldest (inserted as first) elements when full.
|
||||
|
||||
[endsect] [/section:rationale Rationale]
|
||||
|
||||
[section:implementation Implementation ]
|
||||
|
||||
The following paragraphs describe issues that had to be considered during the implementation of the circular_buffer:
|
||||
|
||||
[h3 Thread-Safety]
|
||||
|
||||
The thread-safety of the __cb is the same as the thread-safety of containers in most STL implementations.
|
||||
This means the __cb is not fully thread-safe.
|
||||
The thread-safety is guaranteed only in the sense that simultaneous accesses
|
||||
to distinct instances of the __cb are safe,
|
||||
and simultaneous read accesses to a shared __cb are safe.
|
||||
|
||||
If multiple threads access a single __cb,
|
||||
and at least one of the threads may potentially write,
|
||||
then the user is responsible for ensuring mutual exclusion between the threads during the container accesses.
|
||||
The mutual exclusion between the threads can be achieved by wrapping
|
||||
operations of the underlying __cb with a lock acquisition and release.
|
||||
(See the Bounded Buffer example code at [@boost:libs/circular_buffer/example/circular_buffer_bound_example.cpp circular_buffer_bound_example.cpp])
|
||||
|
||||
[h3 Overwrite Operation]
|
||||
|
||||
Overwrite operation occurs when an element is inserted into a full __cb -
|
||||
the old element is being overwritten by the new one.
|
||||
There was a discussion what exactly "overwriting of an element" means during the formal review.
|
||||
It may be either a destruction of the original element and
|
||||
a consequent inplace construction of a new element
|
||||
or it may be an assignment of a new element into an old one.
|
||||
The __cb implements assignment because it is more effective.
|
||||
|
||||
From the point of business logic of a stored element,
|
||||
the destruction/construction operation and assignment usually mean the same.
|
||||
However, in very rare cases (if in any) they may differ.
|
||||
If there is a requirement for elements to be destructed/constructed instead of being assigned,
|
||||
consider implementing a wrapper of the element which would implement the assign operator,
|
||||
and store the wrappers instead.
|
||||
It is necessary to note that storing such wrappers has a drawback.
|
||||
The destruction/construction will be invoked on every assignment of the wrapper -
|
||||
not only when a wrapper is being overwritten (when the buffer is full)
|
||||
but also when the stored wrappers are being shifted
|
||||
(e.g. as a result of insertion into the middle of container).
|
||||
|
||||
[h3 Writing to a Full Buffer]
|
||||
|
||||
There are several options how to cope if a data source produces more data than can fit in the fixed-sized buffer:
|
||||
|
||||
* Inform the data source to wait until there is room in the buffer (e.g. by throwing an overflow exception).
|
||||
* If the oldest data is the most important, ignore new data from the source until there is room in the buffer again.
|
||||
* If the latest data is the most important, write over the oldest data.
|
||||
* Let the producer to be responsible for checking the size of the buffer prior writing into it.
|
||||
|
||||
It is apparent that the __cb implements the third option.
|
||||
But it may be less apparent it does not implement any other option -
|
||||
especially the first two.
|
||||
One can get an impression that the __cb should implement first three options
|
||||
and offer a mechanism of choosing among them. This impression is wrong.
|
||||
|
||||
The __cb was designed and optimized to be circular
|
||||
(which means overwriting the oldest data when full).
|
||||
If such a controlling mechanism had been enabled,
|
||||
it would just complicate the matters
|
||||
and the usage of the __cb would be probably less straightforward.
|
||||
|
||||
Moreover, the first two options (and the fourth option as well)
|
||||
do not require the buffer to be circular at all.
|
||||
If there is a need for the first or second option, consider implementing an adaptor of e.g. std::vector.
|
||||
In this case the __cb is not suitable for adapting, because,
|
||||
contrary to std::vector, it bears an overhead for its circular behaviour.
|
||||
|
||||
[h3 Reading/Removing from an Empty Buffer]
|
||||
|
||||
When reading or removing an element from an empty buffer,
|
||||
the buffer should be able to notify the data consumer
|
||||
(e.g. by throwing underflow exception) that there are no elements stored in it.
|
||||
The __cb does not implement such a behaviour for two reasons:
|
||||
|
||||
* It would introduce a performance overhead.
|
||||
* No other std container implements it this way.
|
||||
|
||||
It is considered to be a bug to read or remove an element
|
||||
(e.g. by calling [memberref boost::circular_buffer::front() front()]
|
||||
or [memberref boost::circular_buffer::pop_back() pop_back()])
|
||||
from an empty std container and from an empty __cb as well.
|
||||
The data consumer has to test if the container is not empty before reading/removing from it by testing
|
||||
[memberref boost::circular_buffer::empty empty()].
|
||||
However, when reading from the __cb,
|
||||
there is an option to rely on the [memberref boost::circular_buffer::at() at()]
|
||||
method which throws an exception when the index is out of range.
|
||||
|
||||
[h3 Iterator Invalidation]
|
||||
|
||||
An iterator is usually considered to be invalidated if an element,
|
||||
the iterator pointed to, had been removed or overwritten by an another element.
|
||||
This definition is enforced by the Debug Support and is documented for every method.
|
||||
However, some applications utilizing __cb may require less strict definition:
|
||||
an iterator is invalid only if it points to an uninitialized memory.
|
||||
|
||||
Consider following example:
|
||||
|
||||
[import ../example/circular_buffer_iter_example.cpp]
|
||||
|
||||
[circular_buffer_iter_example_1]
|
||||
|
||||
The iterator does not point to the original element any more
|
||||
(and is considered to be invalid from the "strict" point of view)
|
||||
but it still points to the same valid place in the memory.
|
||||
This "soft" definition of iterator invalidation is supported by the __cb
|
||||
but should be considered as an implementation detail rather than a full-fledged feature.
|
||||
The rules when the iterator is still valid can be inferred from the code in
|
||||
[@boost:libs/circular_buffer/test/soft_iterator_invalidation.cpp soft_iterator_invalidation.cpp].
|
||||
|
||||
|
||||
[h3 Move emulation and rvalues]
|
||||
|
||||
Since Boost 1.54.0 support for move semantics was implemented using
|
||||
the [@boost:libs/move/index.html Boost.Move] library.
|
||||
If rvalue references are available __cb will use them, but if not it uses a close,
|
||||
but imperfect emulation. On such compilers:
|
||||
|
||||
* Non-copyable objects can be stored in the containers.
|
||||
They can be constructed in place using `emplace`, or if they support
|
||||
Boost.Move, moved into place.
|
||||
* The containers themselves are not movable.
|
||||
* Argument forwarding is not perfect.
|
||||
|
||||
__cb will use rvalues and move emulations for value types only if move constructor and move assignment operator of the value type do not throw;
|
||||
or if the value type has no copy constructor.
|
||||
|
||||
Some methods won't use move constructor for the value type at all, if the constructor throws. This is
|
||||
required for data consistency and avoidance of situations, when aftrer an exception __cb
|
||||
contains moved away objects along with the good ones.
|
||||
|
||||
See documentation for [@boost:libs/type_traits/doc/html/boost_typetraits/reference/is_copy_constructible.html `is_copy_constructible`], [@boost:libs/type_traits/doc/html/boost_typetraits/reference/is_nothrow_move_assignable.html `is_nothrow_move_assignable`] and [@boost:libs/type_traits/doc/html/boost_typetraits/reference/is_nothrow_move_constructible.html `is_nothrow_move_constructible`] type triats.
|
||||
There you'll find information about how to make constructor of class noexcept and how to make a non-copyable
|
||||
class in C++03 and C++98.
|
||||
|
||||
Performance of __cb will *greatly improve* if value type has noexcept move constructor and noexcept move assignment.
|
||||
|
||||
[h3 Exceptions of move_if_noexcept(T&)]
|
||||
|
||||
Reference documentation of the __cb contains notes like "Throws: See Exceptions of `move_if_noexcept(T&)`".
|
||||
That note means the following: `move_if_noexcept(T& value)` does not throws exceptions at all, but it returns
|
||||
`value` as rvalue reference only if class `T` have noexcept move constructor and noexcept move assignment operator;
|
||||
or if it has no copy constructor. Otherwise `move_if_noexcept(T& value)` returns `value` as const reference.
|
||||
|
||||
This leads us to the following situation:
|
||||
|
||||
* If `value` has a noexcept move constructor and noexcept move assignment operator, then no exceptions will be thrown at all.
|
||||
* If `value` has a throwing move constructor and some copy constructor, then method may throw exceptions of copy constructor.
|
||||
* If `value` has no copy constructor, then method may throw exceptions of move constructor.
|
||||
|
||||
`move_if_noexcept(T&)` uses [@boost:libs/move/index.html Boost.Move], [@boost:libs/type_traits/doc/html/boost_typetraits/reference/is_copy_constructible.html `is_copy_constructible`], [@boost:libs/type_traits/doc/html/boost_typetraits/reference/is_nothrow_move_assignable.html `is_nothrow_move_assignable`] and [@boost:libs/type_traits/doc/html/boost_typetraits/reference/is_nothrow_move_constructible.html `is_nothrow_move_constructible`] type triats.
|
||||
|
||||
|
||||
[h3 Caveats]
|
||||
|
||||
The __cb should not be used for storing pointers to dynamically allocated objects.
|
||||
When a circular buffer becomes full, further insertion will overwrite the stored pointers
|
||||
- resulting in a [*memory leak]. One recommend alternative is the use of smart pointers, for example
|
||||
[@http://www.boost.org/doc/libs/1_53_0/libs/smart_ptr/smart_ptr.htm Boost Smart pointers].
|
||||
|
||||
[@http://en.wikipedia.org/wiki/Std::auto_ptr std::auto_ptr]
|
||||
|
||||
[caution Any container of `std::auto_ptr` is considered particularly hazardous.]
|
||||
|
||||
[tip Never create a circular buffer of `std::auto_ptr`.
|
||||
Refer to Scott Meyers' excellent book Effective STL for a detailed discussion.
|
||||
(Meyers S., Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library.
|
||||
Addison-Wesley, 2001.)
|
||||
]
|
||||
|
||||
While internals of a __cb are circular, [*iterators are not].
|
||||
Iterators of a __cb are only valid for the range `\[begin(), end()\]`,
|
||||
so for example: iterators `(begin() - 1)` and `(end() + 1)` are both invalid.
|
||||
|
||||
[h3 Debug Support]
|
||||
|
||||
In order to help a programmer to avoid and find common bugs,
|
||||
the __cb can be enabled to provide a kind of debug support.
|
||||
|
||||
When the debugging functionality is enabled, the __cb maintains a list of valid iterators.
|
||||
As soon as any element gets destroyed all iterators pointing to this element
|
||||
are removed from this list and explicitly invalidated (an invalidation flag is set).
|
||||
The debug support also consists of many assertions (`BOOST_ASSERT` macros)
|
||||
which ensure the __cb and its iterators are used in the correct manner at runtime.
|
||||
In case an invalid iterator is used, the assertion will report an error.
|
||||
The connection of explicit iterator invalidation and assertions
|
||||
makes a very robust debug technique which catches most of the errors.
|
||||
|
||||
Moreover, the uninitialized memory allocated by __cb is filled with the value `0xcc` in the debug mode.
|
||||
When debugging the code, this can help the programmer to recognize the initialized memory from the uninitialized.
|
||||
For details refer the source code [@boost:boost/circular_buffer/debug.hpp circular_buffer/debug.hpp].
|
||||
|
||||
[caution Since the debugging code makes __cb and its iterators more interconnected, thread safety guarantees of __cb
|
||||
are different when debug support is enabled. In addition to the container itself, all iterators tracked by the container
|
||||
(including any copies thereof) must be protected from concurrent access. In particular, this includes copying, destroying or
|
||||
obtaining iterators from the container, even if for read-only access.]
|
||||
|
||||
The debug support is disabled by default. To enable it, one has to define `BOOST_CB_ENABLE_DEBUG` macro with the value of 1
|
||||
while compiling the code using __cb.
|
||||
|
||||
[h3 Compatibility with Interprocess library]
|
||||
|
||||
The __cb is compatible with the [@boost:libs/interprocess/index.html Boost.Interprocess]
|
||||
[/ 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 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.
|
||||
|
||||
[endsect] [/section:implementation Implementation ]
|
||||
|
||||
[section:examples More Examples]
|
||||
|
||||
[h3 Summing all the values in a circular buffer]
|
||||
|
||||
[import ../example/circular_buffer_sum_example.cpp]
|
||||
|
||||
[circular_buffer_sum_example_1]
|
||||
|
||||
[/circular_buffer_example_output - there is no output for this example]
|
||||
|
||||
The __cb has a capacity of three `int`.
|
||||
Therefore, the size of the buffer will never exceed three.
|
||||
The `std::accumulate` algorithm evaluates the sum of the stored elements.
|
||||
The semantics of the __cb can be inferred from the assertions.
|
||||
|
||||
You can see the full example code at [@boost:libs/circular_buffer/example/circular_buffer_sum_example.cpp circular_buffer_sum_example.cpp].
|
||||
|
||||
[h3 Bounded Buffer Example]
|
||||
|
||||
The bounded buffer is normally used in a producer-consumer mode:
|
||||
producer threads produce items and store them in the container
|
||||
and consumer threads remove these items and process them.
|
||||
The bounded buffer has to guarantee that
|
||||
|
||||
* producers do not insert items into the container when the container is full,
|
||||
* consumers do not try to remove items when the container is empty,
|
||||
* each produced item is consumed by exactly one consumer.
|
||||
|
||||
[import ../example/circular_buffer_bound_example.cpp]
|
||||
|
||||
[circular_buffer_bound_example_1]
|
||||
|
||||
[/ there is no output for this example]
|
||||
|
||||
The bounded_buffer relies on [@boost:/doc/html/thread.html Boost.Thread]
|
||||
and [@boost:libs/bind/index.html Boost.Bind] libraries
|
||||
and [@boost:libs/utility/call_traits.htm Boost.call_traits utility].
|
||||
|
||||
The [memberref boost::circular_buffer::push_front() push_front()]
|
||||
method is called by the producer thread in order to insert a new item into the buffer.
|
||||
The method locks the mutex and waits until there is a space for the new item.
|
||||
(The mutex is unlocked during the waiting stage and has to be regained when the condition is met.)
|
||||
If there is a space in the buffer available,
|
||||
the execution continues and the method inserts the item at the end of the __cb.
|
||||
Then it increments the number of unread items and unlocks the mutex
|
||||
(in case an exception is thrown before the mutex is unlocked,
|
||||
the mutex is unlocked automatically by the destructor of the scoped_lock).
|
||||
At last the method notifies one of the consumer threads
|
||||
waiting for a new item to be inserted into the buffer.
|
||||
|
||||
The [memberref boost::circular_buffer::pop_back() pop_back()]
|
||||
method is called by the consumer thread in order to read the next item from the buffer.
|
||||
The method locks the mutex and waits until there is an unread item in the buffer.
|
||||
If there is at least one unread item,
|
||||
the method decrements the number of unread items and reads the next item from the __cb.
|
||||
Then it unlocks the mutex and notifies one of the producer threads
|
||||
waiting for the buffer to free a space for the next item.
|
||||
|
||||
The `bounded buffer::pop_back()`
|
||||
method [*does not remove the item] but the item is left
|
||||
in the circular_buffer which then [*replaces it with a new one]
|
||||
(inserted by a producer) when the circular_buffer is full.
|
||||
This technique is more effective than removing the item
|
||||
explicitly by calling the [memberref boost::circular_buffer::pop_back() circular_buffer::pop_back()]
|
||||
method of the __cb.
|
||||
|
||||
This claim is based on the assumption that an assignment (replacement)
|
||||
of a new item into an old one is more effective than a destruction
|
||||
(removal) of an old item and a consequent inplace construction (insertion) of a new item.
|
||||
|
||||
For comparison of bounded buffers based on different containers compile and
|
||||
run [@boost:libs/circular_buffer/test/bounded_buffer_comparison.cpp bounded_buffer_comparison.cpp].
|
||||
The test should reveal the bounded buffer based on the __cb is most effective
|
||||
closely followed by the `std::deque` based bounded buffer.
|
||||
(In reality, the result may differ sometimes because the test
|
||||
is always affected by external factors such as immediate CPU load.)
|
||||
|
||||
[import ../test/bounded_buffer_comparison.cpp]
|
||||
|
||||
You can see the full test code at [@boost:libs/circular_buffer/test/bounded_buffer_comparison.cpp bounded_buffer_comparison.cpp],
|
||||
and an example of output is [bounded_buffer_comparison_output].
|
||||
|
||||
[endsect] [/section:examples More examples]
|
||||
|
||||
[section:headers Header Files]
|
||||
|
||||
The circular buffer library is defined in the file [@boost:boost/circular_buffer.hpp circular_buffer.hpp].
|
||||
|
||||
#include <boost/circular_buffer.hpp>
|
||||
|
||||
(There is also a forward declaration for the __cb
|
||||
in the header file [@boost:boost/circular_buffer_fwd.hpp circular_buffer_fwd.hpp]).
|
||||
|
||||
The __cb is defined in the file [@boost:boost/circular_buffer/base.hpp base.hpp].
|
||||
|
||||
The __cbso is defined in the file [@boost:boost/circular_buffer/space_optimized.hpp space_optimized.hpp].
|
||||
|
||||
[endsect] [/section:headers Header Files]
|
||||
|
||||
[section:concepts Modelled Concepts]
|
||||
|
||||
[@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]
|
||||
|
||||
[section:template_params Template Parameters]
|
||||
|
||||
[table:templ Template parameter requirements
|
||||
[[parameter] [Requirements]]
|
||||
[[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 [@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 [@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.
|
||||
The Alloc has to meet the allocator requirements imposed by STL.]]
|
||||
]
|
||||
|
||||
[endsect] [/section:template_params Template Parameters]
|
||||
|
||||
[section:tickets Trac Tickets]
|
||||
|
||||
Report and view bugs and features by adding a ticket at [@https://svn.boost.org/trac/boost Boost.Trac].
|
||||
|
||||
Existing open tickets for this library alone can be viewed
|
||||
[@https://svn.boost.org/trac/boost/query?status=assigned&status=new&status=reopened&component=circular_buffer&col=id&col=summary&col=status&col=owner&col=type&col=milestone&order=priority here].
|
||||
Existing tickets for this library - including closed ones - can be viewed
|
||||
[@https://svn.boost.org/trac/boost/query?status=assigned&status=closed&status=new&status=reopened&component=circular_buffer&col=id&col=summary&col=status&col=owner&col=type&col=milestone&order=priority here].
|
||||
|
||||
Type: Bugs
|
||||
|
||||
[@https://svn.boost.org/trac/boost/ticket/4100 #4100] Some boost classes have sizeof that depends on NDEBUG.
|
||||
|
||||
[@https://svn.boost.org/trac/boost/ticket/5362 #5362] circular_buffer does not compile with BOOST_NO_EXCEPTIONS.
|
||||
|
||||
[@https://svn.boost.org/trac/boost/ticket/6277 #6277] Checked iterators are not threadsafe.
|
||||
|
||||
[@https://svn.boost.org/trac/boost/ticket/6747 #6747] Circular_Buffer / Bounded_Buffer inside Template class problem.
|
||||
|
||||
[@https://svn.boost.org/trac/boost/ticket/7025 #7025] circular buffer reports warning: " type qualifiers ignored on function return type" while compile.
|
||||
|
||||
[@https://svn.boost.org/trac/boost/ticket/7950 #7950] Eliminate W4-warnings under VS2005.
|
||||
|
||||
[@https://svn.boost.org/trac/boost/ticket/8012 #8012] Inconsistency in `linearize()`.
|
||||
|
||||
[@https://svn.boost.org/trac/boost/ticket/8438 #8438] `vector` & __cb storage misbehave when using compiler optimizations.
|
||||
|
||||
Type: Feature Requests
|
||||
|
||||
[@https://svn.boost.org/trac/boost/ticket/5511 #5511] Documentation needs some improvement.
|
||||
|
||||
[@https://svn.boost.org/trac/boost/ticket/7888 #7888] circular_buffer should support move semantics.
|
||||
|
||||
Type: Patches
|
||||
|
||||
[@https://svn.boost.org/trac/boost/ticket/8032 #8032] Warning fixes in circular_buffer.
|
||||
|
||||
[endsect] [/section:tickets Trac Tickets]
|
||||
|
||||
[section:release Release Notes]
|
||||
|
||||
[h4 Boost 1.56]
|
||||
|
||||
* C++11 allocator model support implemented by Glen Fernandes.
|
||||
|
||||
[h4 Boost 1.55]
|
||||
|
||||
* Documentation refactored by Paul A. Bristow using Quickbook, Doxygen and Autoindexing.
|
||||
* Rvalue references emulation added by Antony Polukhin using Boost.Move.
|
||||
|
||||
[h4 Boost 1.42]
|
||||
|
||||
* Added methods erase_begin(size_type) and erase_end(size_type) with constant complexity for such types of stored elements which do not need an explicit destruction e.g. int or double.
|
||||
* Similarly changed implementation of the clear() method and the destructor so their complexity is now constant for such types of stored elements which do not require an explicit destruction (the complexity for other types remains linear).
|
||||
|
||||
[h4 Boost 1.37]
|
||||
|
||||
*Added new methods is_linearized() and rotate(const_iterator).
|
||||
* Fixed bugs:
|
||||
[@https://svn.boost.org/trac/boost/ticket/1987 #1987] Patch to make circular_buffer.hpp #includes absolute.
|
||||
[@https://svn.boost.org/trac/boost/ticket/1852 #1852] Copy constructor does not copy capacity.
|
||||
|
||||
[h4 Boost 1.36]
|
||||
|
||||
* Changed behaviour of the circular_buffer(const allocator_type&) constructor.
|
||||
Since this version the constructor does not allocate any memory and both capacity and size are set to zero.
|
||||
* Fixed bug:
|
||||
[@https://svn.boost.org/trac/boost/ticket/191 #1919] Default constructed circular buffer throws std::bad_alloc.
|
||||
|
||||
[h4 Boost 1.35]
|
||||
* Initial release.
|
||||
|
||||
[endsect] [/section:release Release Notes]
|
||||
|
||||
[section:acknowledgements Acknowledgements]
|
||||
|
||||
Thomas Witt in 2002 produced a prototype called cyclic buffer.
|
||||
|
||||
The circular_buffer has a short history. Its first version was a std::deque adaptor.
|
||||
This container was not very effective because of many reallocations when inserting/removing an element.
|
||||
Thomas Wenish did a review of this version and
|
||||
motivated me to create a circular buffer which allocates memory at once when created.
|
||||
|
||||
The second version adapted `std::vector` but it has been abandoned soon
|
||||
because of limited control over iterator invalidation.
|
||||
The current version is a full-fledged STL compliant container.
|
||||
|
||||
Pavel Vozenilek did a thorough review of this version and came with many good ideas and improvements.
|
||||
|
||||
The idea of the space optimized circular buffer has been introduced by Pavel Vozenilek.
|
||||
|
||||
Also, I would like to thank Howard Hinnant, Nigel Stewart and everyone
|
||||
who participated at the formal review for valuable comments and ideas.
|
||||
|
||||
Paul A. Bristow refactored the documentation in 2013 to use the full power of Quickbook, Doxygen and Autoindexing.
|
||||
|
||||
[endsect] [/section:acknowledgements Acknowledgements]
|
||||
|
||||
|
||||
[section:version_id Documentation Version Info]
|
||||
|
||||
Last edit to Quickbook file __FILENAME__ was at __TIME__ on __DATE__.
|
||||
|
||||
[tip This should appear on the pdf version
|
||||
(but may be redundant on a html version where the last edit date is on the first (home) page).]
|
||||
|
||||
[warning Home page "Last revised" is GMT, not local time. Last edit date is local time.]
|
||||
[/See also Adobe Reader pdf File Properties for creation date, and PDF producer, version and page count.]
|
||||
|
||||
[endsect] [/section:version_id Version Info]
|
||||
|
||||
[xinclude autodoc.xml] [/ Using Doxygen reference documentation.]
|
||||
[/ The position of this in the Quickbook determines the location of the Doxygen references section.]
|
||||
[/ Index(es) should be invoked in the main module, not within a section.]
|
||||
|
||||
'''
|
||||
<index/>
|
||||
'''
|
||||
|
||||
[/ circular_buffer.qbk
|
||||
Copyright 2013 Paul A. Bristow.
|
||||
Copyright 2003-2008 Jan Gaspar.
|
||||
|
||||
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).
|
||||
]
|
||||
|
||||
|
||||
68
doc/circular_buffer.xslt
Normal file
68
doc/circular_buffer.xslt
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<!--
|
||||
XSL transformation from the XML files generated by Doxygen into XHTML source
|
||||
code documentation of the circular_buffer.
|
||||
|
||||
Copyright (c) 2003-2008 Jan Gaspar
|
||||
|
||||
Use, modification, and distribution is subject to the Boost Software
|
||||
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
-->
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
<xsl:import href="doxygen2html.xslt"/>
|
||||
|
||||
<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes" media-type="text/xml"/>
|
||||
|
||||
<xsl:variable name="link-prefix" select="''"/>
|
||||
<xsl:variable name="standalone-functions" select="document(concat($xmldir, '/namespaceboost.xml'))/doxygen/compounddef/sectiondef[@kind='func']"/>
|
||||
|
||||
<xsl:template name="reference">
|
||||
<xsl:value-of select="concat('#', @refid)"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="template-parameters">
|
||||
<xsl:apply-templates select="templateparamlist/param" mode="synopsis"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="public-types">
|
||||
<xsl:apply-templates select="sectiondef[@kind='public-type']/memberdef" mode="synopsis"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="constructors">
|
||||
<xsl:apply-templates select="sectiondef[@kind='public-func']/memberdef[type = '']" mode="synopsis"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="member-functions">
|
||||
<xsl:apply-templates select="sectiondef[@kind='public-func']/memberdef[type != '']" mode="synopsis"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="standalone-functions">
|
||||
<xsl:apply-templates select="$standalone-functions/memberdef[contains(argsstring, 'circular_buffer<')]" mode="synopsis">
|
||||
<xsl:with-param name="indent" select="''"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="template-parameters-details">
|
||||
<xsl:apply-templates select="detaileddescription//parameterlist[@kind='param']/parameteritem" mode="description"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="public-types-details">
|
||||
<xsl:apply-templates select="sectiondef[@kind='public-type']/memberdef" mode="description"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="constructors-details">
|
||||
<xsl:apply-templates select="sectiondef[@kind='public-func']/memberdef[type = '']" mode="description"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="member-functions-details">
|
||||
<xsl:apply-templates select="sectiondef[@kind='public-func']/memberdef[type != '']" mode="description"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="standalone-functions-details">
|
||||
<xsl:apply-templates select="$standalone-functions/memberdef[contains(argsstring, 'circular_buffer<')]" mode="description"/>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
20
doc/copy.xslt
Normal file
20
doc/copy.xslt
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!--
|
||||
Helper XSL transformation making plain copy of an XML tree.
|
||||
|
||||
Copyright (c) 2003-2008 Jan Gaspar
|
||||
|
||||
Use, modification, and distribution is subject to the Boost Software
|
||||
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
-->
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
<xsl:template match="/ | node() | @* | comment() | processing-instruction()">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@* | node()"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
363
doc/doxygen2html.xslt
Normal file
363
doc/doxygen2html.xslt
Normal file
@@ -0,0 +1,363 @@
|
||||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<!--
|
||||
Generic XSL transformation from the XML files generated by Doxygen into XHTML
|
||||
source code documentation.
|
||||
|
||||
Copyright (c) 2003-2008 Jan Gaspar
|
||||
|
||||
Use, modification, and distribution is subject to the Boost Software
|
||||
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
-->
|
||||
|
||||
<!DOCTYPE stylesheet [
|
||||
<!ENTITY nbsp " ">
|
||||
<!ENTITY space " ">
|
||||
]>
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
<xsl:param name="container"/>
|
||||
<xsl:param name="xmldir"/>
|
||||
<xsl:variable name="container-ref" select="//compound[name=concat('boost::', $container) and @kind='class']/@refid"/>
|
||||
<xsl:variable name="class-file" select="concat($xmldir, '/', $container-ref, '.xml')"/>
|
||||
<xsl:variable name="class" select="document($class-file)/doxygen/compounddef[@id = $container-ref]"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<html>
|
||||
<header><title>Source Code Documentation</title></header>
|
||||
<body>
|
||||
<xsl:apply-templates select="$class" mode="synopsis"/>
|
||||
<xsl:apply-templates select="$class" mode="description"/>
|
||||
</body>
|
||||
</html>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="nonbreakablespace">
|
||||
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="bold">
|
||||
<b><xsl:apply-templates/></b>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="emphasis">
|
||||
<i><xsl:apply-templates/></i>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="linebreak">
|
||||
<br />
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="preformatted">
|
||||
<pre><xsl:apply-templates/></pre>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="computeroutput">
|
||||
<code><xsl:apply-templates/></code>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="para">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="ref">
|
||||
<xsl:variable name="link-text" select="substring-after(text(), concat($container, '::'))"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="string-length($link-text) > 0">
|
||||
<xsl:element name="a">
|
||||
<xsl:attribute name="href"><xsl:call-template name="reference"/></xsl:attribute>
|
||||
<xsl:value-of select="$link-text"/>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:when test="text() = $container">
|
||||
<xsl:value-of select="text()"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:element name="a">
|
||||
<xsl:choose>
|
||||
<xsl:when test="count(//memberdef[@id=current()/@refid]) > 0">
|
||||
<xsl:attribute name="href"><xsl:value-of select="concat('#', @refid)"/></xsl:attribute>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:attribute name="href"><xsl:value-of select="concat($link-prefix, '#', @refid)"/></xsl:attribute>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:value-of select="text()"/>
|
||||
</xsl:element>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="ulink">
|
||||
<a href="{@url}"><xsl:apply-templates/></a>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="parameteritem">
|
||||
<xsl:param name="desc" select="''"/>
|
||||
<xsl:param name="style" select="'code'"/>
|
||||
<xsl:if test="$desc != ''">
|
||||
<dt><b><xsl:value-of select="$desc"/></b></dt>
|
||||
</xsl:if>
|
||||
<dd>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$style = 'code'">
|
||||
<dl compact="yes">
|
||||
<dt><code><xsl:apply-templates select="parameternamelist/parametername"/></code></dt>
|
||||
<dd><xsl:apply-templates select="parameterdescription"/></dd>
|
||||
</dl>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains(parameternamelist/parametername, '<code>')">
|
||||
<code><xsl:value-of select="substring-before(substring-after(parameternamelist/parametername, '<code>'), '</code>')"/></code>
|
||||
<xsl:apply-templates select="parameterdescription"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates select="parameternamelist/parametername"/>
|
||||
<xsl:apply-templates select="parameterdescription"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</dd>
|
||||
<xsl:apply-templates select="following-sibling::parameteritem[1]">
|
||||
<xsl:with-param name="style" select="$style"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="simplesect[@kind='return']">
|
||||
<dl><dt><b>Returns:</b></dt><dd><xsl:apply-templates/></dd></dl>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="simplesect[@kind='pre']">
|
||||
<dl><dt><b>Precondition:</b></dt><dd><xsl:apply-templates/></dd></dl>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="simplesect[@kind='post']">
|
||||
<dl><dt><b>Effect:</b></dt><dd><xsl:apply-templates/></dd></dl>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="simplesect[@kind='par']">
|
||||
<dl><dt><b><xsl:value-of select="title"/>:</b></dt><dd><xsl:apply-templates select="para"/></dd></dl>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="simplesect[@kind='warning']">
|
||||
<dl><dt><b>Warning:</b></dt><dd><xsl:apply-templates/></dd></dl>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="simplesect[@kind='note']">
|
||||
<dl><dt><b>Note:</b></dt><dd><xsl:apply-templates/></dd></dl>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="simplesect[@kind='see']">
|
||||
<dl><dt><b>See Also:</b></dt><dd><xsl:apply-templates/></dd></dl>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="parameterlist[@kind='param']">
|
||||
<dl><xsl:apply-templates select="parameteritem[1]">
|
||||
<xsl:with-param name="desc" select="'Parameter(s):'"/>
|
||||
</xsl:apply-templates></dl>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="parameterlist[@kind='exception']">
|
||||
<dl><xsl:apply-templates select="parameteritem[1]">
|
||||
<xsl:with-param name="desc" select="'Throws:'"/>
|
||||
<xsl:with-param name="style" select="'plain'"/>
|
||||
</xsl:apply-templates></dl>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="briefdescription">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Synopsis mode -->
|
||||
|
||||
<xsl:template match="compounddef[@kind = 'class']" mode="synopsis">
|
||||
<div id="srcdoc_synopsis">
|
||||
<table id="table_synopsis" border="0" cellpadding="10">
|
||||
<tr><td>
|
||||
<pre>
|
||||
namespace boost {
|
||||
|
||||
template <<xsl:call-template name="template-parameters"/>>
|
||||
class <xsl:value-of select="$container"/>
|
||||
{
|
||||
public:
|
||||
<xsl:call-template name="public-types"/><xsl:text disable-output-escaping="yes">
|
||||
</xsl:text>
|
||||
<xsl:call-template name="constructors"/><xsl:text disable-output-escaping="yes">
|
||||
</xsl:text>
|
||||
<xsl:call-template name="member-functions"/><xsl:text disable-output-escaping="yes">};
|
||||
|
||||
</xsl:text>
|
||||
<xsl:call-template name="standalone-functions"/>
|
||||
} // namespace boost
|
||||
</pre>
|
||||
</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="param" mode="synopsis">
|
||||
<xsl:param name="link-prefix" select="''"/>
|
||||
<xsl:value-of select="type"/> <a href="{$link-prefix}#templateparam_{declname}"><xsl:value-of select="declname"/></a><xsl:value-of select="substring(', ', 1 div (count(following-sibling::param) != 0))"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="memberdef[@kind='typedef']" mode="synopsis">
|
||||
<xsl:param name="link-prefix" select="''"/>
|
||||
<xsl:if test="normalize-space(briefdescription) != ''"> typedef <xsl:value-of select="substring('typename ', 1 div (contains(type, '::') and not(contains(type, '>'))))"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains(type, 'cb_details::')"><i>implementation-defined</i> </xsl:when>
|
||||
<xsl:otherwise><xsl:apply-templates select="type" mode="synopsis"/> </xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<a href="{$link-prefix}#{@id}"><xsl:value-of select="name"/></a>;<xsl:text disable-output-escaping="yes">
|
||||
</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="memberdef[@kind='function']" mode="synopsis">
|
||||
<xsl:param name="indent" select="' '"/>
|
||||
<xsl:param name="link-prefix" select="''"/>
|
||||
<xsl:param name="link" select="''"/>
|
||||
<xsl:value-of select="$indent"/>
|
||||
<xsl:value-of select="substring('explicit ', 1 div (@explicit = 'yes'))"/>
|
||||
<xsl:if test="count(templateparamlist) > 0">template <<xsl:for-each select="templateparamlist/param"><xsl:value-of select="type"/> <xsl:value-of select="declname"/><xsl:value-of select="substring(', ', 1 div (count(following-sibling::param) != 0))"/></xsl:for-each>><xsl:text disable-output-escaping="yes">
|
||||
</xsl:text><xsl:value-of select="$indent"/>
|
||||
</xsl:if>
|
||||
<xsl:if test="type != ''"><xsl:apply-templates select="type" mode="synopsis"/> </xsl:if>
|
||||
<a href="{$link-prefix}#{concat(substring(@id, 1 div (string-length($link) = 0)), substring($link, 1 div (string-length($link) > 0)))}">
|
||||
<xsl:value-of select="name"/>
|
||||
</a>(<xsl:for-each select="param">
|
||||
<xsl:apply-templates select="type" mode="synopsis"/> <xsl:value-of select="declname"/>
|
||||
<xsl:value-of select="substring(concat(' = ', defval), 1 div (normalize-space(defval) != ''))"/>
|
||||
<xsl:value-of select="substring(', ', 1 div (count(following-sibling::param) != 0))"/>
|
||||
</xsl:for-each>)<xsl:value-of select="substring(' const', 1 div (@const = 'yes'))"/>;<xsl:text disable-output-escaping="yes">
|
||||
</xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="type" mode="synopsis">
|
||||
<xsl:for-each select="text() | ref">
|
||||
<xsl:variable name="item" select="translate(., '&space;', '')"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($item, 'return_value_type') or contains($item, 'param_value_type')">const_reference</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($item, ',')"><xsl:value-of select="concat(substring-before($item, ','), ', ', substring-after($item, ','))"/></xsl:when>
|
||||
<xsl:otherwise><xsl:value-of select="$item"/></xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="not(contains($item, '<')) and not(contains($item, ',')) and name(.) != 'ref' and position() != last()"> </xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Description mode -->
|
||||
|
||||
<xsl:template match="compounddef[@kind = 'class']" mode="description">
|
||||
<div id="srcdoc_params">
|
||||
<table id="table_template_params" border="1" cellpadding="3">
|
||||
<tr><th>Parameter</th><th>Description</th><th>Default</th></tr>
|
||||
<xsl:call-template name="template-parameters-details"/>
|
||||
</table>
|
||||
</div>
|
||||
<div id="srcdoc_types">
|
||||
<table id="table_public_types" border="1" cellpadding="3">
|
||||
<tr><th>Type</th><th>Description</th></tr>
|
||||
<xsl:call-template name="public-types-details"/>
|
||||
</table>
|
||||
</div>
|
||||
<div id="srcdoc_constructors">
|
||||
<table id="table_constructors" border="1" cellpadding="3">
|
||||
<xsl:call-template name="constructors-details"/>
|
||||
</table>
|
||||
</div>
|
||||
<div id="srcdoc_methods">
|
||||
<table id="table_methods" border="1" cellpadding="3">
|
||||
<xsl:call-template name="member-functions-details"/>
|
||||
</table>
|
||||
</div>
|
||||
<div id="srcdoc_functions">
|
||||
<table id="table_functions" border="1" cellpadding="3">
|
||||
<xsl:call-template name="standalone-functions-details"/>
|
||||
</table>
|
||||
</div>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="parameteritem" mode="description">
|
||||
<tr><td><a id="templateparam_{parameternamelist/parametername}"><code><xsl:value-of select="parameternamelist/parametername"/></code></a></td>
|
||||
<td>
|
||||
<xsl:apply-templates select="parameterdescription"/>
|
||||
<xsl:variable name="type-rqmts" select="concat('Type Requirements ', parameternamelist/parametername)"/>
|
||||
<xsl:if test="../../simplesect[@kind='par']/title = $type-rqmts">
|
||||
<dl><dt><b>Type Requirements:</b></dt>
|
||||
<dd><xsl:apply-templates select="../../simplesect[@kind='par'][title=$type-rqmts]/para"/></dd></dl>
|
||||
</xsl:if>
|
||||
</td>
|
||||
<xsl:variable name="default-value" select="concat('Default ', parameternamelist/parametername)"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="../../simplesect[@kind='par']/title = $default-value">
|
||||
<td><code><xsl:value-of select="../../simplesect[@kind='par'][title=$default-value]/para"/></code></td>
|
||||
</xsl:when>
|
||||
<xsl:otherwise><td><br/></td></xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</tr>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="memberdef[@kind='typedef']" mode="description">
|
||||
<xsl:if test="normalize-space(briefdescription) != ''">
|
||||
<tr><td><a id="{@id}"><code><xsl:value-of select="name"/></code></a></td>
|
||||
<td>
|
||||
<xsl:apply-templates select="briefdescription/child::*"/>
|
||||
<xsl:if test="boolean(detaileddescription/para)">
|
||||
<xsl:apply-templates select="detaileddescription/para/text()|detaileddescription/para/child::*"/>
|
||||
</xsl:if>
|
||||
</td></tr>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="memberdef[@kind='function']" mode="description">
|
||||
<xsl:param name="link-prefix" select="''"/>
|
||||
<tr><td><a id="{@id}" /><code><b><xsl:value-of select="substring('explicit ', 1 div (@explicit = 'yes'))"/>
|
||||
<xsl:if test="count(templateparamlist) > 0">
|
||||
template <<xsl:for-each select="templateparamlist/param"><xsl:value-of select="type"/> <xsl:value-of select="declname"/><xsl:value-of select="substring(', ', 1 div (count(following-sibling::param) != 0))"/></xsl:for-each>><br />
|
||||
</xsl:if>
|
||||
<xsl:if test="type != ''"><xsl:apply-templates select="type" mode="description"/> </xsl:if>
|
||||
<xsl:value-of select="name"/>(<xsl:for-each select="param">
|
||||
<xsl:apply-templates select="type" mode="description"/> <xsl:value-of select="declname"/>
|
||||
<xsl:value-of select="substring(concat(' = ', defval), 1 div (normalize-space(defval) != ''))"/>
|
||||
<xsl:value-of select="substring(', ', 1 div (count(following-sibling::param) != 0))"/>
|
||||
</xsl:for-each>)<xsl:value-of select="substring(' const', 1 div (@const = 'yes'))"/>;</b></code><br /><br />
|
||||
<xsl:apply-templates select="briefdescription"/>
|
||||
<xsl:if test="normalize-space(detaileddescription) = ''">
|
||||
<br /><br />
|
||||
</xsl:if>
|
||||
<p><xsl:apply-templates select="detaileddescription"/></p>
|
||||
</td></tr>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="type" mode="description">
|
||||
<xsl:for-each select="text() | ref">
|
||||
<xsl:variable name="item" select="translate(., '&space;', '')"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$item = 'return_value_type' or $item = 'param_value_type'">
|
||||
<xsl:variable name="const-reference" select="$class[@kind = 'class']/sectiondef[@kind='public-type']/memberdef[@kind='typedef' and name='const_reference']"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="boolean($const-reference/reimplements)">
|
||||
<a href="{$link-prefix}#{$const-reference/reimplements/@refid}">const_reference</a>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<a href="{$link-prefix}#{$const-reference/@id}">const_reference</a>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="contains($item, 'circular_buffer')"><xsl:value-of select="$item"/></xsl:when>
|
||||
<xsl:when test="@refid">
|
||||
<xsl:element name="a">
|
||||
<xsl:attribute name="href"><xsl:call-template name="reference"/></xsl:attribute>
|
||||
<xsl:value-of select="$item"/>
|
||||
</xsl:element>
|
||||
</xsl:when>
|
||||
<xsl:otherwise><xsl:value-of select="$item"/></xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:if test="name(.) != 'ref' and position() != last()"> </xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
18
doc/html2xhtml.xslt
Normal file
18
doc/html2xhtml.xslt
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<!--
|
||||
Helper XSL transformation which converts HTML into XHTML.
|
||||
|
||||
Copyright (c) 2003-2008 Jan Gaspar
|
||||
|
||||
Use, modification, and distribution is subject to the Boost Software
|
||||
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
-->
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
<xsl:import href="copy.xslt"/>
|
||||
|
||||
<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes" media-type="text/html"/>
|
||||
|
||||
</xsl:stylesheet>
|
||||
217
doc/jamfile.v2
217
doc/jamfile.v2
@@ -1,217 +0,0 @@
|
||||
|
||||
# Boost.circular_buffer library documentation Jamfile.v2
|
||||
#
|
||||
# Copyright Paul A. Bristow 2013.
|
||||
# Copyright Jan Gaspar 2003-2008.
|
||||
|
||||
# Use, modification and distribution is subject to
|
||||
# the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt
|
||||
# or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
path-constant nav_images : html/images/ ; # png and svg images for home, next, note, tip...
|
||||
path-constant images_location : html/images ; # location of my SVG and PNG images referenced by Quickbook.
|
||||
path-constant pdf_images_location : .. ; # location of SVG and PNG images referenced by pdf.
|
||||
path-constant here : . ; # location of /doc folder.
|
||||
|
||||
# echo "nav_images = " $(nav_images) ; # "nav_images = I:\boost-trunk\libs\circular_buffer\doc\html\images
|
||||
# echo "images_location = " $(images_location) ; # images_location = I:\boost-trunk\libs\circular_buffer\doc\html\images
|
||||
# echo "pdf_images_location = " $(pdf_images_location) #
|
||||
import modules ;
|
||||
using auto-index ;
|
||||
using doxygen ; # Required if you want to use Doxygen.
|
||||
using quickbook ;
|
||||
|
||||
|
||||
doxygen autodoc
|
||||
:
|
||||
# List all the files individually (RECURSIVE=NO ).
|
||||
[ glob ../../../boost/circular_buffer.hpp ]
|
||||
[ glob ../../../boost/circular_buffer/base.hpp ]
|
||||
[ glob ../../../boost/circular_buffer/space_optimized.hpp ]
|
||||
|
||||
:
|
||||
# Pass some setting parameters to Doxygen.
|
||||
<doxygen:param>WARNINGS=YES # Default NO, but useful to see warnings, especially in a logfile.
|
||||
# It is also wise to to set a warnings logfile like this:
|
||||
<doxygen:param>WARN_LOGFILE=AutoDoxywarnings.log # This may not be empty (usually not a good sign!), depending on options chosen.
|
||||
# Much better to send message to a logfile than the default stderr.
|
||||
# and make sure that there are no Doxygen errors or significant warnings in the log file.
|
||||
<doxygen:param>RECURSIVE=NO # Search recursively down .hpp and .cpp subdirectories.
|
||||
<doxygen:param>EXTRACT_ALL=NO
|
||||
<doxygen:param>EXTRACT_PRIVATE=NO # NO means do not extract info about private member functions and data.
|
||||
<doxygen:param>HIDE_UNDOC_MEMBERS=YES # Only show members that have some documentation like \param, \return ...
|
||||
<doxygen:param>MACRO_EXPANSION=YES # YES will expand all macro names in the source code (default = NO).
|
||||
<doxygen:param>EXPAND_ONLY_PREDEF=YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
|
||||
# then the macro expansion is limited to the macros specified with the PREDEFINED and EXPAND_AS_DEFINED tags.
|
||||
# If EXPAND_ONLY_PREDEF tag can be used to specify a list of macro names that should be expanded (as defined).
|
||||
# The PREDEFINED tag can be used to specify one or more macro names that are defined
|
||||
# before the preprocessor is started (similar to the -D option of gcc).
|
||||
# The argument of the tag is a list of macros of the form:
|
||||
# name or name=definition (no spaces).
|
||||
# If the definition and the "=" are omitted, "=1" is assumed.
|
||||
# To prevent a macro definition from being undefined via #undef or
|
||||
# recursively expanded use the := operator instead of the = operator.
|
||||
# See http://www.stack.nl/~dimitri/doxygen/config.html#cfg_predefined.
|
||||
# static char *malloc BOOST_PREVENT_MACRO_SUBSTITUTION(const size_type bytes);
|
||||
# will not produce a helpful Doxygen output, so
|
||||
# replace some with more helpful text, or none, for example:
|
||||
<doxygen:param>"PREDEFINED= \\
|
||||
\"BOOST_PREVENT_MACRO_SUBSTITUTION\" \\
|
||||
\"BOOST_STATIC_CONSTANT(T,V)=static x const y\" \\
|
||||
\"BOOST_UNITS_AUTO_STATIC_CONSTANT(a,b)=static const auto a = b\" \\
|
||||
\"BOOST_DEDUCED_TYPENAME=typename\" \\
|
||||
\"BOOST_CONSTEXPR=constexpr\" \\
|
||||
\"BOOST_CONTAINER_NOEXCEPT=noexcept\" \\
|
||||
\"BOOST_CONTAINER_NOEXCEPT_IF(T)=noexcept(T)\" \\
|
||||
\"BOOST_UNITS_TYPEOF(a)=typeof(a)\" \\
|
||||
\"BOOST_UNITS_HAS_TYPEOF=1\" \\
|
||||
\"BOOST_MPL_ASSERT(expr)=\" \\
|
||||
\"BOOST_ASSERT(expr)=\" \\
|
||||
\"BOOST_RV_REF(T)=T &&\" \\
|
||||
\"ASSERT(x)=assert(x)\" \\
|
||||
\"__cplusplus \""
|
||||
# BOOST_PREVENT_MACRO_SUBSTITUTION, will not be replaced by ,
|
||||
# BOOST_STATIC_CONSTANT will be replaced by "static x const y",
|
||||
# BOOST_DEDUCED_TYPENAME will be replaced by "typename",
|
||||
# BOOST_CONSTEXPR will be replaced by "constexpr".
|
||||
<doxygen:param>EXCLUDE_SYMBOLS=*_throws
|
||||
# <doxygen:param>IMAGE_PATH="../images" # for circular_buffer.png
|
||||
# See autodoxywarnings.log to check this is correct.
|
||||
|
||||
# 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 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...
|
||||
|
||||
# A grep for PREDEFINED= in jamfiles will reveal even more complex examples.
|
||||
# Boost Libraries with useful examples are: Accumulators, Interprocess, MPI, Random, Units, Expressive.
|
||||
|
||||
# Optionally, you can provide a Reference section name specific for your library, for example:
|
||||
<xsl:param>"boost.doxygen.reftitle=Boost.Circular_buffer C++ Reference"
|
||||
;
|
||||
|
||||
xml circular_buffer : circular_buffer.qbk ;
|
||||
|
||||
using boostbook ;
|
||||
|
||||
boostbook standalone
|
||||
:
|
||||
circular_buffer
|
||||
:
|
||||
|
||||
# General settings
|
||||
# =================
|
||||
<format>html:<xsl:param>boost.root=../../../..
|
||||
<format>html:<xsl:param>img.src.path=../../../../doc/html/
|
||||
<format>docbook:<xsl:param>boost.root=boost:
|
||||
|
||||
# Options for html and pdf
|
||||
# ========================
|
||||
# No indent on body text:
|
||||
<xsl:param>body.start.indent=0pt
|
||||
# Margin size:
|
||||
<xsl:param>page.margin.inner=0.5in
|
||||
# Margin size:
|
||||
<xsl:param>page.margin.outer=0.5in
|
||||
# Yes, we want graphics for admonishments:
|
||||
<xsl:param>admon.graphics=1
|
||||
|
||||
# HTML options:
|
||||
# =============
|
||||
# Use graphics icons not text for navigation:
|
||||
<xsl:param>navig.graphics=1
|
||||
# How far down we chunk nested sections, basically all of them:
|
||||
<xsl:param>chunk.section.depth=2
|
||||
# Don't put the first section on the same page as the TOC itself:
|
||||
<xsl:param>chunk.first.sections=1
|
||||
# How far down sections get TOC's
|
||||
<xsl:param>toc.section.depth=4
|
||||
# Max depth in each TOC:
|
||||
<xsl:param>toc.max.depth=2
|
||||
# How far down we go with TOC's
|
||||
<xsl:param>generate.section.toc.level=10
|
||||
# Horizontal ? spacing in table cells.
|
||||
<format>html:<xsl:param>html.cellspacing=3 # pixels
|
||||
# Vertical spacing in table cells.
|
||||
<format>html:<xsl:param>html.cellpadding=5 # pixels
|
||||
# Not sure if these are right way round?
|
||||
|
||||
<auto-index>on # Turns on index (or off).
|
||||
# Turns on (or off) index-verbose for diagnostic info (using /bin auto-index-verbose folders).
|
||||
<auto-index-verbose>on
|
||||
|
||||
<format>pdf:<auto-index-internal>off # on (or off) to use internally generated indexes.
|
||||
|
||||
<format>html:<xsl:param>index.on.type=1 # = 1 For the native stylesheets to generate multiple different indexes.
|
||||
|
||||
<auto-index-script>circular_buffer.idx # Specifies the name of the script to load for circular_buffer.
|
||||
<auto-index-prefix>../../.. # Will get you back up to /circular_buffer, so !scan-path "boost/circular_buffer/" is where *.hpp will be,
|
||||
# and /libs/circular_buffer for other files.
|
||||
# Without this would need !scan-path "../../../boost/circular_buffer"
|
||||
|
||||
# Used by Quickbook to invoke indexing.
|
||||
# Required by boost-trunk/doc/ see jamfile.v2 to use auto-index.
|
||||
# Choose indexing method for html:
|
||||
<format>html:<auto-index-internal>on
|
||||
<format>docbook:<auto-index-internal>on
|
||||
|
||||
# PDF Options:
|
||||
# ============
|
||||
# TOC Generation: this is needed for FOP-0.9 and later:
|
||||
<format>pdf:<xsl:param>fop1.extensions=0
|
||||
# Or enable this if you're using XEP:
|
||||
<format>pdf:<xsl:param>xep.extensions=1
|
||||
# TOC generation: this is needed for FOP 0.2, but must not be set to zero for FOP-0.9!
|
||||
<format>pdf:<xsl:param>fop.extensions=0
|
||||
# No indent on body text:
|
||||
<xsl:param>body.start.indent=0pt
|
||||
# Margin size:
|
||||
<xsl:param>page.margin.inner=0.5in
|
||||
# Margin size:
|
||||
<xsl:param>page.margin.outer=0.5in
|
||||
|
||||
# Yes, we want graphics for admonishments:
|
||||
<xsl:param>admon.graphics=1
|
||||
|
||||
# Set these one for PDF generation *only*:
|
||||
# default png graphics are awful in PDF form,
|
||||
# better use SVG instead:
|
||||
<format>pdf:<xsl:param>admon.graphics.extension=".svg"
|
||||
#<format>pdf:<xsl:param>admon.graphics.extension=".png" # Only png images are available.
|
||||
# Don't need this, default path works OK:
|
||||
#<format>pdf:<xsl:param>admon.graphics.path=$(nav_images)/ # next, prev, note, tip ... for pdf.
|
||||
<format>pdf:<xsl:param>use.role.for.mediaobject=1
|
||||
<format>pdf:<xsl:param>preferred.mediaobject.role=print
|
||||
<format>pdf:<xsl:param>img.src.path=$(pdf_images_location)/ # graphics (diagrams) for pdf.
|
||||
<format>pdf:<xsl:param>draft.mode="no"
|
||||
<format>pdf:<xsl:param>boost.url.prefix=../../../..
|
||||
|
||||
<dependency>autodoc #
|
||||
<dependency>png_install
|
||||
;
|
||||
|
||||
# Install (copy) the 'master' copies of all icon images (both PNG and SVG)
|
||||
# and the Boost logo from your current Boost-root
|
||||
# to the local /doc/html/images folder so that html is complete and standalone.
|
||||
install png_install : [ glob $(here)/*.png ] : <location>$(here)/../../../doc/html/images ;
|
||||
|
||||
# install pdf-install : standalone : <install-type>PDF <location>. ;
|
||||
# Effectively copies the file from \bin folder to the \doc folder,
|
||||
# but will not work as expected if doxygen and/or autoindex is used
|
||||
# because a modified pdf file is created, so this command
|
||||
# will rename the file to the expected filename, here circular_buffer.pdf.
|
||||
|
||||
install pdfinstall : standalone : <install-type>PDF <location>. <name>circular_buffer.pdf ;
|
||||
|
||||
###############################################################################
|
||||
alias boostdoc
|
||||
: standalone/<format>docbook
|
||||
:
|
||||
:
|
||||
: ;
|
||||
explicit boostdoc ;
|
||||
alias boostrelease ;
|
||||
explicit boostrelease ;
|
||||
4232
doc/space_optimized.html
Normal file
4232
doc/space_optimized.html
Normal file
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
106
doc/space_optimized.xslt
Normal file
106
doc/space_optimized.xslt
Normal file
@@ -0,0 +1,106 @@
|
||||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<!--
|
||||
XSL transformation from the XML files generated by Doxygen into XHTML source
|
||||
code documentation of the circular_buffer_space_optimized.
|
||||
|
||||
Copyright (c) 2003-2008 Jan Gaspar
|
||||
|
||||
Use, modification, and distribution is subject to the Boost Software
|
||||
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
-->
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
<xsl:import href="doxygen2html.xslt"/>
|
||||
|
||||
<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes" media-type="text/xml"/>
|
||||
|
||||
<xsl:variable name="link-prefix" select="'circular_buffer.html'"/>
|
||||
<xsl:variable name="circular_buffer-ref" select="//compound[name='boost::circular_buffer' and @kind='class']/@refid"/>
|
||||
<xsl:variable name="circular_buffer-file" select="concat($xmldir, '/', $circular_buffer-ref, '.xml')"/>
|
||||
<xsl:variable name="circular_buffer-reimplemented" select="document($circular_buffer-file)/doxygen/compounddef[@id = $circular_buffer-ref and @kind = 'class']//reimplementedby"/>
|
||||
<xsl:variable name="standalone-functions" select="document(concat($xmldir, '/namespaceboost.xml'))/doxygen/compounddef/sectiondef[@kind='func']"/>
|
||||
|
||||
<xsl:template name="reference">
|
||||
<xsl:variable name="refid" select="$circular_buffer-reimplemented[@refid=current()/@refid and text()!='capacity_type']/../@id"/>
|
||||
<xsl:value-of select="concat(substring(concat($link-prefix, '#', $refid), 1 div (string-length($refid) > 0)), substring(concat('#', @refid), 1 div (string-length($refid) = 0)))"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="template-parameters">
|
||||
<xsl:apply-templates select="templateparamlist/param" mode="synopsis">
|
||||
<xsl:with-param name="link-prefix" select="$link-prefix"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="public-types">
|
||||
<xsl:for-each select="sectiondef[@kind='public-type']/memberdef">
|
||||
<xsl:if test="string-length(normalize-space(briefdescription)) > 0">
|
||||
<xsl:choose>
|
||||
<xsl:when test="document($circular_buffer-file)/doxygen/compounddef[@id = $circular_buffer-ref and @kind = 'class']/sectiondef[@kind='public-type']/memberdef[name=current()/name]/briefdescription = briefdescription">
|
||||
<xsl:apply-templates select="document($circular_buffer-file)/doxygen/compounddef[@id = $circular_buffer-ref and @kind = 'class']/sectiondef[@kind='public-type']/memberdef[name=current()/name]" mode="synopsis">
|
||||
<xsl:with-param name="link-prefix" select="$link-prefix"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:apply-templates select="." mode="synopsis"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="constructors">
|
||||
<xsl:for-each select="sectiondef[@kind='public-func']/memberdef[type = '']">
|
||||
<xsl:variable name="briefdescription" select="normalize-space(briefdescription)"/>
|
||||
<xsl:if test="string-length($briefdescription) > 0">
|
||||
<xsl:apply-templates select="." mode="synopsis"/>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="member-functions">
|
||||
<xsl:variable name="current" select="sectiondef[@kind='public-func']/memberdef[type != '']"/>
|
||||
<xsl:for-each select="document($circular_buffer-file)/doxygen/compounddef[@id = $circular_buffer-ref and @kind = 'class']/sectiondef[@kind='public-func']/memberdef[type != '']">
|
||||
<xsl:if test="count($current[name=current()/name and string-length(normalize-space(briefdescription)) > 0]) = 0">
|
||||
<xsl:apply-templates select="." mode="synopsis">
|
||||
<xsl:with-param name="link-prefix" select="$link-prefix"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
<xsl:for-each select="$current[string-length(normalize-space(briefdescription)) > 0 and normalize-space(briefdescription) != 'no-comment']">
|
||||
<xsl:apply-templates select="." mode="synopsis"/>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="standalone-functions">
|
||||
<xsl:for-each select="$standalone-functions/memberdef[contains(argsstring, 'circular_buffer_space_optimized<')]">
|
||||
<xsl:apply-templates select="." mode="synopsis">
|
||||
<xsl:with-param name="indent" select="''"/>
|
||||
<xsl:with-param name="link-prefix" select="$link-prefix"/>
|
||||
<xsl:with-param name="link" select="$standalone-functions/memberdef[contains(argsstring, 'circular_buffer<') and name=current()/name]/@id"/>
|
||||
</xsl:apply-templates>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="template-parameters-details"/>
|
||||
|
||||
<xsl:template name="public-types-details">
|
||||
<xsl:apply-templates select="sectiondef[@kind='public-type']/memberdef[not(contains(type, 'circular_buffer<'))]" mode="description"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="constructors-details">
|
||||
<xsl:for-each select="sectiondef[@kind='public-func']/memberdef[type = '' and string-length(normalize-space(briefdescription)) > 0]">
|
||||
<xsl:apply-templates select="." mode="description"/>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="member-functions-details">
|
||||
<xsl:for-each select="sectiondef[@kind='public-func']/memberdef[type != '' and string-length(normalize-space(briefdescription)) > 0 and normalize-space(briefdescription) != 'no-comment']">
|
||||
<xsl:apply-templates select="." mode="description"/>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="standalone-functions-details"/>
|
||||
|
||||
</xsl:stylesheet>
|
||||
54
doc/update_srcdoc.sh
Normal file
54
doc/update_srcdoc.sh
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/bin/sh
|
||||
################################################################################
|
||||
# Shell script which updates the Circular Buffer library documentation with #
|
||||
# the latest source code documentation (which is in the source files). #
|
||||
# #
|
||||
# Copyright (c) 2003-2008 Jan Gaspar #
|
||||
# #
|
||||
# Use, modification, and distribution is subject to the Boost Software #
|
||||
# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at #
|
||||
# http://www.boost.org/LICENSE_1_0.txt) #
|
||||
################################################################################
|
||||
|
||||
CONTAINER=$1
|
||||
DOCFILE="$CONTAINER.html"
|
||||
XSLT="$CONTAINER.xslt"
|
||||
XHTML="$CONTAINER.xhtml"
|
||||
SPECIALIZATION=${CONTAINER#circular_buffer_}
|
||||
|
||||
if [ ${#SPECIALIZATION} -gt 0 ]; then
|
||||
DOCFILE=${DOCFILE#circular_buffer_}
|
||||
XSLT=${XSLT#circular_buffer_}
|
||||
XHTML=${XHTML#circular_buffer_}
|
||||
fi
|
||||
|
||||
if [ -f $DOCFILE ]; then
|
||||
|
||||
echo Starting Doxygen ...
|
||||
doxygen
|
||||
|
||||
echo Converting Doxygen generated source code documentation into XHTML ...
|
||||
xsltproc --stringparam container $CONTAINER --stringparam xmldir srcdoc -o srcdoc/srcdoc.xhtml $XSLT srcdoc/index.xml
|
||||
|
||||
echo Preprocessing $DOCFILE ...
|
||||
sed 's/<a\s*id="[^"]*"/<a /g' $DOCFILE | sed 's/<a\s*\(name="[^"]*"\)\s*\(id="[^"]*"\)/<a \1/g' > srcdoc/$DOCFILE
|
||||
|
||||
echo Converting preprocessed $DOCFILE into XHTML ...
|
||||
xsltproc --html -o srcdoc/$XHTML html2xhtml.xslt srcdoc/$DOCFILE
|
||||
|
||||
echo Generating $DOCFILE with updated source code documentation ...
|
||||
xsltproc --stringparam srcdoc srcdoc/srcdoc.xhtml -o $DOCFILE update_srcdoc.xslt srcdoc/$XHTML
|
||||
|
||||
echo Correcting and pretty-printing $DOCFILE with HTML Tidy ...
|
||||
tidy -ashtml -config Tidy.conf $DOCFILE
|
||||
|
||||
echo Removing temporary directory ...
|
||||
rm -rf srcdoc
|
||||
|
||||
echo Done.
|
||||
|
||||
else
|
||||
|
||||
echo Usage: update_srcdoc.sh container
|
||||
|
||||
fi
|
||||
25
doc/update_srcdoc.xslt
Normal file
25
doc/update_srcdoc.xslt
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version='1.0' encoding='iso-8859-1'?>
|
||||
<!--
|
||||
Helper XSL transformation updating source code documentation sections
|
||||
in the specified HTML file.
|
||||
|
||||
Copyright (c) 2003-2008 Jan Gaspar
|
||||
|
||||
Use, modification, and distribution is subject to the Boost Software
|
||||
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
-->
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
<xsl:import href="copy.xslt"/>
|
||||
|
||||
<xsl:output method="html" version="1.0" encoding="iso-8859-1" indent="yes" omit-xml-declaration="yes" media-type="text/html"/>
|
||||
|
||||
<xsl:param name="srcdoc"/>
|
||||
|
||||
<xsl:template match="div[contains(@id, 'srcdoc')]">
|
||||
<xsl:copy-of select="document($srcdoc)//body/div[@id=current()/@id]"/>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -1,316 +0,0 @@
|
||||
// Comparison of bounded buffers based on different containers.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
// Copyright 2013 Paul A. Bristow. Added some Quickbook snippet markers.
|
||||
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#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/bind.hpp>
|
||||
#include <deque>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
const unsigned long QUEUE_SIZE = 1000L;
|
||||
const unsigned long TOTAL_ELEMENTS = QUEUE_SIZE * 1000L;
|
||||
|
||||
template <class T>
|
||||
class bounded_buffer {
|
||||
public:
|
||||
|
||||
typedef boost::circular_buffer<T> container_type;
|
||||
typedef typename container_type::size_type size_type;
|
||||
typedef typename container_type::value_type value_type;
|
||||
typedef typename boost::call_traits<value_type>::param_type param_type;
|
||||
|
||||
explicit bounded_buffer(size_type capacity) : m_unread(0), m_container(capacity) {}
|
||||
|
||||
void push_front(param_type item) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
++m_unread;
|
||||
lock.unlock();
|
||||
m_not_empty.notify_one();
|
||||
}
|
||||
|
||||
void pop_back(value_type* pItem) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_empty.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_empty, this));
|
||||
*pItem = m_container[--m_unread];
|
||||
lock.unlock();
|
||||
m_not_full.notify_one();
|
||||
}
|
||||
|
||||
private:
|
||||
bounded_buffer(const bounded_buffer&); // Disabled copy constructor
|
||||
bounded_buffer& operator = (const bounded_buffer&); // Disabled assign operator
|
||||
|
||||
bool is_not_empty() const { return m_unread > 0; }
|
||||
bool is_not_full() const { return m_unread < m_container.capacity(); }
|
||||
|
||||
size_type m_unread;
|
||||
container_type m_container;
|
||||
boost::mutex m_mutex;
|
||||
boost::condition m_not_empty;
|
||||
boost::condition m_not_full;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class bounded_buffer_space_optimized {
|
||||
public:
|
||||
|
||||
typedef boost::circular_buffer_space_optimized<T> container_type;
|
||||
typedef typename container_type::size_type size_type;
|
||||
typedef typename container_type::value_type value_type;
|
||||
typedef typename boost::call_traits<value_type>::param_type param_type;
|
||||
|
||||
explicit bounded_buffer_space_optimized(size_type capacity) : m_container(capacity) {}
|
||||
|
||||
void push_front(param_type item) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer_space_optimized<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
lock.unlock();
|
||||
m_not_empty.notify_one();
|
||||
}
|
||||
|
||||
void pop_back(value_type* pItem) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_empty.wait(lock, boost::bind(&bounded_buffer_space_optimized<value_type>::is_not_empty, this));
|
||||
*pItem = m_container.back();
|
||||
m_container.pop_back();
|
||||
lock.unlock();
|
||||
m_not_full.notify_one();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bounded_buffer_space_optimized(const bounded_buffer_space_optimized&); // Disabled copy constructor
|
||||
bounded_buffer_space_optimized& operator = (const bounded_buffer_space_optimized&); // Disabled assign operator
|
||||
|
||||
bool is_not_empty() const { return m_container.size() > 0; }
|
||||
bool is_not_full() const { return m_container.size() < m_container.capacity(); }
|
||||
|
||||
container_type m_container;
|
||||
boost::mutex m_mutex;
|
||||
boost::condition m_not_empty;
|
||||
boost::condition m_not_full;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class bounded_buffer_deque_based {
|
||||
public:
|
||||
|
||||
typedef std::deque<T> container_type;
|
||||
typedef typename container_type::size_type size_type;
|
||||
typedef typename container_type::value_type value_type;
|
||||
typedef typename boost::call_traits<value_type>::param_type param_type;
|
||||
|
||||
explicit bounded_buffer_deque_based(size_type capacity) : m_capacity(capacity) {}
|
||||
|
||||
void push_front(param_type item) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer_deque_based<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
lock.unlock();
|
||||
m_not_empty.notify_one();
|
||||
}
|
||||
|
||||
void pop_back(value_type* pItem) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_empty.wait(lock, boost::bind(&bounded_buffer_deque_based<value_type>::is_not_empty, this));
|
||||
*pItem = m_container.back();
|
||||
m_container.pop_back();
|
||||
lock.unlock();
|
||||
m_not_full.notify_one();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bounded_buffer_deque_based(const bounded_buffer_deque_based&); // Disabled copy constructor
|
||||
bounded_buffer_deque_based& operator = (const bounded_buffer_deque_based&); // Disabled assign operator
|
||||
|
||||
bool is_not_empty() const { return m_container.size() > 0; }
|
||||
bool is_not_full() const { return m_container.size() < m_capacity; }
|
||||
|
||||
const size_type m_capacity;
|
||||
container_type m_container;
|
||||
boost::mutex m_mutex;
|
||||
boost::condition m_not_empty;
|
||||
boost::condition m_not_full;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class bounded_buffer_list_based {
|
||||
public:
|
||||
|
||||
typedef std::list<T> container_type;
|
||||
typedef typename container_type::size_type size_type;
|
||||
typedef typename container_type::value_type value_type;
|
||||
typedef typename boost::call_traits<value_type>::param_type param_type;
|
||||
|
||||
explicit bounded_buffer_list_based(size_type capacity) : m_capacity(capacity) {}
|
||||
|
||||
void push_front(param_type item) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer_list_based<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
lock.unlock();
|
||||
m_not_empty.notify_one();
|
||||
}
|
||||
|
||||
void pop_back(value_type* pItem) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_empty.wait(lock, boost::bind(&bounded_buffer_list_based<value_type>::is_not_empty, this));
|
||||
*pItem = m_container.back();
|
||||
m_container.pop_back();
|
||||
lock.unlock();
|
||||
m_not_full.notify_one();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
bounded_buffer_list_based(const bounded_buffer_list_based&); // Disabled copy constructor
|
||||
bounded_buffer_list_based& operator = (const bounded_buffer_list_based&); // Disabled assign operator
|
||||
|
||||
bool is_not_empty() const { return m_container.size() > 0; }
|
||||
bool is_not_full() const { return m_container.size() < m_capacity; }
|
||||
|
||||
const size_type m_capacity;
|
||||
container_type m_container;
|
||||
boost::mutex m_mutex;
|
||||
boost::condition m_not_empty;
|
||||
boost::condition m_not_full;
|
||||
};
|
||||
|
||||
template<class Buffer>
|
||||
class Consumer {
|
||||
|
||||
typedef typename Buffer::value_type value_type;
|
||||
Buffer* m_container;
|
||||
value_type m_item;
|
||||
|
||||
public:
|
||||
Consumer(Buffer* buffer) : m_container(buffer) {}
|
||||
|
||||
void operator()() {
|
||||
for (unsigned long i = 0L; i < TOTAL_ELEMENTS; ++i) {
|
||||
m_container->pop_back(&m_item);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class Buffer>
|
||||
class Producer {
|
||||
|
||||
typedef typename Buffer::value_type value_type;
|
||||
Buffer* m_container;
|
||||
|
||||
public:
|
||||
Producer(Buffer* buffer) : m_container(buffer) {}
|
||||
|
||||
void operator()() {
|
||||
for (unsigned long i = 0L; i < TOTAL_ELEMENTS; ++i) {
|
||||
m_container->push_front(value_type());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class Buffer>
|
||||
void fifo_test(Buffer* buffer) {
|
||||
|
||||
// Start of measurement
|
||||
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))
|
||||
buffer->push_front(Buffer::value_type());
|
||||
#else
|
||||
buffer->push_front(BOOST_DEDUCED_TYPENAME Buffer::value_type());
|
||||
#endif
|
||||
}
|
||||
|
||||
Consumer<Buffer> consumer(buffer);
|
||||
Producer<Buffer> producer(buffer);
|
||||
|
||||
// Start the threads.
|
||||
boost::thread consume(consumer);
|
||||
boost::thread produce(producer);
|
||||
|
||||
// Wait for completion.
|
||||
consume.join();
|
||||
produce.join();
|
||||
|
||||
// End of measurement
|
||||
}
|
||||
|
||||
int main(int /*argc*/, char* /*argv*/[]) {
|
||||
|
||||
bounded_buffer<int> bb_int(QUEUE_SIZE);
|
||||
std::cout << "bounded_buffer<int> ";
|
||||
fifo_test(&bb_int);
|
||||
|
||||
bounded_buffer_space_optimized<int> bb_space_optimized_int(QUEUE_SIZE);
|
||||
std::cout << "bounded_buffer_space_optimized<int> ";
|
||||
fifo_test(&bb_space_optimized_int);
|
||||
|
||||
bounded_buffer_deque_based<int> bb_deque_based_int(QUEUE_SIZE);
|
||||
std::cout << "bounded_buffer_deque_based<int> ";
|
||||
fifo_test(&bb_deque_based_int);
|
||||
|
||||
bounded_buffer_list_based<int> bb_list_based_int(QUEUE_SIZE);
|
||||
std::cout << "bounded_buffer_list_based<int> ";
|
||||
fifo_test(&bb_list_based_int);
|
||||
|
||||
bounded_buffer<std::string> bb_string(QUEUE_SIZE);
|
||||
std::cout << "bounded_buffer<std::string> ";
|
||||
fifo_test(&bb_string);
|
||||
|
||||
bounded_buffer_space_optimized<std::string> bb_space_optimized_string(QUEUE_SIZE);
|
||||
std::cout << "bounded_buffer_space_optimized<std::string> ";
|
||||
fifo_test(&bb_space_optimized_string);
|
||||
|
||||
bounded_buffer_deque_based<std::string> bb_deque_based_string(QUEUE_SIZE);
|
||||
std::cout << "bounded_buffer_deque_based<std::string> ";
|
||||
fifo_test(&bb_deque_based_string);
|
||||
|
||||
bounded_buffer_list_based<std::string> bb_list_based_string(QUEUE_SIZE);
|
||||
std::cout << "bounded_buffer_list_based<std::string> ";
|
||||
fifo_test(&bb_list_based_string);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
|
||||
//[bounded_buffer_comparison_output
|
||||
|
||||
Description: Autorun "J:\Cpp\Misc\Debug\bounded_buffer_comparison.exe"
|
||||
bounded_buffer<int> 5.15 s
|
||||
|
||||
bounded_buffer_space_optimized<int> 5.71 s
|
||||
|
||||
bounded_buffer_deque_based<int> 15.57 s
|
||||
|
||||
bounded_buffer_list_based<int> 17.33 s
|
||||
|
||||
bounded_buffer<std::string> 24.49 s
|
||||
|
||||
bounded_buffer_space_optimized<std::string> 28.33 s
|
||||
|
||||
bounded_buffer_deque_based<std::string> 29.45 s
|
||||
|
||||
bounded_buffer_list_based<std::string> 31.29 s
|
||||
|
||||
//] //[bounded_buffer_comparison_output]
|
||||
|
||||
*/
|
||||
@@ -1,192 +0,0 @@
|
||||
// Copyright 2003-2008 Jan Gaspar.
|
||||
// Copyright 2013 Paul A. Bristow. Added some Quickbook snippet markers.
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See the accompanying file LICENSE_1_0.txt
|
||||
// or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
|
||||
|
||||
//[circular_buffer_bound_example_1
|
||||
/*`
|
||||
This example shows how the `circular_buffer` can be utilized
|
||||
as an underlying container of the bounded buffer.
|
||||
*/
|
||||
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/condition.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/call_traits.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include <boost/timer/timer.hpp> // for auto_cpu_timer
|
||||
#include <iostream>
|
||||
|
||||
template <class T>
|
||||
class bounded_buffer
|
||||
{
|
||||
public:
|
||||
|
||||
typedef boost::circular_buffer<T> container_type;
|
||||
typedef typename container_type::size_type size_type;
|
||||
typedef typename container_type::value_type value_type;
|
||||
typedef typename boost::call_traits<value_type>::param_type param_type;
|
||||
|
||||
explicit bounded_buffer(size_type capacity) : m_unread(0), m_container(capacity) {}
|
||||
|
||||
void push_front(typename boost::call_traits<value_type>::param_type item)
|
||||
{ // `param_type` represents the "best" way to pass a parameter of type `value_type` to a method.
|
||||
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
++m_unread;
|
||||
lock.unlock();
|
||||
m_not_empty.notify_one();
|
||||
}
|
||||
|
||||
void pop_back(value_type* pItem) {
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_empty.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_empty, this));
|
||||
*pItem = m_container[--m_unread];
|
||||
lock.unlock();
|
||||
m_not_full.notify_one();
|
||||
}
|
||||
|
||||
private:
|
||||
bounded_buffer(const bounded_buffer&); // Disabled copy constructor.
|
||||
bounded_buffer& operator = (const bounded_buffer&); // Disabled assign operator.
|
||||
|
||||
bool is_not_empty() const { return m_unread > 0; }
|
||||
bool is_not_full() const { return m_unread < m_container.capacity(); }
|
||||
|
||||
size_type m_unread;
|
||||
container_type m_container;
|
||||
boost::mutex m_mutex;
|
||||
boost::condition m_not_empty;
|
||||
boost::condition m_not_full;
|
||||
}; //
|
||||
|
||||
//] [/circular_buffer_bound_example_1]
|
||||
|
||||
const unsigned long queue_size = 1000L;
|
||||
const unsigned long total_elements = queue_size * 1000L;
|
||||
|
||||
//[circular_buffer_bound_example_2]
|
||||
/*`To demonstrate, create two classes to exercise the buffer.
|
||||
|
||||
The producer class fills the buffer with elements.
|
||||
|
||||
The consumer class consumes the buffer contents.
|
||||
|
||||
*/
|
||||
|
||||
template<class Buffer>
|
||||
class Producer
|
||||
{
|
||||
|
||||
typedef typename Buffer::value_type value_type;
|
||||
Buffer* m_container;
|
||||
|
||||
public:
|
||||
Producer(Buffer* buffer) : m_container(buffer)
|
||||
{}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
for (unsigned long i = 0L; i < total_elements; ++i)
|
||||
{
|
||||
m_container->push_front(value_type());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class Buffer>
|
||||
class Consumer
|
||||
{
|
||||
|
||||
typedef typename Buffer::value_type value_type;
|
||||
Buffer* m_container;
|
||||
value_type m_item;
|
||||
|
||||
public:
|
||||
Consumer(Buffer* buffer) : m_container(buffer)
|
||||
{}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
for (unsigned long i = 0L; i < total_elements; ++i)
|
||||
{
|
||||
m_container->pop_back(&m_item);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*`Create a first-int first-out test of the bound_buffer.
|
||||
Include a call to boost::progress_timer
|
||||
|
||||
[@http://www.boost.org/doc/libs/1_53_0/libs/timer/doc/cpu_timers.html CPU timer]
|
||||
|
||||
*/
|
||||
template<class Buffer>
|
||||
void fifo_test(Buffer* buffer)
|
||||
{
|
||||
// Start of timing.
|
||||
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))
|
||||
buffer->push_front(Buffer::value_type());
|
||||
#else
|
||||
buffer->push_front(BOOST_DEDUCED_TYPENAME Buffer::value_type());
|
||||
#endif
|
||||
}
|
||||
|
||||
// Construct the threads.
|
||||
Consumer<Buffer> consumer(buffer);
|
||||
Producer<Buffer> producer(buffer);
|
||||
|
||||
// Start the threads.
|
||||
boost::thread consume(consumer);
|
||||
boost::thread produce(producer);
|
||||
|
||||
// Wait for completion.
|
||||
consume.join();
|
||||
produce.join();
|
||||
|
||||
// End of timing.
|
||||
// destructor of boost::timer::auto_cpu_timer will output the time to std::cout.
|
||||
|
||||
}
|
||||
//] [/circular_buffer_bound_example_2]
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
//[circular_buffer_bound_example_3]
|
||||
//`Construct a bounded_buffer to hold the chosen type, here int.
|
||||
bounded_buffer<int> bb_int(queue_size);
|
||||
std::cout << "Testing bounded_buffer<int> ";
|
||||
|
||||
//`Start the fifo test.
|
||||
fifo_test(&bb_int);
|
||||
//` destructor of boost::timer::auto_cpu_timer will output the time to std::cout
|
||||
|
||||
//] [/circular_buffer_bound_example_3]
|
||||
|
||||
return 0;
|
||||
} // int main()
|
||||
|
||||
/*
|
||||
|
||||
//[circular_buffer_bound_output
|
||||
|
||||
Description: Autorun "J:\Cpp\Misc\Debug\circular_buffer_bound_example.exe"
|
||||
|
||||
Testing bounded_buffer<int> 15.010692s wall, 9.188459s user + 7.207246s system = 16.395705s CPU (109.2%)
|
||||
|
||||
//] [/circular_buffer_bound_output]
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
// Copyright 2003-2008 Jan Gaspar.
|
||||
// Copyright 2013 Paul A. Bristow. Added some Quickbook snippet markers.
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See the accompanying file LICENSE_1_0.txt
|
||||
// or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
|
||||
|
||||
//[circular_buffer_example_1
|
||||
/*`For all examples, we need this include:
|
||||
*/
|
||||
|
||||
#include <boost/circular_buffer.hpp>
|
||||
|
||||
//] [/circular_buffer_example_1]
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
//[circular_buffer_example_2
|
||||
// Create a circular buffer with a capacity for 3 integers.
|
||||
boost::circular_buffer<int> cb(3);
|
||||
|
||||
// Insert three elements into the buffer.
|
||||
cb.push_back(1);
|
||||
cb.push_back(2);
|
||||
cb.push_back(3);
|
||||
|
||||
int a = cb[0]; // a == 1
|
||||
int b = cb[1]; // b == 2
|
||||
int c = cb[2]; // c == 3
|
||||
|
||||
// The buffer is full now, so pushing subsequent
|
||||
// elements will overwrite the front-most elements.
|
||||
|
||||
cb.push_back(4); // Overwrite 1 with 4.
|
||||
cb.push_back(5); // Overwrite 2 with 5.
|
||||
|
||||
// The buffer now contains 3, 4 and 5.
|
||||
a = cb[0]; // a == 3
|
||||
b = cb[1]; // b == 4
|
||||
c = cb[2]; // c == 5
|
||||
|
||||
// Elements can be popped from either the front or the back.
|
||||
cb.pop_back(); // 5 is removed.
|
||||
cb.pop_front(); // 3 is removed.
|
||||
|
||||
// Leaving only one element with value = 4.
|
||||
int d = cb[0]; // d == 4
|
||||
|
||||
//] [/circular_buffer_example_2]
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
//[circular_buffer_example_output
|
||||
|
||||
There is no output from this example.
|
||||
|
||||
//] [/circular_buffer_example_output]
|
||||
|
||||
*/
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
echo off
|
||||
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
|
||||
set tim=%t:~0,2%%t:~3,2%
|
||||
rem pick just hours and minutes.
|
||||
rem time may include leading space, like " 915", so remove space.
|
||||
set tim=%tim: =%
|
||||
rem boost-no-inspect
|
||||
rem cd \boost-trunk/circular_buffer\libs\circular_buffer\example
|
||||
bjam -a > circular_buffer_examples_%date%_%tim%.log
|
||||
if not ERRORLEVEL 0 (echo Errorlevel is %ERRORLEVEL%) else (echo OK)
|
||||
pause
|
||||
@@ -1,40 +0,0 @@
|
||||
// Copyright 2003-2008 Jan Gaspar.
|
||||
// Copyright 2013 Paul A. Bristow. Added some Quickbook snippet markers.
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See the accompanying file LICENSE_1_0.txt
|
||||
// or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
|
||||
|
||||
#undef BOOST_CB_ENABLE_DEBUG
|
||||
|
||||
//[circular_buffer_iter_example_1
|
||||
/*`
|
||||
*/
|
||||
|
||||
#define BOOST_CB_ENABLE_DEBUG 0 // The Debug Support has to be disabled, otherwise the code produces a runtime error.
|
||||
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <assert.h>
|
||||
|
||||
int main(int /*argc*/, char* /*argv*/[])
|
||||
{
|
||||
|
||||
boost::circular_buffer<int> cb(3);
|
||||
|
||||
cb.push_back(1);
|
||||
cb.push_back(2);
|
||||
cb.push_back(3);
|
||||
|
||||
boost::circular_buffer<int>::iterator it = cb.begin();
|
||||
|
||||
assert(*it == 1);
|
||||
|
||||
cb.push_back(4);
|
||||
|
||||
assert(*it == 4); // The iterator still points to the initialized memory.
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//] [/circular_buffer_iter_example_1]
|
||||
@@ -1,64 +0,0 @@
|
||||
// Copyright 2003-2008 Jan Gaspar.
|
||||
// Copyright 2013 Paul A. Bristow. Added some Quickbook snippet markers.
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See the accompanying file LICENSE_1_0.txt
|
||||
// or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
|
||||
|
||||
//[circular_buffer_sum_example_1
|
||||
|
||||
/*`This example shows several functions, including summing all valid values.
|
||||
*/
|
||||
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#include <numeric>
|
||||
#include <assert.h>
|
||||
|
||||
int main(int /*argc*/, char* /*argv*/[])
|
||||
{
|
||||
// Create a circular buffer of capacity 3.
|
||||
boost::circular_buffer<int> cb(3);
|
||||
assert(cb.capacity() == 3);
|
||||
// Check is empty.
|
||||
assert(cb.size() == 0);
|
||||
assert(cb.empty());
|
||||
|
||||
// Insert some elements into the circular buffer.
|
||||
cb.push_back(1);
|
||||
cb.push_back(2);
|
||||
|
||||
// Assertions to check push_backs have expected effect.
|
||||
assert(cb[0] == 1);
|
||||
assert(cb[1] == 2);
|
||||
assert(!cb.full());
|
||||
assert(cb.size() == 2);
|
||||
assert(cb.capacity() == 3);
|
||||
|
||||
// Insert some other elements.
|
||||
cb.push_back(3);
|
||||
cb.push_back(4);
|
||||
|
||||
// Evaluate the sum of all elements.
|
||||
int sum = std::accumulate(cb.begin(), cb.end(), 0);
|
||||
|
||||
// Assertions to check state.
|
||||
assert(sum == 9);
|
||||
assert(cb[0] == 2);
|
||||
assert(cb[1] == 3);
|
||||
assert(cb[2] == 4);
|
||||
assert(*cb.begin() == 2);
|
||||
assert(cb.front() == 2);
|
||||
assert(cb.back() == 4);
|
||||
assert(cb.full());
|
||||
assert(cb.size() == 3);
|
||||
assert(cb.capacity() == 3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//] [/circular_buffer_sum_example_1]
|
||||
|
||||
|
||||
/*
|
||||
There is no output from this example.
|
||||
*/
|
||||
@@ -1,42 +0,0 @@
|
||||
# Copyright Paul A. Bristow 2013
|
||||
|
||||
# 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)
|
||||
|
||||
# jamfile.v2 to run all circular_buffer examples.
|
||||
|
||||
# bring in the rules for testing.
|
||||
import testing ;
|
||||
|
||||
project
|
||||
: requirements
|
||||
<library>/boost/system//boost_system
|
||||
<library>/boost/thread//boost_thread
|
||||
#<define>BOOST_ALL_NO_LIB=1
|
||||
<threading>multi
|
||||
|
||||
<toolset>gcc:<cxxflags>-Wno-missing-braces
|
||||
<toolset>darwin:<cxxflags>-Wno-missing-braces
|
||||
<toolset>acc:<cxxflags>+W2068,2461,2236,4070
|
||||
<toolset>intel:<cxxflags>-Qwd264,239
|
||||
<toolset>msvc:<warnings>all
|
||||
<toolset>msvc:<asynch-exceptions>on
|
||||
<toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
|
||||
<toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
|
||||
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
|
||||
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
|
||||
<toolset>msvc:<cxxflags>/wd4996
|
||||
<toolset>msvc:<cxxflags>/wd4512
|
||||
<toolset>msvc:<cxxflags>/wd4610
|
||||
<toolset>msvc:<cxxflags>/wd4510
|
||||
<toolset>msvc:<cxxflags>/wd4127
|
||||
<toolset>msvc:<cxxflags>/wd4701
|
||||
<toolset>msvc:<cxxflags>/wd4127
|
||||
<toolset>msvc:<cxxflags>/wd4305
|
||||
;
|
||||
|
||||
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,27 +8,24 @@
|
||||
|
||||
// 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
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1200
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/circular_buffer_fwd.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
/*! Debug support control. */
|
||||
#if !defined(BOOST_CB_ENABLE_DEBUG)
|
||||
// BOOST_CB_ENABLE_DEBUG: Debug support control.
|
||||
#if defined(NDEBUG) || defined(BOOST_CB_DISABLE_DEBUG)
|
||||
#define BOOST_CB_ENABLE_DEBUG 0
|
||||
#else
|
||||
#define BOOST_CB_ENABLE_DEBUG 1
|
||||
#endif
|
||||
|
||||
/*! INTERNAL ONLY */
|
||||
// BOOST_CB_ASSERT: Runtime assertion.
|
||||
#if BOOST_CB_ENABLE_DEBUG
|
||||
#include <boost/assert.hpp>
|
||||
#define BOOST_CB_ASSERT(Expr) BOOST_ASSERT(Expr)
|
||||
@@ -36,19 +33,29 @@ Includes <boost/circular_buffer/base.hpp>
|
||||
#define BOOST_CB_ASSERT(Expr) ((void)0)
|
||||
#endif
|
||||
|
||||
/*! INTERNAL ONLY */
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x0550) || BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||
#define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) ((void)0)
|
||||
// BOOST_CB_STATIC_ASSERT: Compile time assertion.
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
#define BOOST_CB_STATIC_ASSERT(Expr) ((void)0)
|
||||
#else
|
||||
#include <iterator>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) \
|
||||
BOOST_STATIC_ASSERT((is_convertible<typename std::iterator_traits<Iterator>::value_type, Type>::value))
|
||||
#include <boost/static_assert.hpp>
|
||||
#define BOOST_CB_STATIC_ASSERT(Expr) BOOST_STATIC_ASSERT(Expr)
|
||||
#endif
|
||||
|
||||
/*! INTERNAL ONLY */
|
||||
// BOOST_CB_IS_CONVERTIBLE: Check if Iterator::value_type is convertible to Type.
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x0550) || BOOST_WORKAROUND(__MWERKS__, <= 0x2407) || \
|
||||
BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
#define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) ((void)0)
|
||||
#else
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#define BOOST_CB_IS_CONVERTIBLE(Iterator, Type) \
|
||||
BOOST_CB_STATIC_ASSERT((is_convertible<typename detail::iterator_traits<Iterator>::value_type, Type>::value))
|
||||
#endif
|
||||
|
||||
// BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS:
|
||||
// Check if the STL provides templated iterator constructors for its containers.
|
||||
#if defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
|
||||
#define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS BOOST_STATIC_ASSERT(false);
|
||||
#define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS BOOST_CB_STATIC_ASSERT(false);
|
||||
#else
|
||||
#define BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS ((void)0);
|
||||
#endif
|
||||
@@ -60,6 +67,8 @@ Includes <boost/circular_buffer/base.hpp>
|
||||
|
||||
#undef BOOST_CB_ASSERT_TEMPLATED_ITERATOR_CONSTRUCTORS
|
||||
#undef BOOST_CB_IS_CONVERTIBLE
|
||||
#undef BOOST_CB_STATIC_ASSERT
|
||||
#undef BOOST_CB_ASSERT
|
||||
#undef BOOST_CB_ENABLE_DEBUG
|
||||
|
||||
#endif // #if !defined(BOOST_CIRCULAR_BUFFER_HPP)
|
||||
|
||||
@@ -1,79 +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
|
||||
#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)
|
||||
using std::allocator_traits;
|
||||
#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& a) BOOST_NOEXCEPT {
|
||||
return a.max_size();
|
||||
}
|
||||
|
||||
#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
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,20 +9,10 @@
|
||||
#if !defined(BOOST_CIRCULAR_BUFFER_DEBUG_HPP)
|
||||
#define BOOST_CIRCULAR_BUFFER_DEBUG_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1200
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if BOOST_CB_ENABLE_DEBUG
|
||||
#include <cstring>
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std {
|
||||
using ::memset;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // BOOST_CB_ENABLE_DEBUG
|
||||
namespace boost {
|
||||
|
||||
namespace cb_details {
|
||||
@@ -32,17 +22,6 @@ namespace cb_details {
|
||||
// The value the uninitialized memory is filled with.
|
||||
const int UNINITIALIZED = 0xcc;
|
||||
|
||||
template <class T>
|
||||
inline void do_fill_uninitialized_memory(T* data, std::size_t size_in_bytes) BOOST_NOEXCEPT {
|
||||
std::memset(static_cast<void*>(data), UNINITIALIZED, size_in_bytes);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline void do_fill_uninitialized_memory(T& /*data*/, std::size_t /*size_in_bytes*/) BOOST_NOEXCEPT {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
class debug_iterator_registry;
|
||||
|
||||
/*!
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
|
||||
// Copyright 2014,2018 Glen Joseph Fernandes
|
||||
// (glenjofe@gmail.com)
|
||||
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -12,26 +9,15 @@
|
||||
#if !defined(BOOST_CIRCULAR_BUFFER_DETAILS_HPP)
|
||||
#define BOOST_CIRCULAR_BUFFER_DETAILS_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1200
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/iterator.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/circular_buffer/allocators.hpp>
|
||||
#include <boost/core/pointer_traits.hpp>
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/type_traits/is_nothrow_move_constructible.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <boost/detail/no_exceptions_support.hpp>
|
||||
#include <iterator>
|
||||
|
||||
// Silence MS /W4 warnings like C4913:
|
||||
// "user defined binary operator ',' exists but no overload could convert all operands, default built-in binary operator ',' used"
|
||||
// This might happen when previously including some boost headers that overload the coma operator.
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4913)
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace cb_details {
|
||||
@@ -43,10 +29,8 @@ void uninitialized_fill_n_with_alloc(
|
||||
ForwardIterator first, Diff n, const T& item, Alloc& alloc);
|
||||
|
||||
template<class InputIterator, class ForwardIterator, class Alloc>
|
||||
ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a);
|
||||
|
||||
template<class InputIterator, class ForwardIterator, class Alloc>
|
||||
ForwardIterator uninitialized_move_if_noexcept(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a);
|
||||
ForwardIterator uninitialized_copy_with_alloc(
|
||||
InputIterator first, InputIterator last, ForwardIterator dest, Alloc& alloc);
|
||||
|
||||
/*!
|
||||
\struct const_traits
|
||||
@@ -57,7 +41,7 @@ struct const_traits {
|
||||
// Basic types
|
||||
typedef typename Traits::value_type value_type;
|
||||
typedef typename Traits::const_pointer pointer;
|
||||
typedef const value_type& reference;
|
||||
typedef typename Traits::const_reference reference;
|
||||
typedef typename Traits::size_type size_type;
|
||||
typedef typename Traits::difference_type difference_type;
|
||||
|
||||
@@ -74,7 +58,7 @@ struct nonconst_traits {
|
||||
// Basic types
|
||||
typedef typename Traits::value_type value_type;
|
||||
typedef typename Traits::pointer pointer;
|
||||
typedef value_type& reference;
|
||||
typedef typename Traits::reference reference;
|
||||
typedef typename Traits::size_type size_type;
|
||||
typedef typename Traits::difference_type difference_type;
|
||||
|
||||
@@ -114,7 +98,7 @@ private:
|
||||
*/
|
||||
template <class Value, class Alloc>
|
||||
struct assign_n {
|
||||
typedef typename allocator_traits<Alloc>::size_type size_type;
|
||||
typedef typename Alloc::size_type size_type;
|
||||
size_type m_n;
|
||||
Value m_item;
|
||||
Alloc& m_alloc;
|
||||
@@ -133,24 +117,19 @@ private:
|
||||
*/
|
||||
template <class Iterator, class Alloc>
|
||||
struct assign_range {
|
||||
Iterator m_first;
|
||||
Iterator m_last;
|
||||
Alloc& m_alloc;
|
||||
|
||||
const Iterator& m_first;
|
||||
const Iterator& m_last;
|
||||
Alloc& m_alloc;
|
||||
assign_range(const Iterator& first, const Iterator& last, Alloc& alloc)
|
||||
: m_first(first), m_last(last), m_alloc(alloc) {}
|
||||
|
||||
: m_first(first), m_last(last), m_alloc(alloc) {}
|
||||
template <class Pointer>
|
||||
void operator () (Pointer p) const {
|
||||
boost::cb_details::uninitialized_copy(m_first, m_last, p, m_alloc);
|
||||
uninitialized_copy_with_alloc(m_first, m_last, p, m_alloc);
|
||||
}
|
||||
private:
|
||||
assign_range<Iterator, Alloc>& operator = (const assign_range<Iterator, Alloc>&); // do not generate
|
||||
};
|
||||
|
||||
template <class Iterator, class Alloc>
|
||||
inline assign_range<Iterator, Alloc> make_assign_range(const Iterator& first, const Iterator& last, Alloc& a) {
|
||||
return assign_range<Iterator, Alloc>(first, last, a);
|
||||
}
|
||||
|
||||
/*!
|
||||
\class capacity_control
|
||||
\brief Capacity controller of the space optimized circular buffer.
|
||||
@@ -158,19 +137,18 @@ inline assign_range<Iterator, Alloc> make_assign_range(const Iterator& first, co
|
||||
template <class Size>
|
||||
class capacity_control {
|
||||
|
||||
//! The capacity of the space-optimized circular buffer.
|
||||
//! The capacity of the space optimized circular buffer.
|
||||
Size m_capacity;
|
||||
|
||||
//! The lowest guaranteed or minimum capacity of the adapted space-optimized circular buffer.
|
||||
//! The lowest guaranteed capacity of the adapted circular buffer.
|
||||
Size m_min_capacity;
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
capacity_control(Size buffer_capacity, Size min_buffer_capacity = 0)
|
||||
: m_capacity(buffer_capacity), m_min_capacity(min_buffer_capacity)
|
||||
{ // Check for capacity lower than min_capacity.
|
||||
BOOST_CB_ASSERT(buffer_capacity >= min_buffer_capacity);
|
||||
: m_capacity(buffer_capacity), m_min_capacity(min_buffer_capacity) {
|
||||
BOOST_CB_ASSERT(buffer_capacity >= min_buffer_capacity); // check for capacity lower than min_capacity
|
||||
}
|
||||
|
||||
// Default copy constructor.
|
||||
@@ -196,33 +174,46 @@ public:
|
||||
for iterating from begin() to end() of the circular buffer.
|
||||
*/
|
||||
template <class Buff, class Traits>
|
||||
struct iterator
|
||||
struct iterator :
|
||||
public boost::iterator<
|
||||
std::random_access_iterator_tag,
|
||||
typename Traits::value_type,
|
||||
typename Traits::difference_type,
|
||||
typename Traits::pointer,
|
||||
typename Traits::reference>
|
||||
#if BOOST_CB_ENABLE_DEBUG
|
||||
: public debug_iterator_base
|
||||
, public debug_iterator_base
|
||||
#endif // #if BOOST_CB_ENABLE_DEBUG
|
||||
{
|
||||
// Helper types
|
||||
|
||||
//! Base iterator.
|
||||
typedef boost::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 Traits::value_type value_type;
|
||||
typedef typename base_iterator::value_type value_type;
|
||||
|
||||
//! Pointer to the element.
|
||||
typedef typename Traits::pointer pointer;
|
||||
typedef typename base_iterator::pointer pointer;
|
||||
|
||||
//! Reference to the element.
|
||||
typedef typename Traits::reference reference;
|
||||
typedef typename base_iterator::reference reference;
|
||||
|
||||
//! Size type.
|
||||
typedef typename Traits::size_type size_type;
|
||||
|
||||
//! Difference type.
|
||||
typedef typename Traits::difference_type difference_type;
|
||||
typedef typename base_iterator::difference_type difference_type;
|
||||
|
||||
// Member variables
|
||||
|
||||
@@ -415,49 +406,45 @@ operator + (typename Traits::difference_type n, const iterator<Buff, Traits>& it
|
||||
return it + n;
|
||||
}
|
||||
|
||||
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR)
|
||||
|
||||
//! Iterator category.
|
||||
template <class Buff, class Traits>
|
||||
inline std::random_access_iterator_tag iterator_category(const iterator<Buff, Traits>&) {
|
||||
return std::random_access_iterator_tag();
|
||||
}
|
||||
|
||||
//! The type of the elements stored in the circular buffer.
|
||||
template <class Buff, class Traits>
|
||||
inline typename Traits::value_type* value_type(const iterator<Buff, Traits>&) { return 0; }
|
||||
|
||||
//! Distance type.
|
||||
template <class Buff, class Traits>
|
||||
inline typename Traits::difference_type* distance_type(const iterator<Buff, Traits>&) { return 0; }
|
||||
|
||||
#endif // #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR)
|
||||
|
||||
/*!
|
||||
\fn ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator dest)
|
||||
\brief Equivalent of <code>std::uninitialized_copy</code> but with explicit specification of value type.
|
||||
\fn ForwardIterator uninitialized_copy_with_alloc(InputIterator first, InputIterator last, ForwardIterator dest,
|
||||
Alloc& alloc)
|
||||
\brief Equivalent of <code>std::uninitialized_copy</code> with allocator.
|
||||
*/
|
||||
template<class InputIterator, class ForwardIterator, class Alloc>
|
||||
inline ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a) {
|
||||
inline ForwardIterator uninitialized_copy_with_alloc(InputIterator first, InputIterator last, ForwardIterator dest,
|
||||
Alloc& alloc) {
|
||||
ForwardIterator next = dest;
|
||||
BOOST_TRY {
|
||||
for (; first != last; ++first, ++dest)
|
||||
allocator_traits<Alloc>::construct(a, boost::to_address(dest), *first);
|
||||
alloc.construct(dest, *first);
|
||||
} BOOST_CATCH(...) {
|
||||
for (; next != dest; ++next)
|
||||
allocator_traits<Alloc>::destroy(a, boost::to_address(next));
|
||||
alloc.destroy(next);
|
||||
BOOST_RETHROW
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
return dest;
|
||||
}
|
||||
|
||||
template<class InputIterator, class ForwardIterator, class Alloc>
|
||||
ForwardIterator uninitialized_move_if_noexcept_impl(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a,
|
||||
true_type) {
|
||||
for (; first != last; ++first, ++dest)
|
||||
allocator_traits<Alloc>::construct(a, boost::to_address(dest), boost::move(*first));
|
||||
return dest;
|
||||
}
|
||||
|
||||
template<class InputIterator, class ForwardIterator, class Alloc>
|
||||
ForwardIterator uninitialized_move_if_noexcept_impl(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a,
|
||||
false_type) {
|
||||
return uninitialized_copy(first, last, dest, a);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn ForwardIterator uninitialized_move_if_noexcept(InputIterator first, InputIterator last, ForwardIterator dest)
|
||||
\brief Equivalent of <code>std::uninitialized_copy</code> but with explicit specification of value type and moves elements if they have noexcept move constructors.
|
||||
*/
|
||||
template<class InputIterator, class ForwardIterator, class Alloc>
|
||||
ForwardIterator uninitialized_move_if_noexcept(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& a) {
|
||||
typedef typename boost::is_nothrow_move_constructible<typename allocator_traits<Alloc>::value_type>::type tag_t;
|
||||
return uninitialized_move_if_noexcept_impl(first, last, dest, a, tag_t());
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void uninitialized_fill_n_with_alloc(ForwardIterator first, Diff n, const T& item, Alloc& alloc)
|
||||
\brief Equivalent of <code>std::uninitialized_fill_n</code> with allocator.
|
||||
@@ -467,10 +454,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);
|
||||
alloc.construct(first, item);
|
||||
} BOOST_CATCH(...) {
|
||||
for (; next != first; ++next)
|
||||
allocator_traits<Alloc>::destroy(alloc, boost::to_address(next));
|
||||
alloc.destroy(next);
|
||||
BOOST_RETHROW
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
@@ -480,8 +467,4 @@ inline void uninitialized_fill_n_with_alloc(ForwardIterator first, Diff n, const
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // #if !defined(BOOST_CIRCULAR_BUFFER_DETAILS_HPP)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@
|
||||
#if !defined(BOOST_CIRCULAR_BUFFER_FWD_HPP)
|
||||
#define BOOST_CIRCULAR_BUFFER_FWD_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1200
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,17 +2,16 @@
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; URL=../../doc/html/circular_buffer.html">
|
||||
<meta http-equiv="refresh" content="0; URL=doc/circular_buffer.html">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<title>
|
||||
Redirection
|
||||
</title>
|
||||
</head>
|
||||
<body>
|
||||
Automatic redirection failed, please go to
|
||||
<a href="../../doc/html/circular_buffer.html"> ../../doc/html/circular_buffer.html</a>.
|
||||
Automatic redirection failed, please go to <a href="doc/circular_buffer.html">circular_buffer.html</a>.
|
||||
<p>
|
||||
<small>Copyright © 2003-2008 Jan Gaspar, 2013 Paul A. Bristow</small>
|
||||
<small>Copyright © 2003-2008 Jan Gaspar</small>
|
||||
</p>
|
||||
<p>
|
||||
<small>Use, modification, and distribution is subject to the Boost Software License, Version 1.0.<br>
|
||||
@@ -21,5 +20,3 @@
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"key": "circular_buffer",
|
||||
"name": "Circular Buffer",
|
||||
"authors": [
|
||||
"Jan Gaspar"
|
||||
],
|
||||
"description": "A STL compliant container also known as ring or cyclic buffer.",
|
||||
"category": [
|
||||
"Containers"
|
||||
],
|
||||
"maintainers": [
|
||||
"Jan Gaspar <jano_gaspar -at- yahoo.com>"
|
||||
]
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
# accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# Added warning suppression Paul A. Bristow 25 Nov 2008
|
||||
# Added warning supression Paul A. Bristow 25 Nov 2008
|
||||
|
||||
# Bring in rules for testing.
|
||||
import testing ;
|
||||
@@ -22,11 +22,9 @@ project
|
||||
;
|
||||
|
||||
test-suite "circular_buffer"
|
||||
: [ run base_test.cpp : : : <threading>single : ]
|
||||
[ run space_optimized_test.cpp : : : <threading>single : ]
|
||||
[ run base_test.cpp : : : <threading>single <define>"BOOST_CB_ENABLE_DEBUG=1" : base_test_dbg ]
|
||||
[ run space_optimized_test.cpp : : : <threading>single <define>"BOOST_CB_ENABLE_DEBUG=1" : space_optimized_test_dbg ]
|
||||
[ run soft_iterator_invalidation.cpp : : : <threading>single : ]
|
||||
[ run constant_erase_test.cpp : : : <threading>single : ]
|
||||
: [ run base_test.cpp : <threading>single : ]
|
||||
[ run space_optimized_test.cpp : <threading>single : ]
|
||||
[ run soft_iterator_invalidation.cpp : <threading>single : ]
|
||||
[ run constant_erase_test.cpp : <threading>single : ]
|
||||
[ compile bounded_buffer_comparison.cpp : <threading>multi : ]
|
||||
;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Test of the base circular buffer container.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
// Copyright (c) 2013 Antony Polukhin
|
||||
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -25,11 +24,11 @@ void iterator_constructor_and_assign_test() {
|
||||
circular_buffer<MyInteger>::const_iterator end1 = cb.end();
|
||||
circular_buffer<MyInteger>::const_iterator end2 = end1;
|
||||
|
||||
BOOST_TEST(itCopy == it);
|
||||
BOOST_TEST(cit == it);
|
||||
BOOST_TEST(end1 == end2);
|
||||
BOOST_TEST(it != end1);
|
||||
BOOST_TEST(cit != end2);
|
||||
BOOST_CHECK(itCopy == it);
|
||||
BOOST_CHECK(cit == it);
|
||||
BOOST_CHECK(end1 == end2);
|
||||
BOOST_CHECK(it != end1);
|
||||
BOOST_CHECK(cit != end2);
|
||||
}
|
||||
|
||||
void iterator_reference_test() {
|
||||
@@ -38,14 +37,14 @@ void iterator_reference_test() {
|
||||
circular_buffer<Dummy>::iterator it = cb.begin();
|
||||
circular_buffer<Dummy>::const_iterator cit = cb.begin() + 1;
|
||||
|
||||
BOOST_TEST((*it).m_n == Dummy::eVar);
|
||||
BOOST_TEST((*it).fnc() == Dummy::eFnc);
|
||||
BOOST_TEST((*cit).const_fnc() == Dummy::eConst);
|
||||
BOOST_TEST((*it).virtual_fnc() == Dummy::eVirtual);
|
||||
BOOST_TEST(it->m_n == Dummy::eVar);
|
||||
BOOST_TEST(it->fnc() == Dummy::eFnc);
|
||||
BOOST_TEST(cit->const_fnc() == Dummy::eConst);
|
||||
BOOST_TEST(it->virtual_fnc() == Dummy::eVirtual);
|
||||
BOOST_CHECK((*it).m_n == Dummy::eVar);
|
||||
BOOST_CHECK((*it).fnc() == Dummy::eFnc);
|
||||
BOOST_CHECK((*cit).const_fnc() == Dummy::eConst);
|
||||
BOOST_CHECK((*it).virtual_fnc() == Dummy::eVirtual);
|
||||
BOOST_CHECK(it->m_n == Dummy::eVar);
|
||||
BOOST_CHECK(it->fnc() == Dummy::eFnc);
|
||||
BOOST_CHECK(cit->const_fnc() == Dummy::eConst);
|
||||
BOOST_CHECK(it->virtual_fnc() == Dummy::eVirtual);
|
||||
}
|
||||
|
||||
void iterator_difference_test() {
|
||||
@@ -57,16 +56,16 @@ void iterator_difference_test() {
|
||||
circular_buffer<MyInteger>::const_iterator begin = cb.begin();
|
||||
circular_buffer<MyInteger>::iterator end = cb.end();
|
||||
|
||||
BOOST_TEST(begin - begin == 0);
|
||||
BOOST_TEST(end - cb.begin() == 5);
|
||||
BOOST_TEST(end - end == 0);
|
||||
BOOST_TEST(begin - cb.end() == -5);
|
||||
BOOST_TEST(it1 - cb.begin() == 2);
|
||||
BOOST_TEST(it1 - begin == 2);
|
||||
BOOST_TEST(end - it1 == 3);
|
||||
BOOST_TEST(it2 - it1 == 1);
|
||||
BOOST_TEST(it1 - it2 == -1);
|
||||
BOOST_TEST(it2 - it2 == 0);
|
||||
BOOST_CHECK(begin - begin == 0);
|
||||
BOOST_CHECK(end - cb.begin() == 5);
|
||||
BOOST_CHECK(end - end == 0);
|
||||
BOOST_CHECK(begin - cb.end() == -5);
|
||||
BOOST_CHECK(it1 - cb.begin() == 2);
|
||||
BOOST_CHECK(it1 - begin == 2);
|
||||
BOOST_CHECK(end - it1 == 3);
|
||||
BOOST_CHECK(it2 - it1 == 1);
|
||||
BOOST_CHECK(it1 - it2 == -1);
|
||||
BOOST_CHECK(it2 - it2 == 0);
|
||||
}
|
||||
|
||||
void iterator_increment_test() {
|
||||
@@ -80,9 +79,9 @@ void iterator_increment_test() {
|
||||
it2++;
|
||||
++it3;
|
||||
|
||||
BOOST_TEST(it1 == cb.begin() + 1);
|
||||
BOOST_TEST(it2 == cb.begin() + 6);
|
||||
BOOST_TEST(it3 == cb.end());
|
||||
BOOST_CHECK(it1 == cb.begin() + 1);
|
||||
BOOST_CHECK(it2 == cb.begin() + 6);
|
||||
BOOST_CHECK(it3 == cb.end());
|
||||
}
|
||||
|
||||
void iterator_decrement_test() {
|
||||
@@ -96,9 +95,9 @@ void iterator_decrement_test() {
|
||||
it2--;
|
||||
--it3;
|
||||
|
||||
BOOST_TEST(it1 == cb.end() - 1);
|
||||
BOOST_TEST(it2 == cb.end() - 6);
|
||||
BOOST_TEST(it3 == cb.begin());
|
||||
BOOST_CHECK(it1 == cb.end() - 1);
|
||||
BOOST_CHECK(it2 == cb.end() - 6);
|
||||
BOOST_CHECK(it3 == cb.begin());
|
||||
}
|
||||
|
||||
void iterator_addition_test() {
|
||||
@@ -115,12 +114,12 @@ void iterator_addition_test() {
|
||||
it3 += 5;
|
||||
it4 += -2;
|
||||
|
||||
BOOST_TEST(it1 == 5 + cb.begin());
|
||||
BOOST_TEST(it2 == cb.end());
|
||||
BOOST_TEST(it3 == cb.end());
|
||||
BOOST_TEST(it4 + 3 == cb.end());
|
||||
BOOST_TEST((-3) + it4 == cb.begin() + 4);
|
||||
BOOST_TEST(cb.begin() + 0 == cb.begin());
|
||||
BOOST_CHECK(it1 == 5 + cb.begin());
|
||||
BOOST_CHECK(it2 == cb.end());
|
||||
BOOST_CHECK(it3 == cb.end());
|
||||
BOOST_CHECK(it4 + 3 == cb.end());
|
||||
BOOST_CHECK((-3) + it4 == cb.begin() + 4);
|
||||
BOOST_CHECK(cb.begin() + 0 == cb.begin());
|
||||
}
|
||||
|
||||
void iterator_subtraction_test() {
|
||||
@@ -137,12 +136,12 @@ void iterator_subtraction_test() {
|
||||
it2 -= 0;
|
||||
it3 -= 5;
|
||||
|
||||
BOOST_TEST(it1 == cb.begin() + 2);
|
||||
BOOST_TEST(it2 == cb.end());
|
||||
BOOST_TEST(it3 == cb.begin());
|
||||
BOOST_TEST(it4 - 7 == cb.begin());
|
||||
BOOST_TEST(it4 - (-3) == cb.end());
|
||||
BOOST_TEST(cb.begin() - 0 == cb.begin());
|
||||
BOOST_CHECK(it1 == cb.begin() + 2);
|
||||
BOOST_CHECK(it2 == cb.end());
|
||||
BOOST_CHECK(it3 == cb.begin());
|
||||
BOOST_CHECK(it4 - 7 == cb.begin());
|
||||
BOOST_CHECK(it4 - (-3) == cb.end());
|
||||
BOOST_CHECK(cb.begin() - 0 == cb.begin());
|
||||
}
|
||||
|
||||
void iterator_element_access_test() {
|
||||
@@ -156,9 +155,9 @@ void iterator_element_access_test() {
|
||||
cb.push_back(6);
|
||||
circular_buffer<MyInteger>::iterator it = cb.begin() + 1;
|
||||
|
||||
BOOST_TEST(it[0] == 2);
|
||||
BOOST_TEST(it[-1] == 1);
|
||||
BOOST_TEST(it[2] == 4);
|
||||
BOOST_CHECK(it[0] == 2);
|
||||
BOOST_CHECK(it[-1] == 1);
|
||||
BOOST_CHECK(it[2] == 4);
|
||||
}
|
||||
|
||||
void iterator_comparison_test() {
|
||||
@@ -169,31 +168,31 @@ void iterator_comparison_test() {
|
||||
circular_buffer<MyInteger>::const_iterator begin = cb.begin();
|
||||
circular_buffer<MyInteger>::iterator end = cb.end();
|
||||
|
||||
BOOST_TEST(begin == begin);
|
||||
BOOST_TEST(end > cb.begin());
|
||||
BOOST_TEST(begin < end);
|
||||
BOOST_TEST(end > begin);
|
||||
BOOST_TEST(end == end);
|
||||
BOOST_TEST(begin < cb.end());
|
||||
BOOST_TEST(!(begin + 1 > cb.end()));
|
||||
BOOST_TEST(it > cb.begin());
|
||||
BOOST_TEST(end > it);
|
||||
BOOST_TEST(begin >= begin);
|
||||
BOOST_TEST(end >= cb.begin());
|
||||
BOOST_TEST(end <= end);
|
||||
BOOST_TEST(begin <= cb.end());
|
||||
BOOST_TEST(it >= cb.begin());
|
||||
BOOST_TEST(end >= it);
|
||||
BOOST_TEST(!(begin + 4 < begin + 4));
|
||||
BOOST_TEST(begin + 4 < begin + 5);
|
||||
BOOST_TEST(!(begin + 5 < begin + 4));
|
||||
BOOST_TEST(it < end - 1);
|
||||
BOOST_TEST(!(end - 1 < it));
|
||||
BOOST_CHECK(begin == begin);
|
||||
BOOST_CHECK(end > cb.begin());
|
||||
BOOST_CHECK(begin < end);
|
||||
BOOST_CHECK(end > begin);
|
||||
BOOST_CHECK(end == end);
|
||||
BOOST_CHECK(begin < cb.end());
|
||||
BOOST_CHECK(!(begin + 1 > cb.end()));
|
||||
BOOST_CHECK(it > cb.begin());
|
||||
BOOST_CHECK(end > it);
|
||||
BOOST_CHECK(begin >= begin);
|
||||
BOOST_CHECK(end >= cb.begin());
|
||||
BOOST_CHECK(end <= end);
|
||||
BOOST_CHECK(begin <= cb.end());
|
||||
BOOST_CHECK(it >= cb.begin());
|
||||
BOOST_CHECK(end >= it);
|
||||
BOOST_CHECK(!(begin + 4 < begin + 4));
|
||||
BOOST_CHECK(begin + 4 < begin + 5);
|
||||
BOOST_CHECK(!(begin + 5 < begin + 4));
|
||||
BOOST_CHECK(it < end - 1);
|
||||
BOOST_CHECK(!(end - 1 < it));
|
||||
}
|
||||
|
||||
void iterator_invalidation_test() {
|
||||
|
||||
#if BOOST_CB_ENABLE_DEBUG
|
||||
#if !defined(NDEBUG) && !defined(BOOST_CB_DISABLE_DEBUG)
|
||||
|
||||
circular_buffer<MyInteger>::iterator it1;
|
||||
circular_buffer<MyInteger>::const_iterator it2;
|
||||
@@ -202,12 +201,12 @@ void iterator_invalidation_test() {
|
||||
circular_buffer<MyInteger>::const_iterator it5;
|
||||
circular_buffer<MyInteger>::const_iterator it6;
|
||||
|
||||
BOOST_TEST(it1.is_valid(0));
|
||||
BOOST_TEST(it2.is_valid(0));
|
||||
BOOST_TEST(it3.is_valid(0));
|
||||
BOOST_TEST(it4.is_valid(0));
|
||||
BOOST_TEST(it5.is_valid(0));
|
||||
BOOST_TEST(it6.is_valid(0));
|
||||
BOOST_CHECK(it1.is_valid(0));
|
||||
BOOST_CHECK(it2.is_valid(0));
|
||||
BOOST_CHECK(it3.is_valid(0));
|
||||
BOOST_CHECK(it4.is_valid(0));
|
||||
BOOST_CHECK(it5.is_valid(0));
|
||||
BOOST_CHECK(it6.is_valid(0));
|
||||
|
||||
{
|
||||
circular_buffer<MyInteger> cb(5, 0);
|
||||
@@ -220,49 +219,49 @@ void iterator_invalidation_test() {
|
||||
it5 = it2;
|
||||
it6 = it1;
|
||||
|
||||
BOOST_TEST(it1.is_valid(&cb));
|
||||
BOOST_TEST(it2.is_valid(&ccb));
|
||||
BOOST_TEST(it3.is_valid(&cb));
|
||||
BOOST_TEST(it4.is_valid(&cb));
|
||||
BOOST_TEST(it5.is_valid(&ccb));
|
||||
BOOST_TEST(it6.is_valid(&cb));
|
||||
BOOST_CHECK(it1.is_valid(&cb));
|
||||
BOOST_CHECK(it2.is_valid(&ccb));
|
||||
BOOST_CHECK(it3.is_valid(&cb));
|
||||
BOOST_CHECK(it4.is_valid(&cb));
|
||||
BOOST_CHECK(it5.is_valid(&ccb));
|
||||
BOOST_CHECK(it6.is_valid(&cb));
|
||||
}
|
||||
|
||||
BOOST_TEST(it1.is_valid(0));
|
||||
BOOST_TEST(it2.is_valid(0));
|
||||
BOOST_TEST(it3.is_valid(0));
|
||||
BOOST_TEST(it4.is_valid(0));
|
||||
BOOST_TEST(it5.is_valid(0));
|
||||
BOOST_TEST(it6.is_valid(0));
|
||||
BOOST_CHECK(it1.is_valid(0));
|
||||
BOOST_CHECK(it2.is_valid(0));
|
||||
BOOST_CHECK(it3.is_valid(0));
|
||||
BOOST_CHECK(it4.is_valid(0));
|
||||
BOOST_CHECK(it5.is_valid(0));
|
||||
BOOST_CHECK(it6.is_valid(0));
|
||||
|
||||
circular_buffer<MyInteger> cb(10, 0);
|
||||
it1 = cb.end();
|
||||
cb.clear();
|
||||
BOOST_TEST(it1.is_valid(&cb));
|
||||
BOOST_CHECK(it1.is_valid(&cb));
|
||||
cb.push_back(1);
|
||||
cb.push_back(2);
|
||||
cb.push_back(3);
|
||||
int i = 0;
|
||||
for (it2 = cb.begin(); it2 != it1; it2++, i++);
|
||||
BOOST_TEST(i == 3);
|
||||
BOOST_CHECK(i == 3);
|
||||
|
||||
circular_buffer<MyInteger> cb1(10, 0);
|
||||
circular_buffer<MyInteger> cb2(20, 0);
|
||||
it1 = cb1.end();
|
||||
it2 = cb2.begin();
|
||||
BOOST_TEST(it1.is_valid(&cb1));
|
||||
BOOST_TEST(it2.is_valid(&cb2));
|
||||
BOOST_CHECK(it1.is_valid(&cb1));
|
||||
BOOST_CHECK(it2.is_valid(&cb2));
|
||||
|
||||
cb1.swap(cb2);
|
||||
BOOST_TEST(!it1.is_valid(&cb1));
|
||||
BOOST_TEST(!it2.is_valid(&cb2));
|
||||
BOOST_CHECK(!it1.is_valid(&cb1));
|
||||
BOOST_CHECK(!it2.is_valid(&cb2));
|
||||
|
||||
it1 = cb1.begin() + 3;
|
||||
it2 = cb1.begin();
|
||||
cb1.push_back(1);
|
||||
BOOST_TEST(it1.is_valid(&cb1));
|
||||
BOOST_TEST(!it2.is_valid(&cb1));
|
||||
BOOST_TEST(*it2.m_it == 1);
|
||||
BOOST_CHECK(it1.is_valid(&cb1));
|
||||
BOOST_CHECK(!it2.is_valid(&cb1));
|
||||
BOOST_CHECK(*it2.m_it == 1);
|
||||
|
||||
circular_buffer<MyInteger> cb3(5);
|
||||
cb3.push_back(1);
|
||||
@@ -273,16 +272,16 @@ void iterator_invalidation_test() {
|
||||
it1 = cb3.begin() + 2;
|
||||
it2 = cb3.begin();
|
||||
cb3.insert(cb3.begin() + 3, 6);
|
||||
BOOST_TEST(it1.is_valid(&cb3));
|
||||
BOOST_TEST(!it2.is_valid(&cb3));
|
||||
BOOST_TEST(*it2.m_it == 5);
|
||||
BOOST_CHECK(it1.is_valid(&cb3));
|
||||
BOOST_CHECK(!it2.is_valid(&cb3));
|
||||
BOOST_CHECK(*it2.m_it == 5);
|
||||
|
||||
it1 = cb3.begin() + 3;
|
||||
it2 = cb3.end() - 1;
|
||||
cb3.push_front(7);
|
||||
BOOST_TEST(it1.is_valid(&cb3));
|
||||
BOOST_TEST(!it2.is_valid(&cb3));
|
||||
BOOST_TEST(*it2.m_it == 7);
|
||||
BOOST_CHECK(it1.is_valid(&cb3));
|
||||
BOOST_CHECK(!it2.is_valid(&cb3));
|
||||
BOOST_CHECK(*it2.m_it == 7);
|
||||
|
||||
circular_buffer<MyInteger> cb4(5);
|
||||
cb4.push_back(1);
|
||||
@@ -293,51 +292,51 @@ void iterator_invalidation_test() {
|
||||
it1 = cb4.begin() + 3;
|
||||
it2 = cb4.begin();
|
||||
cb4.rinsert(cb4.begin() + 2, 6);
|
||||
BOOST_TEST(it1.is_valid(&cb4));
|
||||
BOOST_TEST(!it2.is_valid(&cb4));
|
||||
BOOST_TEST(*it2.m_it == 2);
|
||||
BOOST_CHECK(it1.is_valid(&cb4));
|
||||
BOOST_CHECK(!it2.is_valid(&cb4));
|
||||
BOOST_CHECK(*it2.m_it == 2);
|
||||
|
||||
it1 = cb1.begin() + 5;
|
||||
it2 = cb1.end() - 1;
|
||||
cb1.pop_back();
|
||||
BOOST_TEST(it1.is_valid(&cb1));
|
||||
BOOST_TEST(!it2.is_valid(&cb1));
|
||||
BOOST_CHECK(it1.is_valid(&cb1));
|
||||
BOOST_CHECK(!it2.is_valid(&cb1));
|
||||
|
||||
it1 = cb1.begin() + 5;
|
||||
it2 = cb1.begin();
|
||||
cb1.pop_front();
|
||||
BOOST_TEST(it1.is_valid(&cb1));
|
||||
BOOST_TEST(!it2.is_valid(&cb1));
|
||||
BOOST_CHECK(it1.is_valid(&cb1));
|
||||
BOOST_CHECK(!it2.is_valid(&cb1));
|
||||
|
||||
circular_buffer<MyInteger> cb5(20, 0);
|
||||
it1 = cb5.begin() + 5;
|
||||
it2 = it3 = cb5.begin() + 15;
|
||||
cb5.erase(cb5.begin() + 10);
|
||||
BOOST_TEST(it1.is_valid(&cb5));
|
||||
BOOST_TEST(!it2.is_valid(&cb5));
|
||||
BOOST_TEST(!it3.is_valid(&cb5));
|
||||
BOOST_CHECK(it1.is_valid(&cb5));
|
||||
BOOST_CHECK(!it2.is_valid(&cb5));
|
||||
BOOST_CHECK(!it3.is_valid(&cb5));
|
||||
|
||||
it1 = cb5.begin() + 1;
|
||||
it2 = it3 = cb5.begin() + 8;
|
||||
cb5.erase(cb5.begin() + 3, cb5.begin() + 7);
|
||||
BOOST_TEST(it1.is_valid(&cb5));
|
||||
BOOST_TEST(!it2.is_valid(&cb5));
|
||||
BOOST_TEST(!it3.is_valid(&cb5));
|
||||
BOOST_CHECK(it1.is_valid(&cb5));
|
||||
BOOST_CHECK(!it2.is_valid(&cb5));
|
||||
BOOST_CHECK(!it3.is_valid(&cb5));
|
||||
|
||||
circular_buffer<MyInteger> cb6(20, 0);
|
||||
it4 = it1 = cb6.begin() + 5;
|
||||
it2 = cb6.begin() + 15;
|
||||
cb6.rerase(cb6.begin() + 10);
|
||||
BOOST_TEST(!it1.is_valid(&cb6));
|
||||
BOOST_TEST(!it4.is_valid(&cb6));
|
||||
BOOST_TEST(it2.is_valid(&cb6));
|
||||
BOOST_CHECK(!it1.is_valid(&cb6));
|
||||
BOOST_CHECK(!it4.is_valid(&cb6));
|
||||
BOOST_CHECK(it2.is_valid(&cb6));
|
||||
|
||||
it4 = it1 = cb6.begin() + 1;
|
||||
it2 = cb6.begin() + 8;
|
||||
cb6.rerase(cb6.begin() + 3, cb6.begin() + 7);
|
||||
BOOST_TEST(!it1.is_valid(&cb6));
|
||||
BOOST_TEST(!it4.is_valid(&cb6));
|
||||
BOOST_TEST(it2.is_valid(&cb6));
|
||||
BOOST_CHECK(!it1.is_valid(&cb6));
|
||||
BOOST_CHECK(!it4.is_valid(&cb6));
|
||||
BOOST_CHECK(it2.is_valid(&cb6));
|
||||
|
||||
circular_buffer<MyInteger> cb7(10, 1);
|
||||
cb7.push_back(2);
|
||||
@@ -347,16 +346,16 @@ void iterator_invalidation_test() {
|
||||
it2 = cb7.begin();
|
||||
it3 = cb7.begin() + 6;
|
||||
cb7.linearize();
|
||||
BOOST_TEST(it1.is_valid(&cb7));
|
||||
BOOST_TEST(!it2.is_valid(&cb7));
|
||||
BOOST_TEST(!it3.is_valid(&cb7));
|
||||
BOOST_CHECK(it1.is_valid(&cb7));
|
||||
BOOST_CHECK(!it2.is_valid(&cb7));
|
||||
BOOST_CHECK(!it3.is_valid(&cb7));
|
||||
it1 = cb7.end();
|
||||
it2 = cb7.begin();
|
||||
it3 = cb7.begin() + 6;
|
||||
cb7.linearize();
|
||||
BOOST_TEST(it1.is_valid(&cb7));
|
||||
BOOST_TEST(it2.is_valid(&cb7));
|
||||
BOOST_TEST(it3.is_valid(&cb7));
|
||||
BOOST_CHECK(it1.is_valid(&cb7));
|
||||
BOOST_CHECK(it2.is_valid(&cb7));
|
||||
BOOST_CHECK(it3.is_valid(&cb7));
|
||||
|
||||
cb7.push_back(5);
|
||||
cb7.push_back(6);
|
||||
@@ -364,21 +363,21 @@ void iterator_invalidation_test() {
|
||||
it2 = cb7.begin();
|
||||
it3 = cb7.begin() + 6;
|
||||
cb7.set_capacity(10);
|
||||
BOOST_TEST(it1.is_valid(&cb7));
|
||||
BOOST_TEST(it2.is_valid(&cb7));
|
||||
BOOST_TEST(it3.is_valid(&cb7));
|
||||
BOOST_CHECK(it1.is_valid(&cb7));
|
||||
BOOST_CHECK(it2.is_valid(&cb7));
|
||||
BOOST_CHECK(it3.is_valid(&cb7));
|
||||
cb7.set_capacity(20);
|
||||
BOOST_TEST(it1.is_valid(&cb7));
|
||||
BOOST_TEST(!it2.is_valid(&cb7));
|
||||
BOOST_TEST(!it3.is_valid(&cb7));
|
||||
BOOST_CHECK(it1.is_valid(&cb7));
|
||||
BOOST_CHECK(!it2.is_valid(&cb7));
|
||||
BOOST_CHECK(!it3.is_valid(&cb7));
|
||||
cb7.push_back(7);
|
||||
it1 = cb7.end();
|
||||
it2 = cb7.begin();
|
||||
it3 = cb7.begin() + 6;
|
||||
cb7.set_capacity(10);
|
||||
BOOST_TEST(it1.is_valid(&cb7));
|
||||
BOOST_TEST(!it2.is_valid(&cb7));
|
||||
BOOST_TEST(!it3.is_valid(&cb7));
|
||||
BOOST_CHECK(it1.is_valid(&cb7));
|
||||
BOOST_CHECK(!it2.is_valid(&cb7));
|
||||
BOOST_CHECK(!it3.is_valid(&cb7));
|
||||
|
||||
cb7.push_back(8);
|
||||
cb7.push_back(9);
|
||||
@@ -386,21 +385,21 @@ void iterator_invalidation_test() {
|
||||
it2 = cb7.begin();
|
||||
it3 = cb7.begin() + 6;
|
||||
cb7.rset_capacity(10);
|
||||
BOOST_TEST(it1.is_valid(&cb7));
|
||||
BOOST_TEST(it2.is_valid(&cb7));
|
||||
BOOST_TEST(it3.is_valid(&cb7));
|
||||
BOOST_CHECK(it1.is_valid(&cb7));
|
||||
BOOST_CHECK(it2.is_valid(&cb7));
|
||||
BOOST_CHECK(it3.is_valid(&cb7));
|
||||
cb7.rset_capacity(20);
|
||||
BOOST_TEST(it1.is_valid(&cb7));
|
||||
BOOST_TEST(!it2.is_valid(&cb7));
|
||||
BOOST_TEST(!it3.is_valid(&cb7));
|
||||
BOOST_CHECK(it1.is_valid(&cb7));
|
||||
BOOST_CHECK(!it2.is_valid(&cb7));
|
||||
BOOST_CHECK(!it3.is_valid(&cb7));
|
||||
cb7.push_back(10);
|
||||
it1 = cb7.end();
|
||||
it2 = cb7.begin();
|
||||
it3 = cb7.begin() + 6;
|
||||
cb7.rset_capacity(10);
|
||||
BOOST_TEST(it1.is_valid(&cb7));
|
||||
BOOST_TEST(!it2.is_valid(&cb7));
|
||||
BOOST_TEST(!it3.is_valid(&cb7));
|
||||
BOOST_CHECK(it1.is_valid(&cb7));
|
||||
BOOST_CHECK(!it2.is_valid(&cb7));
|
||||
BOOST_CHECK(!it3.is_valid(&cb7));
|
||||
|
||||
circular_buffer<MyInteger> cb8(10, 1);
|
||||
cb8.push_back(2);
|
||||
@@ -409,23 +408,23 @@ void iterator_invalidation_test() {
|
||||
it2 = cb8.begin();
|
||||
it3 = cb8.begin() + 6;
|
||||
cb8.resize(10);
|
||||
BOOST_TEST(it1.is_valid(&cb8));
|
||||
BOOST_TEST(it2.is_valid(&cb8));
|
||||
BOOST_TEST(it3.is_valid(&cb8));
|
||||
BOOST_CHECK(it1.is_valid(&cb8));
|
||||
BOOST_CHECK(it2.is_valid(&cb8));
|
||||
BOOST_CHECK(it3.is_valid(&cb8));
|
||||
cb8.resize(20);
|
||||
BOOST_TEST(it1.is_valid(&cb8));
|
||||
BOOST_TEST(!it2.is_valid(&cb8));
|
||||
BOOST_TEST(!it3.is_valid(&cb8));
|
||||
BOOST_CHECK(it1.is_valid(&cb8));
|
||||
BOOST_CHECK(!it2.is_valid(&cb8));
|
||||
BOOST_CHECK(!it3.is_valid(&cb8));
|
||||
cb8.push_back(4);
|
||||
it1 = cb8.end();
|
||||
it2 = cb8.begin();
|
||||
it3 = cb8.begin() + 6;
|
||||
it4 = cb8.begin() + 12;
|
||||
cb8.resize(10);
|
||||
BOOST_TEST(it1.is_valid(&cb8));
|
||||
BOOST_TEST(it2.is_valid(&cb8));
|
||||
BOOST_TEST(it3.is_valid(&cb8));
|
||||
BOOST_TEST(!it4.is_valid(&cb8));
|
||||
BOOST_CHECK(it1.is_valid(&cb8));
|
||||
BOOST_CHECK(it2.is_valid(&cb8));
|
||||
BOOST_CHECK(it3.is_valid(&cb8));
|
||||
BOOST_CHECK(!it4.is_valid(&cb8));
|
||||
|
||||
cb8.set_capacity(10);
|
||||
cb8.push_back(5);
|
||||
@@ -434,23 +433,23 @@ void iterator_invalidation_test() {
|
||||
it2 = cb8.begin();
|
||||
it3 = cb8.begin() + 6;
|
||||
cb8.rresize(10);
|
||||
BOOST_TEST(it1.is_valid(&cb8));
|
||||
BOOST_TEST(it2.is_valid(&cb8));
|
||||
BOOST_TEST(it3.is_valid(&cb8));
|
||||
BOOST_CHECK(it1.is_valid(&cb8));
|
||||
BOOST_CHECK(it2.is_valid(&cb8));
|
||||
BOOST_CHECK(it3.is_valid(&cb8));
|
||||
cb8.rresize(20);
|
||||
BOOST_TEST(it1.is_valid(&cb8));
|
||||
BOOST_TEST(!it2.is_valid(&cb8));
|
||||
BOOST_TEST(!it3.is_valid(&cb8));
|
||||
BOOST_CHECK(it1.is_valid(&cb8));
|
||||
BOOST_CHECK(!it2.is_valid(&cb8));
|
||||
BOOST_CHECK(!it3.is_valid(&cb8));
|
||||
cb8.push_back(7);
|
||||
it1 = cb8.end();
|
||||
it2 = cb8.begin();
|
||||
it3 = cb8.begin() + 6;
|
||||
it4 = cb8.begin() + 12;
|
||||
cb8.rresize(10);
|
||||
BOOST_TEST(it1.is_valid(&cb8));
|
||||
BOOST_TEST(!it2.is_valid(&cb8));
|
||||
BOOST_TEST(!it3.is_valid(&cb8));
|
||||
BOOST_TEST(it4.is_valid(&cb8));
|
||||
BOOST_CHECK(it1.is_valid(&cb8));
|
||||
BOOST_CHECK(!it2.is_valid(&cb8));
|
||||
BOOST_CHECK(!it3.is_valid(&cb8));
|
||||
BOOST_CHECK(it4.is_valid(&cb8));
|
||||
|
||||
circular_buffer<MyInteger> cb9(15, 1);
|
||||
it1 = cb9.end();
|
||||
@@ -458,10 +457,10 @@ void iterator_invalidation_test() {
|
||||
it3 = cb9.begin() + 6;
|
||||
it4 = cb9.begin() + 12;
|
||||
cb9 = cb8;
|
||||
BOOST_TEST(it1.is_valid(&cb9));
|
||||
BOOST_TEST(!it2.is_valid(&cb9));
|
||||
BOOST_TEST(!it3.is_valid(&cb9));
|
||||
BOOST_TEST(!it4.is_valid(&cb9));
|
||||
BOOST_CHECK(it1.is_valid(&cb9));
|
||||
BOOST_CHECK(!it2.is_valid(&cb9));
|
||||
BOOST_CHECK(!it3.is_valid(&cb9));
|
||||
BOOST_CHECK(!it4.is_valid(&cb9));
|
||||
|
||||
circular_buffer<MyInteger> cb10(10, 1);
|
||||
it1 = cb10.end();
|
||||
@@ -469,10 +468,10 @@ void iterator_invalidation_test() {
|
||||
it3 = cb10.begin() + 3;
|
||||
it4 = cb10.begin() + 7;
|
||||
cb10.assign(5, 2);
|
||||
BOOST_TEST(it1.is_valid(&cb10));
|
||||
BOOST_TEST(!it2.is_valid(&cb10));
|
||||
BOOST_TEST(!it3.is_valid(&cb10));
|
||||
BOOST_TEST(!it4.is_valid(&cb10));
|
||||
BOOST_CHECK(it1.is_valid(&cb10));
|
||||
BOOST_CHECK(!it2.is_valid(&cb10));
|
||||
BOOST_CHECK(!it3.is_valid(&cb10));
|
||||
BOOST_CHECK(!it4.is_valid(&cb10));
|
||||
|
||||
circular_buffer<MyInteger> cb11(10, 1);
|
||||
it1 = cb11.end();
|
||||
@@ -480,10 +479,10 @@ void iterator_invalidation_test() {
|
||||
it3 = cb11.begin() + 3;
|
||||
it4 = cb11.begin() + 7;
|
||||
cb11.assign(15, 5, 2);
|
||||
BOOST_TEST(it1.is_valid(&cb11));
|
||||
BOOST_TEST(!it2.is_valid(&cb11));
|
||||
BOOST_TEST(!it3.is_valid(&cb11));
|
||||
BOOST_TEST(!it4.is_valid(&cb11));
|
||||
BOOST_CHECK(it1.is_valid(&cb11));
|
||||
BOOST_CHECK(!it2.is_valid(&cb11));
|
||||
BOOST_CHECK(!it3.is_valid(&cb11));
|
||||
BOOST_CHECK(!it4.is_valid(&cb11));
|
||||
|
||||
circular_buffer<MyInteger> cb12(10, 1);
|
||||
it1 = cb12.end();
|
||||
@@ -491,10 +490,10 @@ void iterator_invalidation_test() {
|
||||
it3 = cb12.begin() + 3;
|
||||
it4 = cb12.begin() + 7;
|
||||
cb12.assign(cb11.begin(), cb11.end());
|
||||
BOOST_TEST(it1.is_valid(&cb12));
|
||||
BOOST_TEST(!it2.is_valid(&cb12));
|
||||
BOOST_TEST(!it3.is_valid(&cb12));
|
||||
BOOST_TEST(!it4.is_valid(&cb12));
|
||||
BOOST_CHECK(it1.is_valid(&cb12));
|
||||
BOOST_CHECK(!it2.is_valid(&cb12));
|
||||
BOOST_CHECK(!it3.is_valid(&cb12));
|
||||
BOOST_CHECK(!it4.is_valid(&cb12));
|
||||
|
||||
circular_buffer<MyInteger> cb13(10, 1);
|
||||
it1 = cb13.end();
|
||||
@@ -502,10 +501,10 @@ void iterator_invalidation_test() {
|
||||
it3 = cb13.begin() + 3;
|
||||
it4 = cb13.begin() + 7;
|
||||
cb13.assign(15, cb11.begin(), cb11.end());
|
||||
BOOST_TEST(it1.is_valid(&cb13));
|
||||
BOOST_TEST(!it2.is_valid(&cb13));
|
||||
BOOST_TEST(!it3.is_valid(&cb13));
|
||||
BOOST_TEST(!it4.is_valid(&cb13));
|
||||
BOOST_CHECK(it1.is_valid(&cb13));
|
||||
BOOST_CHECK(!it2.is_valid(&cb13));
|
||||
BOOST_CHECK(!it3.is_valid(&cb13));
|
||||
BOOST_CHECK(!it4.is_valid(&cb13));
|
||||
|
||||
circular_buffer<MyInteger> cb14(10);
|
||||
cb14.push_back(1);
|
||||
@@ -520,10 +519,10 @@ void iterator_invalidation_test() {
|
||||
it3 = cb14.begin() + 1;
|
||||
it4 = cb14.begin() + 5;
|
||||
cb14.rotate(it2);
|
||||
BOOST_TEST(it1.is_valid(&cb14));
|
||||
BOOST_TEST(it2.is_valid(&cb14));
|
||||
BOOST_TEST(!it3.is_valid(&cb14));
|
||||
BOOST_TEST(it4.is_valid(&cb14));
|
||||
BOOST_CHECK(it1.is_valid(&cb14));
|
||||
BOOST_CHECK(it2.is_valid(&cb14));
|
||||
BOOST_CHECK(!it3.is_valid(&cb14));
|
||||
BOOST_CHECK(it4.is_valid(&cb14));
|
||||
|
||||
circular_buffer<MyInteger> cb15(7);
|
||||
cb15.push_back(1);
|
||||
@@ -540,10 +539,10 @@ void iterator_invalidation_test() {
|
||||
it3 = cb15.begin() + 1;
|
||||
it4 = cb15.begin() + 5;
|
||||
cb15.rotate(it3);
|
||||
BOOST_TEST(it1.is_valid(&cb15));
|
||||
BOOST_TEST(it2.is_valid(&cb15));
|
||||
BOOST_TEST(it3.is_valid(&cb15));
|
||||
BOOST_TEST(it4.is_valid(&cb15));
|
||||
BOOST_CHECK(it1.is_valid(&cb15));
|
||||
BOOST_CHECK(it2.is_valid(&cb15));
|
||||
BOOST_CHECK(it3.is_valid(&cb15));
|
||||
BOOST_CHECK(it4.is_valid(&cb15));
|
||||
|
||||
circular_buffer<MyInteger> cb16(10);
|
||||
cb16.push_back(1);
|
||||
@@ -558,12 +557,12 @@ void iterator_invalidation_test() {
|
||||
it3 = cb16.begin();
|
||||
it4 = cb16.begin() + 5;
|
||||
cb16.rotate(it4);
|
||||
BOOST_TEST(it1.is_valid(&cb16));
|
||||
BOOST_TEST(!it2.is_valid(&cb16));
|
||||
BOOST_TEST(it3.is_valid(&cb16));
|
||||
BOOST_TEST(!it4.is_valid(&cb16));
|
||||
BOOST_CHECK(it1.is_valid(&cb16));
|
||||
BOOST_CHECK(!it2.is_valid(&cb16));
|
||||
BOOST_CHECK(it3.is_valid(&cb16));
|
||||
BOOST_CHECK(!it4.is_valid(&cb16));
|
||||
|
||||
#endif // #if BOOST_CB_ENABLE_DEBUG
|
||||
#endif // #if !defined(NDEBUG) && !defined(BOOST_CB_DISABLE_DEBUG)
|
||||
}
|
||||
|
||||
// basic exception safety test (it is useful to use any memory-leak detection tool)
|
||||
@@ -573,290 +572,189 @@ void exception_safety_test() {
|
||||
|
||||
circular_buffer<MyInteger> cb1(3, 5);
|
||||
MyInteger::set_exception_trigger(3);
|
||||
BOOST_TEST_THROWS(cb1.set_capacity(5), std::exception);
|
||||
BOOST_TEST(cb1.capacity() == 3);
|
||||
BOOST_CHECK_THROW(cb1.set_capacity(5), std::exception);
|
||||
BOOST_CHECK(cb1.capacity() == 3);
|
||||
MyInteger::set_exception_trigger(3);
|
||||
BOOST_TEST_THROWS(cb1.rset_capacity(5), std::exception);
|
||||
BOOST_TEST(cb1.capacity() == 3);
|
||||
BOOST_CHECK_THROW(cb1.rset_capacity(5), std::exception);
|
||||
BOOST_CHECK(cb1.capacity() == 3);
|
||||
generic_test(cb1);
|
||||
|
||||
MyInteger::set_exception_trigger(3);
|
||||
BOOST_TEST_THROWS(circular_buffer<MyInteger> cb2(5, 10), std::exception);
|
||||
BOOST_CHECK_THROW(circular_buffer<MyInteger> cb2(5, 10), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb3(5, 10);
|
||||
MyInteger::set_exception_trigger(3);
|
||||
BOOST_TEST_THROWS(circular_buffer<MyInteger> cb4(cb3), std::exception);
|
||||
BOOST_CHECK_THROW(circular_buffer<MyInteger> cb4(cb3), std::exception);
|
||||
|
||||
vector<MyInteger> v(5, MyInteger(10));
|
||||
MyInteger::set_exception_trigger(3);
|
||||
BOOST_TEST_THROWS(circular_buffer<MyInteger> cb5(8, v.begin(), v.end()), std::exception);
|
||||
BOOST_CHECK_THROW(circular_buffer<MyInteger> cb5(8, v.begin(), v.end()), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb6(5, 10);
|
||||
circular_buffer<MyInteger> cb7(8, 3);
|
||||
MyInteger::set_exception_trigger(3);
|
||||
BOOST_TEST_THROWS(cb7 = cb6, std::exception);
|
||||
BOOST_TEST(cb7.size() == 8);
|
||||
BOOST_TEST(cb7.capacity() == 8);
|
||||
BOOST_TEST(cb7[0] == 3);
|
||||
BOOST_TEST(cb7[7] == 3);
|
||||
BOOST_CHECK_THROW(cb7 = cb6, std::exception);
|
||||
BOOST_CHECK(cb7.size() == 8);
|
||||
BOOST_CHECK(cb7.capacity() == 8);
|
||||
BOOST_CHECK(cb7[0] == 3);
|
||||
BOOST_CHECK(cb7[7] == 3);
|
||||
generic_test(cb7);
|
||||
|
||||
circular_buffer<MyInteger> cb8(5, 10);
|
||||
MyInteger::set_exception_trigger(2);
|
||||
BOOST_TEST_THROWS(cb8.push_front(1), std::exception);
|
||||
BOOST_CHECK_THROW(cb8.push_front(1), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb9(5);
|
||||
cb9.push_back(1);
|
||||
cb9.push_back(2);
|
||||
cb9.push_back(3);
|
||||
MyInteger::set_exception_trigger(3);
|
||||
BOOST_TEST_THROWS(cb9.insert(cb9.begin() + 1, 4), std::exception);
|
||||
BOOST_CHECK_THROW(cb9.insert(cb9.begin() + 1, 4), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb10(5);
|
||||
cb10.push_back(1);
|
||||
cb10.push_back(2);
|
||||
cb10.push_back(3);
|
||||
MyInteger::set_exception_trigger(3);
|
||||
BOOST_TEST_THROWS(cb10.rinsert(cb10.begin() + 1, 4), std::exception);
|
||||
BOOST_CHECK_THROW(cb10.rinsert(cb10.begin() + 1, 4), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb11(5);
|
||||
cb11.push_back(1);
|
||||
cb11.push_back(2);
|
||||
MyInteger::set_exception_trigger(2);
|
||||
BOOST_TEST_THROWS(cb11.rinsert(cb11.begin(), 1), std::exception);
|
||||
BOOST_CHECK_THROW(cb11.rinsert(cb11.begin(), 1), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb12(5, 1);
|
||||
MyInteger::set_exception_trigger(3);
|
||||
BOOST_TEST_THROWS(cb12.assign(4, 2), std::exception);
|
||||
BOOST_CHECK_THROW(cb12.assign(4, 2), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb13(5, 1);
|
||||
MyInteger::set_exception_trigger(3);
|
||||
BOOST_TEST_THROWS(cb13.assign(6, 2), std::exception);
|
||||
BOOST_CHECK_THROW(cb13.assign(6, 2), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb14(5);
|
||||
cb14.push_back(1);
|
||||
cb14.push_back(2);
|
||||
MyInteger::set_exception_trigger(3);
|
||||
BOOST_TEST_THROWS(cb14.insert(cb14.begin(), 10, 3), std::exception);
|
||||
BOOST_CHECK_THROW(cb14.insert(cb14.begin(), 10, 3), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb15(5);
|
||||
cb15.push_back(1);
|
||||
cb15.push_back(2);
|
||||
MyInteger::set_exception_trigger(3);
|
||||
BOOST_TEST_THROWS(cb15.insert(cb15.end(), 10, 3), std::exception);
|
||||
BOOST_CHECK_THROW(cb15.insert(cb15.end(), 10, 3), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb16(5);
|
||||
cb16.push_back(1);
|
||||
cb16.push_back(2);
|
||||
MyInteger::set_exception_trigger(3);
|
||||
BOOST_TEST_THROWS(cb16.rinsert(cb16.begin(), 10, 3), std::exception);
|
||||
BOOST_CHECK_THROW(cb16.rinsert(cb16.begin(), 10, 3), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb17(5);
|
||||
cb17.push_back(1);
|
||||
cb17.push_back(2);
|
||||
MyInteger::set_exception_trigger(3);
|
||||
BOOST_TEST_THROWS(cb17.rinsert(cb17.end(), 10, 3), std::exception);
|
||||
BOOST_CHECK_THROW(cb17.rinsert(cb17.end(), 10, 3), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb18(5, 0);
|
||||
cb18.push_back(1);
|
||||
cb18.push_back(2);
|
||||
cb18.pop_front();
|
||||
MyInteger::set_exception_trigger(4);
|
||||
BOOST_TEST_THROWS(cb18.linearize(), std::exception);
|
||||
BOOST_CHECK_THROW(cb18.linearize(), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb19(5, 0);
|
||||
cb19.push_back(1);
|
||||
cb19.push_back(2);
|
||||
MyInteger::set_exception_trigger(5);
|
||||
BOOST_TEST_THROWS(cb19.linearize(), std::exception);
|
||||
BOOST_CHECK_THROW(cb19.linearize(), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb20(5, 0);
|
||||
cb20.push_back(1);
|
||||
cb20.push_back(2);
|
||||
MyInteger::set_exception_trigger(6);
|
||||
BOOST_TEST_THROWS(cb20.linearize(), std::exception);
|
||||
BOOST_CHECK_THROW(cb20.linearize(), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb21(5);
|
||||
cb21.push_back(1);
|
||||
cb21.push_back(2);
|
||||
cb21.push_back(3);
|
||||
MyInteger::set_exception_trigger(2);
|
||||
BOOST_TEST_THROWS(cb21.insert(cb21.begin() + 1, 4), std::exception);
|
||||
BOOST_CHECK_THROW(cb21.insert(cb21.begin() + 1, 4), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb22(5);
|
||||
cb22.push_back(1);
|
||||
cb22.push_back(2);
|
||||
cb22.push_back(3);
|
||||
MyInteger::set_exception_trigger(2);
|
||||
BOOST_TEST_THROWS(cb22.insert(cb22.end(), 4), std::exception);
|
||||
BOOST_CHECK_THROW(cb22.insert(cb22.end(), 4), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb23(5, 0);
|
||||
MyInteger::set_exception_trigger(2);
|
||||
BOOST_TEST_THROWS(cb23.insert(cb23.begin() + 1, 4), std::exception);
|
||||
BOOST_CHECK_THROW(cb23.insert(cb23.begin() + 1, 4), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb24(5);
|
||||
cb24.push_back(1);
|
||||
cb24.push_back(2);
|
||||
cb24.push_back(3);
|
||||
MyInteger::set_exception_trigger(2);
|
||||
BOOST_TEST_THROWS(cb24.rinsert(cb24.begin() + 1, 4), std::exception);
|
||||
BOOST_CHECK_THROW(cb24.rinsert(cb24.begin() + 1, 4), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb25(5, 0);
|
||||
MyInteger::set_exception_trigger(2);
|
||||
BOOST_TEST_THROWS(cb25.rinsert(cb25.begin() + 3, 4), std::exception);
|
||||
BOOST_CHECK_THROW(cb25.rinsert(cb25.begin() + 3, 4), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb26(5);
|
||||
cb26.push_back(1);
|
||||
cb26.push_back(2);
|
||||
MyInteger::set_exception_trigger(5);
|
||||
BOOST_TEST_THROWS(cb26.insert(cb26.begin(), 10, 3), std::exception);
|
||||
BOOST_CHECK_THROW(cb26.insert(cb26.begin(), 10, 3), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb27(5);
|
||||
cb27.push_back(1);
|
||||
cb27.push_back(2);
|
||||
MyInteger::set_exception_trigger(5);
|
||||
BOOST_TEST_THROWS(cb27.insert(cb27.end(), 10, 3), std::exception);
|
||||
BOOST_CHECK_THROW(cb27.insert(cb27.end(), 10, 3), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb28(5);
|
||||
cb28.push_back(1);
|
||||
cb28.push_back(2);
|
||||
MyInteger::set_exception_trigger(5);
|
||||
BOOST_TEST_THROWS(cb28.rinsert(cb28.begin(), 10, 3), std::exception);
|
||||
BOOST_CHECK_THROW(cb28.rinsert(cb28.begin(), 10, 3), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb29(5);
|
||||
cb29.push_back(1);
|
||||
cb29.push_back(2);
|
||||
MyInteger::set_exception_trigger(5);
|
||||
BOOST_TEST_THROWS(cb29.rinsert(cb29.end(), 10, 3), std::exception);
|
||||
BOOST_CHECK_THROW(cb29.rinsert(cb29.end(), 10, 3), std::exception);
|
||||
|
||||
circular_buffer<MyInteger> cb30(10);
|
||||
cb30.push_back(1);
|
||||
cb30.push_back(2);
|
||||
cb30.push_back(3);
|
||||
MyInteger::set_exception_trigger(2);
|
||||
BOOST_TEST_THROWS(cb30.rinsert(cb30.begin(), 10, 3), std::exception);
|
||||
BOOST_CHECK_THROW(cb30.rinsert(cb30.begin(), 10, 3), std::exception);
|
||||
|
||||
#endif // #if !defined(BOOST_NO_EXCEPTIONS)
|
||||
}
|
||||
|
||||
|
||||
void move_container_values_except() {
|
||||
move_container_values_impl<noncopyable_movable_except_t>();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void move_container_values_resetting_impl() {
|
||||
typedef T noncopyable_movable_test_t;
|
||||
CB_CONTAINER<noncopyable_movable_test_t> cb1(1);
|
||||
noncopyable_movable_test_t var;
|
||||
cb1.push_back();
|
||||
|
||||
cb1.push_back(boost::move(var));
|
||||
BOOST_TEST(!cb1.back().is_moved());
|
||||
BOOST_TEST(var.is_moved());
|
||||
BOOST_TEST(cb1.size() == 1);
|
||||
var = boost::move(cb1.back());
|
||||
BOOST_TEST(cb1.back().is_moved());
|
||||
|
||||
cb1.push_front(boost::move(var));
|
||||
BOOST_TEST(!cb1.front().is_moved());
|
||||
BOOST_TEST(var.is_moved());
|
||||
BOOST_TEST(cb1.size() == 1);
|
||||
var = boost::move(cb1.back());
|
||||
BOOST_TEST(cb1.back().is_moved());
|
||||
|
||||
cb1.push_back();
|
||||
BOOST_TEST(!cb1.back().is_moved());
|
||||
BOOST_TEST(cb1.size() == 1);
|
||||
var = boost::move(cb1.back());
|
||||
BOOST_TEST(cb1.back().is_moved());
|
||||
|
||||
cb1.push_front();
|
||||
BOOST_TEST(!cb1.front().is_moved());
|
||||
BOOST_TEST(cb1.size() == 1);
|
||||
var = boost::move(cb1.back());
|
||||
BOOST_TEST(cb1.back().is_moved());
|
||||
|
||||
|
||||
cb1.insert(cb1.begin());
|
||||
// If the circular_buffer is full and the pos points to begin(),
|
||||
// then the item will not be inserted.
|
||||
BOOST_TEST(cb1.front().is_moved());
|
||||
BOOST_TEST(cb1.size() == 1);
|
||||
var = boost::move(cb1.back());
|
||||
BOOST_TEST(cb1.back().is_moved());
|
||||
|
||||
cb1.insert(cb1.begin(), boost::move(var));
|
||||
// If the circular_buffer is full and the pos points to begin(),
|
||||
// then the item will not be inserted.
|
||||
BOOST_TEST(cb1.front().is_moved());
|
||||
BOOST_TEST(cb1.size() == 1);
|
||||
var = boost::move(cb1.back());
|
||||
BOOST_TEST(cb1.back().is_moved());
|
||||
|
||||
cb1.rinsert(cb1.begin());
|
||||
BOOST_TEST(!cb1.back().is_moved());
|
||||
BOOST_TEST(cb1.size() == 1);
|
||||
var = boost::move(cb1.back());
|
||||
BOOST_TEST(cb1.back().is_moved());
|
||||
|
||||
var.reinit();
|
||||
cb1.rinsert(cb1.begin(), boost::move(var));
|
||||
BOOST_TEST(!cb1.back().is_moved());
|
||||
BOOST_TEST(cb1.size() == 1);
|
||||
var = boost::move(cb1.back());
|
||||
BOOST_TEST(cb1.back().is_moved());
|
||||
|
||||
cb1.rinsert(cb1.end());
|
||||
BOOST_TEST(cb1.back().is_moved());
|
||||
BOOST_TEST(cb1.size() == 1);
|
||||
var = boost::move(cb1.back());
|
||||
BOOST_TEST(cb1.back().is_moved());
|
||||
|
||||
var.reinit();
|
||||
cb1.rinsert(cb1.end(), boost::move(var));
|
||||
BOOST_TEST(cb1.back().is_moved());
|
||||
BOOST_TEST(cb1.size() == 1);
|
||||
var = boost::move(cb1.back());
|
||||
BOOST_TEST(cb1.back().is_moved());
|
||||
cb1.push_back();
|
||||
BOOST_TEST(!cb1[0].is_moved());
|
||||
|
||||
const int val = cb1[0].value();
|
||||
cb1.linearize();
|
||||
BOOST_TEST(!cb1[0].is_moved());
|
||||
BOOST_TEST(cb1[0].value() == val);
|
||||
|
||||
cb1.rotate(cb1.begin());
|
||||
BOOST_TEST(!cb1[0].is_moved());
|
||||
BOOST_TEST(cb1[0].value() == val);
|
||||
}
|
||||
|
||||
void move_container_values_resetting_except() {
|
||||
move_container_values_resetting_impl<noncopyable_movable_except_t>();
|
||||
}
|
||||
|
||||
void move_container_values_resetting_noexcept() {
|
||||
move_container_values_resetting_impl<noncopyable_movable_noexcept_t>();
|
||||
}
|
||||
|
||||
// test main
|
||||
int main()
|
||||
{
|
||||
run_common_tests();
|
||||
iterator_constructor_and_assign_test();
|
||||
iterator_reference_test();
|
||||
iterator_difference_test();
|
||||
iterator_increment_test();
|
||||
iterator_decrement_test();
|
||||
iterator_addition_test();
|
||||
iterator_subtraction_test();
|
||||
iterator_element_access_test();
|
||||
iterator_comparison_test();
|
||||
iterator_invalidation_test();
|
||||
exception_safety_test();
|
||||
move_container_values_except();
|
||||
move_container_values_resetting_except();
|
||||
move_container_values_resetting_noexcept();
|
||||
return boost::report_errors();
|
||||
test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[]) {
|
||||
|
||||
test_suite* tests = BOOST_TEST_SUITE("Unit tests for the circular_buffer.");
|
||||
add_common_tests(tests);
|
||||
|
||||
tests->add(BOOST_TEST_CASE(&iterator_constructor_and_assign_test));
|
||||
tests->add(BOOST_TEST_CASE(&iterator_reference_test));
|
||||
tests->add(BOOST_TEST_CASE(&iterator_difference_test));
|
||||
tests->add(BOOST_TEST_CASE(&iterator_increment_test));
|
||||
tests->add(BOOST_TEST_CASE(&iterator_decrement_test));
|
||||
tests->add(BOOST_TEST_CASE(&iterator_addition_test));
|
||||
tests->add(BOOST_TEST_CASE(&iterator_subtraction_test));
|
||||
tests->add(BOOST_TEST_CASE(&iterator_element_access_test));
|
||||
tests->add(BOOST_TEST_CASE(&iterator_comparison_test));
|
||||
tests->add(BOOST_TEST_CASE(&iterator_invalidation_test));
|
||||
tests->add(BOOST_TEST_CASE(&exception_safety_test));
|
||||
|
||||
return tests;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
// Comparison of bounded buffers based on different containers.
|
||||
|
||||
// Copyright (c) 2003-2008 Jan Gaspar
|
||||
// Copyright 2013 Paul A. Bristow. Added some Quickbook snippet markers.
|
||||
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#define BOOST_CB_DISABLE_DEBUG
|
||||
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/condition_variable.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>
|
||||
@@ -34,7 +35,7 @@ public:
|
||||
explicit bounded_buffer(size_type capacity) : m_unread(0), m_container(capacity) {}
|
||||
|
||||
void push_front(param_type item) {
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
++m_unread;
|
||||
@@ -43,7 +44,7 @@ public:
|
||||
}
|
||||
|
||||
void pop_back(value_type* pItem) {
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_empty.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_empty, this));
|
||||
*pItem = m_container[--m_unread];
|
||||
lock.unlock();
|
||||
@@ -60,8 +61,8 @@ private:
|
||||
size_type m_unread;
|
||||
container_type m_container;
|
||||
boost::mutex m_mutex;
|
||||
boost::condition_variable m_not_empty;
|
||||
boost::condition_variable m_not_full;
|
||||
boost::condition m_not_empty;
|
||||
boost::condition m_not_full;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
@@ -76,7 +77,7 @@ public:
|
||||
explicit bounded_buffer_space_optimized(size_type capacity) : m_container(capacity) {}
|
||||
|
||||
void push_front(param_type item) {
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer_space_optimized<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
lock.unlock();
|
||||
@@ -84,7 +85,7 @@ public:
|
||||
}
|
||||
|
||||
void pop_back(value_type* pItem) {
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_empty.wait(lock, boost::bind(&bounded_buffer_space_optimized<value_type>::is_not_empty, this));
|
||||
*pItem = m_container.back();
|
||||
m_container.pop_back();
|
||||
@@ -102,8 +103,8 @@ private:
|
||||
|
||||
container_type m_container;
|
||||
boost::mutex m_mutex;
|
||||
boost::condition_variable m_not_empty;
|
||||
boost::condition_variable m_not_full;
|
||||
boost::condition m_not_empty;
|
||||
boost::condition m_not_full;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
@@ -118,7 +119,7 @@ public:
|
||||
explicit bounded_buffer_deque_based(size_type capacity) : m_capacity(capacity) {}
|
||||
|
||||
void push_front(param_type item) {
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer_deque_based<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
lock.unlock();
|
||||
@@ -126,7 +127,7 @@ public:
|
||||
}
|
||||
|
||||
void pop_back(value_type* pItem) {
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_empty.wait(lock, boost::bind(&bounded_buffer_deque_based<value_type>::is_not_empty, this));
|
||||
*pItem = m_container.back();
|
||||
m_container.pop_back();
|
||||
@@ -145,8 +146,8 @@ private:
|
||||
const size_type m_capacity;
|
||||
container_type m_container;
|
||||
boost::mutex m_mutex;
|
||||
boost::condition_variable m_not_empty;
|
||||
boost::condition_variable m_not_full;
|
||||
boost::condition m_not_empty;
|
||||
boost::condition m_not_full;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
@@ -161,7 +162,7 @@ public:
|
||||
explicit bounded_buffer_list_based(size_type capacity) : m_capacity(capacity) {}
|
||||
|
||||
void push_front(param_type item) {
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_full.wait(lock, boost::bind(&bounded_buffer_list_based<value_type>::is_not_full, this));
|
||||
m_container.push_front(item);
|
||||
lock.unlock();
|
||||
@@ -169,7 +170,7 @@ public:
|
||||
}
|
||||
|
||||
void pop_back(value_type* pItem) {
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
boost::mutex::scoped_lock lock(m_mutex);
|
||||
m_not_empty.wait(lock, boost::bind(&bounded_buffer_list_based<value_type>::is_not_empty, this));
|
||||
*pItem = m_container.back();
|
||||
m_container.pop_back();
|
||||
@@ -188,8 +189,8 @@ private:
|
||||
const size_type m_capacity;
|
||||
container_type m_container;
|
||||
boost::mutex m_mutex;
|
||||
boost::condition_variable m_not_empty;
|
||||
boost::condition_variable m_not_full;
|
||||
boost::condition m_not_empty;
|
||||
boost::condition m_not_full;
|
||||
};
|
||||
|
||||
template<class Buffer>
|
||||
@@ -229,7 +230,7 @@ template<class Buffer>
|
||||
void fifo_test(Buffer* buffer) {
|
||||
|
||||
// Start of measurement
|
||||
boost::timer::auto_cpu_timer progress;
|
||||
boost::progress_timer progress;
|
||||
|
||||
// Initialize the buffer with some values before launching producer and consumer threads.
|
||||
for (unsigned long i = QUEUE_SIZE / 2L; i > 0; --i) {
|
||||
@@ -290,27 +291,3 @@ int main(int /*argc*/, char* /*argv*/[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
|
||||
//[bounded_buffer_comparison_output
|
||||
|
||||
Description: Autorun "J:\Cpp\Misc\Debug\bounded_buffer_comparison.exe"
|
||||
bounded_buffer<int> 5.15 s
|
||||
|
||||
bounded_buffer_space_optimized<int> 5.71 s
|
||||
|
||||
bounded_buffer_deque_based<int> 15.57 s
|
||||
|
||||
bounded_buffer_list_based<int> 17.33 s
|
||||
|
||||
bounded_buffer<std::string> 24.49 s
|
||||
|
||||
bounded_buffer_space_optimized<std::string> 28.33 s
|
||||
|
||||
bounded_buffer_deque_based<std::string> 29.45 s
|
||||
|
||||
bounded_buffer_list_based<std::string> 31.29 s
|
||||
|
||||
//] //[bounded_buffer_comparison_output]
|
||||
|
||||
*/
|
||||
|
||||
1862
test/common.ipp
1862
test/common.ipp
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,8 @@
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#define BOOST_CB_DISABLE_DEBUG
|
||||
|
||||
#include "test.hpp"
|
||||
|
||||
int MyInteger::ms_exception_trigger = 0;
|
||||
@@ -25,35 +27,35 @@ void erase_begin_test() {
|
||||
|
||||
cb1.erase_begin(2);
|
||||
|
||||
BOOST_TEST(cb1.size() == 3);
|
||||
BOOST_TEST(cb1[0] == 4);
|
||||
BOOST_TEST(cb1[1] == 5);
|
||||
BOOST_TEST(cb1[2] == 6);
|
||||
BOOST_CHECK(cb1.size() == 3);
|
||||
BOOST_CHECK(cb1[0] == 4);
|
||||
BOOST_CHECK(cb1[1] == 5);
|
||||
BOOST_CHECK(cb1[2] == 6);
|
||||
|
||||
cb1.erase_begin(3);
|
||||
BOOST_TEST(cb1.empty());
|
||||
BOOST_TEST(*p == 2);
|
||||
BOOST_TEST(*(p + 1) == 3);
|
||||
BOOST_TEST(*(p + 2) == 4);
|
||||
BOOST_CHECK(cb1.empty());
|
||||
BOOST_CHECK(*p == 2);
|
||||
BOOST_CHECK(*(p + 1) == 3);
|
||||
BOOST_CHECK(*(p + 2) == 4);
|
||||
|
||||
cb1.push_back(10);
|
||||
cb1.push_back(11);
|
||||
cb1.push_back(12);
|
||||
|
||||
BOOST_TEST(cb1.size() == 3);
|
||||
BOOST_TEST(cb1[0] == 10);
|
||||
BOOST_TEST(cb1[1] == 11);
|
||||
BOOST_TEST(cb1[2] == 12);
|
||||
BOOST_CHECK(cb1.size() == 3);
|
||||
BOOST_CHECK(cb1[0] == 10);
|
||||
BOOST_CHECK(cb1[1] == 11);
|
||||
BOOST_CHECK(cb1[2] == 12);
|
||||
|
||||
circular_buffer<InstanceCounter> cb2(5, InstanceCounter());
|
||||
|
||||
BOOST_TEST(cb2.size() == 5);
|
||||
BOOST_TEST(InstanceCounter::count() == 5);
|
||||
BOOST_CHECK(cb2.size() == 5);
|
||||
BOOST_CHECK(InstanceCounter::count() == 5);
|
||||
|
||||
cb2.erase_begin(2);
|
||||
|
||||
BOOST_TEST(cb2.size() == 3);
|
||||
BOOST_TEST(InstanceCounter::count() == 3);
|
||||
BOOST_CHECK(cb2.size() == 3);
|
||||
BOOST_CHECK(InstanceCounter::count() == 3);
|
||||
|
||||
circular_buffer<MyInteger> cb3(5);
|
||||
cb3.push_back(1);
|
||||
@@ -64,10 +66,10 @@ void erase_begin_test() {
|
||||
cb3.push_back(6);
|
||||
cb3.erase_begin(2);
|
||||
|
||||
BOOST_TEST(cb3.size() == 3);
|
||||
BOOST_TEST(cb3[0] == 4);
|
||||
BOOST_TEST(cb3[1] == 5);
|
||||
BOOST_TEST(cb3[2] == 6);
|
||||
BOOST_CHECK(cb3.size() == 3);
|
||||
BOOST_CHECK(cb3[0] == 4);
|
||||
BOOST_CHECK(cb3[1] == 5);
|
||||
BOOST_CHECK(cb3[2] == 6);
|
||||
}
|
||||
|
||||
void erase_end_test() {
|
||||
@@ -84,35 +86,35 @@ void erase_end_test() {
|
||||
|
||||
cb1.erase_end(2);
|
||||
|
||||
BOOST_TEST(cb1.size() == 3);
|
||||
BOOST_TEST(cb1[0] == 2);
|
||||
BOOST_TEST(cb1[1] == 3);
|
||||
BOOST_TEST(cb1[2] ==4);
|
||||
BOOST_CHECK(cb1.size() == 3);
|
||||
BOOST_CHECK(cb1[0] == 2);
|
||||
BOOST_CHECK(cb1[1] == 3);
|
||||
BOOST_CHECK(cb1[2] ==4);
|
||||
|
||||
cb1.erase_end(3);
|
||||
BOOST_TEST(cb1.empty());
|
||||
BOOST_TEST(*p == 5);
|
||||
BOOST_TEST(*(p - 1) == 4);
|
||||
BOOST_TEST(*(p - 2) == 3);
|
||||
BOOST_CHECK(cb1.empty());
|
||||
BOOST_CHECK(*p == 5);
|
||||
BOOST_CHECK(*(p - 1) == 4);
|
||||
BOOST_CHECK(*(p - 2) == 3);
|
||||
|
||||
cb1.push_back(10);
|
||||
cb1.push_back(11);
|
||||
cb1.push_back(12);
|
||||
|
||||
BOOST_TEST(cb1.size() == 3);
|
||||
BOOST_TEST(cb1[0] == 10);
|
||||
BOOST_TEST(cb1[1] == 11);
|
||||
BOOST_TEST(cb1[2] == 12);
|
||||
BOOST_CHECK(cb1.size() == 3);
|
||||
BOOST_CHECK(cb1[0] == 10);
|
||||
BOOST_CHECK(cb1[1] == 11);
|
||||
BOOST_CHECK(cb1[2] == 12);
|
||||
|
||||
circular_buffer<InstanceCounter> cb2(5, InstanceCounter());
|
||||
|
||||
BOOST_TEST(cb2.size() == 5);
|
||||
BOOST_TEST(InstanceCounter::count() == 5);
|
||||
BOOST_CHECK(cb2.size() == 5);
|
||||
BOOST_CHECK(InstanceCounter::count() == 5);
|
||||
|
||||
cb2.erase_end(2);
|
||||
|
||||
BOOST_TEST(cb2.size() == 3);
|
||||
BOOST_TEST(InstanceCounter::count() == 3);
|
||||
BOOST_CHECK(cb2.size() == 3);
|
||||
BOOST_CHECK(InstanceCounter::count() == 3);
|
||||
|
||||
circular_buffer<MyInteger> cb3(5);
|
||||
cb3.push_back(1);
|
||||
@@ -123,10 +125,10 @@ void erase_end_test() {
|
||||
cb3.push_back(6);
|
||||
cb3.erase_end(2);
|
||||
|
||||
BOOST_TEST(cb3.size() == 3);
|
||||
BOOST_TEST(cb3[0] == 2);
|
||||
BOOST_TEST(cb3[1] == 3);
|
||||
BOOST_TEST(cb3[2] == 4);
|
||||
BOOST_CHECK(cb3.size() == 3);
|
||||
BOOST_CHECK(cb3[0] == 2);
|
||||
BOOST_CHECK(cb3[1] == 3);
|
||||
BOOST_CHECK(cb3[2] == 4);
|
||||
}
|
||||
|
||||
void clear_test() {
|
||||
@@ -143,22 +145,22 @@ void clear_test() {
|
||||
|
||||
cb1.clear();
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
circular_buffer<InstanceCounter> cb2(5, InstanceCounter());
|
||||
|
||||
BOOST_TEST(cb2.size() == 5);
|
||||
BOOST_TEST(InstanceCounter::count() == 5);
|
||||
BOOST_CHECK(cb2.size() == 5);
|
||||
BOOST_CHECK(InstanceCounter::count() == 5);
|
||||
|
||||
cb2.clear();
|
||||
|
||||
BOOST_TEST(cb2.empty());
|
||||
BOOST_TEST(InstanceCounter::count() == 0);
|
||||
BOOST_CHECK(cb2.empty());
|
||||
BOOST_CHECK(InstanceCounter::count() == 0);
|
||||
|
||||
circular_buffer<MyInteger> cb3(5);
|
||||
cb3.push_back(1);
|
||||
@@ -169,14 +171,17 @@ void clear_test() {
|
||||
cb3.push_back(6);
|
||||
cb3.clear();
|
||||
|
||||
BOOST_TEST(cb3.empty());
|
||||
BOOST_CHECK(cb3.empty());
|
||||
}
|
||||
|
||||
// test main
|
||||
int main()
|
||||
{
|
||||
erase_begin_test();
|
||||
erase_end_test();
|
||||
clear_test();
|
||||
return boost::report_errors();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#define BOOST_CB_DISABLE_DEBUG
|
||||
|
||||
#include "test.hpp"
|
||||
|
||||
// test of the example (introduced in the documentation)
|
||||
@@ -22,11 +24,11 @@ void validity_example_test() {
|
||||
|
||||
circular_buffer<int>::iterator it = cb.begin();
|
||||
|
||||
BOOST_TEST(*it == 1);
|
||||
BOOST_CHECK(*it == 1);
|
||||
|
||||
cb.push_back(4);
|
||||
|
||||
BOOST_TEST(*it == 4);
|
||||
BOOST_CHECK(*it == 4);
|
||||
}
|
||||
|
||||
void validity_insert_test() {
|
||||
@@ -46,13 +48,13 @@ void validity_insert_test() {
|
||||
|
||||
// memory placement: { 1, 4, 2, 3 }
|
||||
// circular buffer: { 1, 4, 2, 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);
|
||||
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);
|
||||
|
||||
// it4 -> 3
|
||||
circular_buffer<int>::iterator it4 = it1 + 3;
|
||||
@@ -61,14 +63,14 @@ void validity_insert_test() {
|
||||
|
||||
// memory placement: { 3, 5, 4, 2 }
|
||||
// circular buffer: { 5, 4, 2, 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);
|
||||
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);
|
||||
}
|
||||
|
||||
void validity_insert_n_test() {
|
||||
@@ -89,14 +91,14 @@ void validity_insert_n_test() {
|
||||
|
||||
// memory placement: { 1, 4, 4, 2, 3 }
|
||||
// circular buffer: { 1, 4, 4, 2, 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);
|
||||
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);
|
||||
|
||||
// it4 -> 2, it5 -> 3
|
||||
circular_buffer<int>::iterator it4 = it1 + 3;
|
||||
@@ -106,16 +108,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_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);
|
||||
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);
|
||||
}
|
||||
|
||||
void validity_insert_range_test() {
|
||||
@@ -145,14 +147,14 @@ void validity_insert_range_test() {
|
||||
|
||||
// memory placement: { 1, 4, 5, 2, 3 }
|
||||
// circular buffer: { 1, 4, 5, 2, 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);
|
||||
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);
|
||||
|
||||
// it14 -> 2, it15 -> 3
|
||||
circular_buffer<int>::iterator it14 = it11 + 3;
|
||||
@@ -162,16 +164,16 @@ void validity_insert_range_test() {
|
||||
|
||||
// memory placement: { 3, 7, 4, 5, 2 } - 7 inserted only
|
||||
// circular buffer: { 7, 4, 5, 2, 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);
|
||||
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);
|
||||
|
||||
// memory placement: { 1, 2, 3 }
|
||||
// circular buffer: { 1, 2, 3 }
|
||||
@@ -189,14 +191,14 @@ void validity_insert_range_test() {
|
||||
|
||||
// memory placement: { 1, 4, 5, 2, 3 }
|
||||
// circular buffer: { 1, 4, 5, 2, 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);
|
||||
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);
|
||||
|
||||
// it24 -> 2, it25 -> 3
|
||||
circular_buffer<int>::iterator it24 = it21 + 3;
|
||||
@@ -206,16 +208,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_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);
|
||||
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);
|
||||
}
|
||||
|
||||
void validity_rinsert_test() {
|
||||
@@ -235,13 +237,13 @@ void validity_rinsert_test() {
|
||||
|
||||
// memory placement: { 2, 4, 3, 1 }
|
||||
// circular buffer: { 1, 2, 4, 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);
|
||||
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);
|
||||
|
||||
// it4 -> 1
|
||||
circular_buffer<int>::iterator it4 = it1 - 1;
|
||||
@@ -250,14 +252,14 @@ void validity_rinsert_test() {
|
||||
|
||||
// memory placement: { 5, 4, 1, 2 }
|
||||
// circular buffer: { 1, 2, 5, 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);
|
||||
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);
|
||||
}
|
||||
|
||||
void validity_rinsert_n_test() {
|
||||
@@ -278,14 +280,14 @@ void validity_rinsert_n_test() {
|
||||
|
||||
// memory placement: { 4, 4, 3, 1, 2 }
|
||||
// circular buffer: { 1, 2, 4, 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);
|
||||
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);
|
||||
|
||||
// it4 -> 1, it5 -> 2
|
||||
circular_buffer<int>::iterator it4 = it1 - 2;
|
||||
@@ -295,16 +297,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_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);
|
||||
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);
|
||||
}
|
||||
|
||||
void validity_rinsert_range_test() {
|
||||
@@ -334,14 +336,14 @@ void validity_rinsert_range_test() {
|
||||
|
||||
// memory placement: { 4, 5, 3, 1, 2 }
|
||||
// circular buffer: { 1, 2, 4, 5, 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);
|
||||
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);
|
||||
|
||||
// it14 -> 1, it15 -> 2
|
||||
circular_buffer<int>::iterator it14 = it11 - 2;
|
||||
@@ -351,16 +353,16 @@ void validity_rinsert_range_test() {
|
||||
|
||||
// memory placement: { 5, 6, 1, 2, 4 } - 6 inserted only
|
||||
// circular buffer: { 1, 2, 4, 5, 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);
|
||||
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);
|
||||
|
||||
// memory placement: { 1, 2, 3 }
|
||||
// circular buffer: { 1, 2, 3 }
|
||||
@@ -378,14 +380,14 @@ void validity_rinsert_range_test() {
|
||||
|
||||
// memory placement: { 4, 5, 3, 1, 2 }
|
||||
// circular buffer: { 1, 2, 4, 5, 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);
|
||||
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);
|
||||
|
||||
// it24 -> 1, it25 -> 2
|
||||
circular_buffer<int>::iterator it24 = it21 - 2;
|
||||
@@ -395,16 +397,16 @@ void validity_rinsert_range_test() {
|
||||
|
||||
// memory placement: { 5, 6, 1, 2, 4 }
|
||||
// circular buffer: { 1, 2, 4, 5, 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);
|
||||
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);
|
||||
}
|
||||
|
||||
void validity_erase_test() {
|
||||
@@ -430,14 +432,14 @@ void validity_erase_test() {
|
||||
|
||||
// memory placement: { 5, X, 1, 3, 4 }
|
||||
// circular buffer: { 1, 3, 4, 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);
|
||||
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);
|
||||
}
|
||||
|
||||
void validity_erase_range_test() {
|
||||
@@ -465,14 +467,14 @@ void validity_erase_range_test() {
|
||||
|
||||
// memory placement: { 6, X, X, 1, 2, 5 }
|
||||
// circular buffer: { 1, 2, 5, 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);
|
||||
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);
|
||||
}
|
||||
|
||||
void validity_rerase_test() {
|
||||
@@ -498,14 +500,14 @@ void validity_rerase_test() {
|
||||
|
||||
// memory placement: { 4, 5, X, 1, 3 }
|
||||
// circular buffer: { 1, 3, 4, 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);
|
||||
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);
|
||||
}
|
||||
|
||||
void validity_rerase_range_test() {
|
||||
@@ -533,14 +535,14 @@ void validity_rerase_range_test() {
|
||||
|
||||
// memory placement: { 2, 5, 6, X, X, 1 }
|
||||
// circular buffer: { 1, 2, 5, 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);
|
||||
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);
|
||||
}
|
||||
|
||||
void validity_linearize_test() {
|
||||
@@ -562,12 +564,12 @@ void validity_linearize_test() {
|
||||
|
||||
// memory placement: { 1, 2, 3 }
|
||||
// circular buffer: { 1, 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);
|
||||
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);
|
||||
}
|
||||
|
||||
void validity_swap_test() {
|
||||
@@ -600,20 +602,20 @@ void validity_swap_test() {
|
||||
cb1.swap(cb2);
|
||||
|
||||
// Although iterators refer to the original elements,
|
||||
// their internal state is inconsistent and no other operation
|
||||
// their interal state is inconsistent and no other operation
|
||||
// (except dereferencing) can be invoked on them any more.
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
void validity_push_back_test() {
|
||||
@@ -635,12 +637,12 @@ void validity_push_back_test() {
|
||||
|
||||
// memory placement: { 3, 4, 2 }
|
||||
// circular buffer: { 2, 3, 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);
|
||||
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);
|
||||
}
|
||||
|
||||
void validity_push_front_test() {
|
||||
@@ -662,12 +664,12 @@ void validity_push_front_test() {
|
||||
|
||||
// memory placement: { 4, 1, 2 }
|
||||
// circular buffer: { 4, 1, 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);
|
||||
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);
|
||||
}
|
||||
|
||||
void validity_pop_back_test() {
|
||||
@@ -688,10 +690,10 @@ void validity_pop_back_test() {
|
||||
|
||||
// memory placement: { X, 1, 2 }
|
||||
// circular buffer: { 1, 2 }
|
||||
BOOST_TEST(*it1 == 1);
|
||||
BOOST_TEST(*it2 == 2);
|
||||
BOOST_TEST(cb[0] == 1);
|
||||
BOOST_TEST(cb[1] == 2);
|
||||
BOOST_CHECK(*it1 == 1);
|
||||
BOOST_CHECK(*it2 == 2);
|
||||
BOOST_CHECK(cb[0] == 1);
|
||||
BOOST_CHECK(cb[1] == 2);
|
||||
}
|
||||
|
||||
void validity_pop_front_test() {
|
||||
@@ -712,31 +714,34 @@ void validity_pop_front_test() {
|
||||
|
||||
// memory placement: { 3, X, 2 }
|
||||
// circular buffer: { 2, 3 }
|
||||
BOOST_TEST(*it1 == 2);
|
||||
BOOST_TEST(*it2 == 3);
|
||||
BOOST_TEST(cb[0] == 2);
|
||||
BOOST_TEST(cb[1] == 3);
|
||||
BOOST_CHECK(*it1 == 2);
|
||||
BOOST_CHECK(*it2 == 3);
|
||||
BOOST_CHECK(cb[0] == 2);
|
||||
BOOST_CHECK(cb[1] == 3);
|
||||
}
|
||||
|
||||
// test main
|
||||
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();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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_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());
|
||||
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());
|
||||
|
||||
cb2.erase(cb2.begin() + 2, cb2.end());
|
||||
|
||||
BOOST_TEST(cb2.size() == 2);
|
||||
BOOST_TEST(cb2.capacity().min_capacity() <= cb2.internal_capacity());
|
||||
BOOST_CHECK(cb2.size() == 2);
|
||||
BOOST_CHECK(cb2.capacity().min_capacity() <= cb2.internal_capacity());
|
||||
|
||||
cb2.clear();
|
||||
cb3.clear();
|
||||
|
||||
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());
|
||||
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());
|
||||
}
|
||||
|
||||
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_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);
|
||||
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);
|
||||
|
||||
c1 = c2;
|
||||
|
||||
BOOST_TEST(c1.capacity() == 20);
|
||||
BOOST_TEST(c1.min_capacity() == 5);
|
||||
BOOST_CHECK(c1.capacity() == 20);
|
||||
BOOST_CHECK(c1.min_capacity() == 5);
|
||||
}
|
||||
|
||||
void specific_constructors_test() {
|
||||
|
||||
cb_space_optimized cb1;
|
||||
BOOST_TEST(cb1.capacity() == 0);
|
||||
BOOST_TEST(cb1.capacity().min_capacity() == 0);
|
||||
BOOST_TEST(cb1.internal_capacity() == 0);
|
||||
BOOST_TEST(cb1.size() == 0);
|
||||
BOOST_CHECK(cb1.capacity() == 0);
|
||||
BOOST_CHECK(cb1.capacity().min_capacity() == 0);
|
||||
BOOST_CHECK(cb1.internal_capacity() == 0);
|
||||
BOOST_CHECK(cb1.size() == 0);
|
||||
|
||||
cb1.push_back(1);
|
||||
cb1.push_back(2);
|
||||
cb1.push_back(3);
|
||||
|
||||
BOOST_TEST(cb1.size() == 0);
|
||||
BOOST_TEST(cb1.capacity() == 0);
|
||||
BOOST_CHECK(cb1.size() == 0);
|
||||
BOOST_CHECK(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_TEST(cb2.capacity() == 3);
|
||||
BOOST_TEST(cb2.capacity().min_capacity() == 0);
|
||||
BOOST_TEST(cb2.size() == 3);
|
||||
BOOST_CHECK(cb2.capacity() == 3);
|
||||
BOOST_CHECK(cb2.capacity().min_capacity() == 0);
|
||||
BOOST_CHECK(cb2.size() == 3);
|
||||
}
|
||||
|
||||
void shrink_to_fit_test() {
|
||||
@@ -112,20 +112,20 @@ void shrink_to_fit_test() {
|
||||
cb.push_back(2);
|
||||
cb.push_back(3);
|
||||
|
||||
BOOST_TEST(cb.size() == 3);
|
||||
BOOST_TEST(cb.capacity() == 1000);
|
||||
BOOST_CHECK(cb.size() == 3);
|
||||
BOOST_CHECK(cb.capacity() == 1000);
|
||||
|
||||
size_t internal_capacity = cb.internal_capacity();
|
||||
cb_space_optimized(cb).swap(cb);
|
||||
|
||||
BOOST_TEST(cb.size() == 3);
|
||||
BOOST_TEST(cb.capacity() == 1000);
|
||||
BOOST_TEST(internal_capacity >= cb.internal_capacity());
|
||||
BOOST_CHECK(cb.size() == 3);
|
||||
BOOST_CHECK(cb.capacity() == 1000);
|
||||
BOOST_CHECK(internal_capacity >= cb.internal_capacity());
|
||||
}
|
||||
|
||||
void iterator_invalidation_test() {
|
||||
|
||||
#if BOOST_CB_ENABLE_DEBUG
|
||||
#if !defined(NDEBUG) && !defined(BOOST_CB_DISABLE_DEBUG)
|
||||
|
||||
cb_space_optimized cb1(10, 1);
|
||||
cb1.push_back(2);
|
||||
@@ -136,33 +136,33 @@ void iterator_invalidation_test() {
|
||||
cb_space_optimized::iterator it3 = cb1.begin() + 6;
|
||||
|
||||
cb1.set_capacity(10);
|
||||
BOOST_TEST(it1.is_valid(&cb1));
|
||||
BOOST_TEST(!it2.is_valid(&cb1));
|
||||
BOOST_TEST(!it3.is_valid(&cb1));
|
||||
BOOST_CHECK(it1.is_valid(&cb1));
|
||||
BOOST_CHECK(!it2.is_valid(&cb1));
|
||||
BOOST_CHECK(!it3.is_valid(&cb1));
|
||||
|
||||
it1 = cb1.end();
|
||||
it2 = cb1.begin();
|
||||
it3 = cb1.begin() + 6;
|
||||
cb1.rset_capacity(10);
|
||||
BOOST_TEST(it1.is_valid(&cb1));
|
||||
BOOST_TEST(!it2.is_valid(&cb1));
|
||||
BOOST_TEST(!it3.is_valid(&cb1));
|
||||
BOOST_CHECK(it1.is_valid(&cb1));
|
||||
BOOST_CHECK(!it2.is_valid(&cb1));
|
||||
BOOST_CHECK(!it3.is_valid(&cb1));
|
||||
|
||||
it1 = cb1.end();
|
||||
it2 = cb1.begin();
|
||||
it3 = cb1.begin() + 6;
|
||||
cb1.resize(10);
|
||||
BOOST_TEST(it1.is_valid(&cb1));
|
||||
BOOST_TEST(!it2.is_valid(&cb1));
|
||||
BOOST_TEST(!it3.is_valid(&cb1));
|
||||
BOOST_CHECK(it1.is_valid(&cb1));
|
||||
BOOST_CHECK(!it2.is_valid(&cb1));
|
||||
BOOST_CHECK(!it3.is_valid(&cb1));
|
||||
|
||||
it1 = cb1.end();
|
||||
it2 = cb1.begin();
|
||||
it3 = cb1.begin() + 6;
|
||||
cb1.rresize(10);
|
||||
BOOST_TEST(it1.is_valid(&cb1));
|
||||
BOOST_TEST(!it2.is_valid(&cb1));
|
||||
BOOST_TEST(!it3.is_valid(&cb1));
|
||||
BOOST_CHECK(it1.is_valid(&cb1));
|
||||
BOOST_CHECK(!it2.is_valid(&cb1));
|
||||
BOOST_CHECK(!it3.is_valid(&cb1));
|
||||
|
||||
{
|
||||
cb_space_optimized cb2(10, 1);
|
||||
@@ -173,21 +173,24 @@ void iterator_invalidation_test() {
|
||||
it2 = cb2.begin();
|
||||
it3 = cb2.begin() + 6;
|
||||
}
|
||||
BOOST_TEST(!it1.is_valid(&cb1));
|
||||
BOOST_TEST(!it2.is_valid(&cb1));
|
||||
BOOST_TEST(!it3.is_valid(&cb1));
|
||||
BOOST_CHECK(!it1.is_valid(&cb1));
|
||||
BOOST_CHECK(!it2.is_valid(&cb1));
|
||||
BOOST_CHECK(!it3.is_valid(&cb1));
|
||||
|
||||
#endif // #if BOOST_CB_ENABLE_DEBUG
|
||||
#endif // #if !defined(NDEBUG) && !defined(BOOST_CB_DISABLE_DEBUG)
|
||||
}
|
||||
|
||||
// test main
|
||||
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();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
#define BOOST_CB_TEST
|
||||
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/test/included/unit_test_framework.hpp>
|
||||
#include <boost/iterator.hpp>
|
||||
#include <iterator>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
@@ -89,7 +90,6 @@ 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,9 +97,9 @@ public:
|
||||
};
|
||||
|
||||
// simulator of an input iterator
|
||||
struct MyInputIterator {
|
||||
struct MyInputIterator
|
||||
: boost::iterator<std::input_iterator_tag, int, ptrdiff_t, int*, int&> {
|
||||
typedef std::vector<int>::iterator vector_iterator;
|
||||
typedef std::input_iterator_tag iterator_category;
|
||||
typedef int value_type;
|
||||
typedef int* pointer;
|
||||
typedef int& reference;
|
||||
@@ -139,6 +139,7 @@ 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