Compare commits

...

107 Commits

Author SHA1 Message Date
05e0d1688d Re-enabled 32-bit clang-win AppVeyor job on VS2019 image.
32-bit clang does not fail with the mspdb error on the VS2019 image.
Apply the same env script workaround as for the 64-bit clang.
2021-10-10 13:59:26 +03:00
dcaf2c0e3b Fixed a typo in AppVeyor config. 2021-10-10 00:18:35 +03:00
71107238eb Call env setup script to work around missing msvcrt.lib errors with clang-win. 2021-10-10 00:08:03 +03:00
28c90abaf0 Try switching clang-win to VS2019 image.
This is an attempt to work around the missing msvcrt(d).lib linking errors.
2021-10-09 20:32:03 +03:00
2cc83cc7d5 Added MinGW-w64 gcc 8.1 job to AppVeyor. 2021-10-09 20:31:48 +03:00
e8fc7cc2a1 Disabled 32-bit clang-win in AppVeyor because of "unable to load mspdbcore.dll" errors. 2021-10-09 11:18:24 +03:00
09d24c0516 Fixed git version check on Mac OS. 2021-09-26 20:43:44 +03:00
3f51807f24 Disabled random operators tests under UBSAN.
The tests use random input to various arithmetic and bitwise operators,
which cause undefined behavior, such as shifting by more than the left
operand capacity or signed integer overflows.
2021-09-16 02:12:41 +03:00
a04a0d9531 Updated link to AppVeyor badge. 2021-09-15 22:18:17 +03:00
449a03e13d Updated README.md to replace Travis CI with GHA and add other links. 2021-09-15 21:43:31 +03:00
dc59afafdb Added GitHub Actions config. 2021-09-15 21:40:04 +03:00
e845ae6752 Removed Travis CI config.
Since Travis CI no longer runs free jobs for open source projects,
we are migrating to GitHub Actions instead.
2021-09-15 21:38:55 +03:00
375382e1e6 Merge pull request #67 from Kojoley/patch-1
Cease dependence on ContainerHash
2021-06-23 07:42:12 -07:00
6cca23a63a Cease dependence on ContainerHash
by local `hash_range` forward declaration
2021-06-20 19:34:05 +03:00
9ad7e51912 Update CMakeLists.txt 2021-06-10 00:45:51 +03:00
601f80e8c1 Merge pull request #75 from Kojoley/feature/result_of-variadic-templates
Use variadic templates in result_of
2021-04-22 23:12:34 +03:00
c960bef6ef Merge pull request #76 from vahtis/develop
Workaround for Oracle Developer Studio
2021-03-25 16:58:37 +01:00
6ab27d5689 Workaround for Oracle Developer Studio
Oracle Developer Studio needs same workaround as VIsual Studio
2021-03-25 11:32:37 +02:00
3e2f0199cf Use variadic templates in result_of 2021-03-08 04:25:46 +03:00
9c2aa8d193 Revert "Make string_{view|ref} remove_prefix and remove_suffix throw on invalid lengths. Addresses issue #73"
This reverts commit 601fc9371f.
2021-03-01 16:50:14 -08:00
601fc9371f Make string_{view|ref} remove_prefix and remove_suffix throw on invalid lengths. Addresses issue #73 2021-03-01 06:52:49 -08:00
7aafdf92a0 [skip ci] Merge pull request #71 from eldiener/develop
[skip ci] Add "cxxstd" json field
2021-01-20 11:18:10 +03:00
a7570d7608 [skip ci] Add "cxxstd" json field. The "cxxstd" json field is being added to each Boost library's meta json information for libraries in order to specify the minumum C++ standard compilation level. The value of this field matches one of the values for 'cxxstd' in Boost.Build. The purpose of doing this is to provide information for the Boost website documentation for each library which will specify the minimum C++ standard compilation that an end-user must employ in order to use the particular library. This will aid end-users who want to know if they can successfully use a Boost library based on their C++ compiler's compilation level, without having to search the library's documentation to find this out. 2021-01-19 22:19:49 -05:00
37168a3f4b Use address-model=32 for msvc-9.0, 10.0, 11.0 2020-10-12 00:01:10 +03:00
e56171989a Merge pull request #69 from giomasce-throwaway/develop
Fix copyright headers.
2020-10-11 11:48:14 -04:00
f00a5bf0d3 Fix copyright headers. 2020-10-11 17:35:14 +02:00
a4feaf4f24 Merge pull request #66 from boostorg/feature/value-init
Add a new value_init test, change implementation to not depend on TypeTraits
2020-05-27 12:51:45 +03:00
688628f764 Add test/value_init_test3 2020-05-26 00:39:51 +03:00
8faf831bd1 memset data_ instead of *this 2020-05-25 23:50:35 +03:00
25cb7aa122 Use a base class to apply the memset workaround to avoid dependency on TypeTraits 2020-05-25 05:09:36 +03:00
0ae5cebc7f Add value_init_test2.cpp, which tests the cases from value_init_workaround_test 2020-05-25 04:44:29 +03:00
1caa002121 Added gcc 10 build jobs to Travis CI. 2020-05-22 18:46:41 +03:00
691f3238d7 Use 20 instead of 2a to refer to C++20 in Travis CI. 2020-05-05 23:12:01 +03:00
8b6da499a3 Added clang-10 jobs to Travis CI. 2020-05-05 23:02:58 +03:00
6e6d0777e8 Merge pull request #64 from glenfe/develop
Update to Operators constexpr support
2020-04-12 13:33:17 -04:00
64fffa0f97 Simplify BOOST_OPERATORS_CONSTEXPR definition 2020-04-12 13:03:30 -04:00
5da340a2a4 Rename BOOST_OPS_CONSTEXPR to BOOST_OPERATORS_CONSTEXPR 2020-04-12 13:03:22 -04:00
9a4cff038b Move constexpr operators test to separate test 2020-04-12 13:03:18 -04:00
0c059a50ad Merge pull request #63 from eldiener/develop
Changes for Embarcadero C++ clang-based compilers, targeting Boost 1.74. Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost conf…
2020-04-12 09:49:06 -07:00
bdc5b5cf3a Merge pull request #55 from tonyelewis/add-constexpr-support
Add constexpr to operators (w/ basic docs, tests)
2020-04-12 13:07:24 +02:00
86e7caefea Update CMakeLists.txt 2020-04-11 14:14:33 -04:00
7953ba56ba Update tests to run constexpr on newer MSVCs 2020-04-11 18:39:15 +01:00
46f72656b3 Remove constexpr from all but the comparison ops 2020-04-11 18:31:15 +01:00
e3a2a06011 Re-add constexpr support for newer MSVC versions 2020-04-11 18:30:24 +01:00
a4752e066d Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers. 2020-03-24 01:39:51 -04:00
957aeba2e9 Update Travis and Appveyor configurations 2019-12-15 10:39:10 -05:00
2b436d7d50 Use ostream_put from Boost.IO 2019-12-15 09:46:38 -05:00
882c9c86c4 More detabification 2019-12-12 06:00:51 +02:00
c81d8e3990 Add <cstdio> for EOF; detabify, remove trailing whitespace 2019-12-12 05:57:51 +02:00
75276a055d Disabled all but one OS X jobs because they are slow on Travis CI. 2019-10-22 15:11:41 +03:00
309e6a1b31 Updated CI configs, added compilers. 2019-10-22 00:52:54 +03:00
9eeb7f85c5 Replaced tabs with spaces. 2019-06-25 15:46:36 +03:00
62c34f51f6 Avoid confusion with the spaceship operator, fixes #59 2019-04-30 18:29:28 +02:00
6a1917ceec Add Free Functions section heading 2019-04-29 20:12:30 -04:00
47c9f69ffe Correct documentation URLs and update documentation 2019-04-29 18:48:51 -04:00
7b74d2d494 Update libraries.json and documentation 2019-04-23 15:37:57 -04:00
57da5f0c18 Merge pull request #58 from boostorg/ostream_write
Refactor stream write functionality into a standalone utility
2019-04-23 03:56:04 -07:00
dabf53a703 Refactor stream write functionality into a standalone utility 2019-04-19 09:53:29 -04:00
ff56b3649e Merge pull request #57 from glenfe/develop
Make string_view operator<< use rdbuf directly
2019-04-18 09:00:53 -07:00
31e0ae4c37 Switch Appveyor to 2015 image 2019-04-14 18:13:56 +03:00
5fe9df91c0 Make string_view operator<< use rdbuf directly 2019-04-12 18:06:35 -04:00
f03b681d01 Increased the number of git fetch jobs to 8 in CI. 2019-01-15 18:34:38 +03:00
e120a83d1e Revert "Use depinst to install dependencies in CI. Increase the number of git fetch jobs to 8."
This reverts commit 424fea5881.

By request from Peter Dimov in 424fea5881 (commitcomment-31945411).

The manual enumeration of Boost.Utility dependencies server as a detection
mechanism for unwanted dependencies creep in.
2019-01-15 18:28:28 +03:00
424fea5881 Use depinst to install dependencies in CI. Increase the number of git fetch jobs to 8. 2019-01-15 14:06:11 +03:00
53d9aa9d2f Use the actual number of logical CPUs for the number of CI build/test jobs. 2019-01-03 23:23:55 +03:00
6b62dcc504 Completely remove constexpr for MSVC 2018-12-24 07:02:31 +00:00
91ebdcd1dd Remove C++14 constexpr due to MSVC/GCC problems 2018-12-22 15:52:13 +00:00
e8d2b2ba76 Add constexpr to operators (w/ basic docs, tests) 2018-12-21 10:28:22 +00:00
ce64b13846 Added tools/boost_install and libs/headers manual checkout to CI jobs. 2018-12-18 22:14:06 +03:00
32c50e0814 Added an experimental partial CMakeLists.txt for dependency tracking in CMake projects. 2018-12-18 19:51:11 +03:00
05dda09fd3 Added libstdc++5 installation in the clang 7 job.
Apparently, a more recent libstdc++ is needed by Boost.StringView in C++14
and later mode.
2018-11-02 12:12:15 +03:00
a4cafcc75d Added gcc 8 and clang 7 CI jobs. 2018-11-01 20:36:52 +03:00
796fb965be Merge branch 'develop' 2018-11-01 17:17:11 +03:00
08da98a551 Added a readme file.
For Boost.Utility logo thanks to Adam Wulkiewicz. The logo was taken from:

https://github.com/awulkiew/boost-logos
2018-11-01 17:09:34 +03:00
57b027f1cd Merge branch 'develop' 2018-09-23 08:47:11 -04:00
db05c11f50 Fix string_ref::find/rfind's handling of empty strings. Thanks to 'reluctantbugreporter' for the bug report 2018-09-14 09:48:13 -07:00
3d2a7f0c17 Merge pull request #49 from boostorg/final
Avoid inheritance for final types in compressed_pair
2018-09-12 22:29:26 -04:00
8858bad352 Merge pull request #38 from danieljames/feature/fix-links
Fix some links
2018-09-11 08:35:08 -04:00
fc135e0d72 Avoid inheritance for final types in compressed_pair 2018-09-09 17:34:22 -04:00
ebe44296ca Add boilerplate reference to LICENSE_1_0.txt 2018-07-31 01:46:53 +03:00
bdf55e0b6f Add boilerplate reference to LICENSE_1_0.txt 2018-07-31 00:22:42 +03:00
d4170ccdb5 Merge pull request #45 from dimztimz/develop
Implement boost hash for string_view
2018-05-01 07:51:36 -07:00
e2d115db97 Use hash_fwd.hpp in string_view for more lightweight dependencies. 2018-04-20 23:18:31 +02:00
15cfa44937 Boost detail is dependency of boost hash. 2018-04-20 14:07:33 +02:00
473be2e4c1 Boost integer is dependency of boost hash. 2018-04-20 13:58:12 +02:00
6ad6bc005c Implement boost hash for string_view 2018-04-20 13:42:07 +02:00
7709f0e430 Merge pull request #42 from dimztimz/develop
Faster find functions in string_view by using traits::find()
2018-04-09 16:34:23 -07:00
eacea4664d implement string_view.find(string) in terms of traits.compare and find.
This should be faster that it's previous implementations
in terms of std::search()
2018-04-02 00:52:57 +02:00
1fe5af5264 Faster find functions in string_view by using traits::find() 2018-04-01 20:00:03 +02:00
d2fb06e6a0 Fix another link 2018-01-12 10:48:52 +00:00
73baeb7a63 Fix some links 2018-01-11 18:01:50 +00:00
56f13625b1 Fix link to declval 2017-12-24 00:33:12 +02:00
ac4e8da91d Only install the necessary submodules in Travis and Appveyor 2017-12-24 00:28:06 +02:00
426836d860 Remove shared_iterator files (they're in Iterator now) 2017-12-24 00:05:50 +02:00
82df2b82fc Merge pull request #37 from glenfe/develop
Utility tests should use lightweight_test instead of test
2017-12-23 21:52:07 +02:00
f8a243bcff Utility tests should use lightweight_test instead of test 2017-12-23 13:00:33 -05:00
51f7f7f53e Add -d0 to b2 headers on Appveyor 2017-12-23 12:01:03 +02:00
5f535a151c Add -j3 to Travis 2017-12-23 11:56:09 +02:00
c88936800d Remove dependency on Random in operators_test.cpp 2017-12-23 06:19:43 +02:00
96fbce5759 Remove use of shared_ptr in test/value_init_test.cpp 2017-12-23 04:44:29 +02:00
9d46de1578 Replace use of mpl/has_xxx.hpp with handwritten traits 2017-12-21 06:30:03 +02:00
976a4d2fc1 Merge branch 'develop' into feature/result_of-no-mpl 2017-12-20 23:16:08 +02:00
ea81279b35 Add appveyor.yml 2017-12-20 23:14:36 +02:00
7d101d420c Replace mpl primitives with type_traits 2017-12-20 21:55:07 +02:00
d8acfef27b Update includes in utility.hpp; add deprecation comment 2017-12-02 04:35:22 +02:00
d7ae336915 Merge branch 'master' into develop 2017-12-02 03:47:03 +02:00
b74f49f1e5 Remove dependency on iterator in <boost/utility.hpp> 2017-12-02 03:38:29 +02:00
56 changed files with 2694 additions and 1679 deletions

424
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,424 @@
# Copyright 2021 Andrey Semashev
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
name: CI
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
concurrency:
group: ${{format('{0}:{1}', github.repository, github.ref)}}
cancel-in-progress: true
env:
GIT_FETCH_JOBS: 8
NET_RETRY_COUNT: 5
DEFAULT_BUILD_VARIANT: debug,release
jobs:
posix:
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
# Linux, gcc
- toolset: gcc-4.4
cxxstd: "98,0x"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- g++-4.4
sources:
- "ppa:ubuntu-toolchain-r/test"
- toolset: gcc-4.6
cxxstd: "03,0x"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- g++-4.6
sources:
- "ppa:ubuntu-toolchain-r/test"
- toolset: gcc-4.7
cxxstd: "03,11"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- g++-4.7
- toolset: gcc-4.8
cxxstd: "03,11"
os: ubuntu-18.04
install:
- g++-4.8
- toolset: gcc-4.9
cxxstd: "03,11"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- g++-4.9
- toolset: gcc-5
cxxstd: "03,11,14,1z"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- g++-5
- toolset: gcc-6
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install:
- g++-6
- toolset: gcc-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install:
- g++-7
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install:
- g++-8
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install:
- g++-9
- toolset: gcc-10
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install:
- g++-10
- toolset: gcc-11
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install:
- g++-11
sources:
- "ppa:ubuntu-toolchain-r/test"
- name: UBSAN
toolset: gcc-11
cxxstd: "03,11,14,17,20"
ubsan: 1
build_variant: debug
os: ubuntu-20.04
install:
- g++-11
sources:
- "ppa:ubuntu-toolchain-r/test"
# Linux, clang
- toolset: clang
compiler: clang++-3.5
cxxstd: "03,11"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- clang-3.5
- toolset: clang
compiler: clang++-3.6
cxxstd: "03,11,14"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- clang-3.6
- toolset: clang
compiler: clang++-3.7
cxxstd: "03,11,14"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- clang-3.7
- toolset: clang
compiler: clang++-3.8
cxxstd: "03,11,14"
os: ubuntu-20.04
container: ubuntu:16.04
install:
- clang-3.8
- toolset: clang
compiler: clang++-3.9
cxxstd: "03,11,14"
os: ubuntu-18.04
install:
- clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "03,11,14"
os: ubuntu-18.04
install:
- clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install:
- clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install:
- clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install:
- clang-7
# Note: clang-8 does not fully support C++20, so it is not compatible with libstdc++-8 in this mode
- toolset: clang
compiler: clang++-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install:
- clang-8
- g++-7
gcc_toolchain: 7
- toolset: clang
compiler: clang++-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install:
- clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install:
- clang-10
- toolset: clang
compiler: clang++-11
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install:
- clang-11
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install:
- clang-12
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install:
- clang-12
- libc++-12-dev
- libc++abi-12-dev
cxxflags: -stdlib=libc++
linkflags: -stdlib=libc++
- name: UBSAN
toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
cxxflags: -stdlib=libc++
linkflags: -stdlib=libc++
ubsan: 1
build_variant: debug
os: ubuntu-20.04
install:
- clang-12
- libc++-12-dev
- libc++abi-12-dev
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-10.15
timeout-minutes: 60
runs-on: ${{matrix.os}}
container: ${{matrix.container}}
steps:
- name: Setup environment
run: |
if [ -f "/etc/debian_version" ]
then
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
export DEBIAN_FRONTEND=noninteractive
fi
if [ -n "${{matrix.container}}" ]
then
echo "GHA_CONTAINER=${{matrix.container}}" >> $GITHUB_ENV
if [ -f "/etc/debian_version" ]
then
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https ca-certificates make build-essential g++ python python3 git cmake
fi
fi
git config --global pack.threads 0
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: |
SOURCE_KEYS=(${{join(matrix.source_keys, ' ')}})
SOURCES=(${{join(matrix.sources, ' ')}})
for key in "${SOURCE_KEYS[@]}"
do
for i in {1..$NET_RETRY_COUNT}
do
wget -O - "$key" | sudo apt-key add - && break || sleep 2
done
done
if [ ${#SOURCES[@]} -gt 0 ]
then
APT_ADD_REPO_COMMON_ARGS=("-y")
APT_ADD_REPO_HAS_SOURCE_ARGS=0
SOFTWARE_PROPERTIES_VERSION="$(dpkg-query --showformat='${Version}' --show software-properties-common)"
if dpkg --compare-versions "$SOFTWARE_PROPERTIES_VERSION" ge "0.96.24.20"
then
APT_ADD_REPO_COMMON_ARGS+=("-n")
fi
if dpkg --compare-versions "$SOFTWARE_PROPERTIES_VERSION" ge "0.98.10"
then
APT_ADD_REPO_HAS_SOURCE_ARGS=1
fi
for source in "${SOURCES[@]}"
do
for i in {1..$NET_RETRY_COUNT}
do
APT_ADD_REPO_ARGS=("${APT_ADD_REPO_COMMON_ARGS[@]}")
if [ $APT_ADD_REPO_HAS_SOURCE_ARGS -ne 0 ]
then
case "$source" in
"ppa:"*)
APT_ADD_REPO_ARGS+=("-P")
;;
"deb "*)
APT_ADD_REPO_ARGS+=("-S")
;;
*)
APT_ADD_REPO_ARGS+=("-U")
;;
esac
fi
APT_ADD_REPO_ARGS+=("$source")
sudo -E apt-add-repository "${APT_ADD_REPO_ARGS[@]}" && break || sleep 2
done
done
fi
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y ${{join(matrix.install, ' ')}}
- name: Setup GCC Toolchain
if: matrix.gcc_toolchain
run: |
GCC_TOOLCHAIN_ROOT="$HOME/gcc-toolchain"
echo "GCC_TOOLCHAIN_ROOT=\"$GCC_TOOLCHAIN_ROOT\"" >> $GITHUB_ENV
MULTIARCH_TRIPLET="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
mkdir -p "$GCC_TOOLCHAIN_ROOT"
ln -s /usr/include "$GCC_TOOLCHAIN_ROOT/include"
ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin"
mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET"
ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}"
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV
echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV
DEPINST_ARGS=()
GIT_VERSION="$(git --version | sed -e 's/git version //')"
GIT_HAS_JOBS=1
if [ -f "/etc/debian_version" ]
then
if $(dpkg --compare-versions "$GIT_VERSION" lt 2.8.0)
then
GIT_HAS_JOBS=0
fi
else
declare -a GIT_VER=(${GIT_VERSION//./ })
declare -a GIT_MIN_VER=(2 8 0)
for ((i=0; i<${#GIT_VER[@]}; i++))
do
if [ -z "${GIT_MIN_VER[i]}" ]
then
GIT_MIN_VER[i]=0
fi
if [ "${GIT_VER[i]}" -lt "${GIT_MIN_VER[i]}" ]
then
GIT_HAS_JOBS=0
break
fi
done
fi
if [ "$GIT_HAS_JOBS" -ne 0 ]
then
DEPINST_ARGS+=("--git_args" "--jobs $GIT_FETCH_JOBS")
fi
cd ..
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" "boost-root"
cd boost-root
mkdir -p libs/$LIBRARY
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
DEPINST_ARGS+=("$LIBRARY")
python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}"
if [ -z "${{matrix.cmake_tests}}" ]
then
./bootstrap.sh
./b2 headers
if [ -n "${{matrix.compiler}}" -o -n "$GCC_TOOLCHAIN_ROOT" ]
then
echo -n "using ${{matrix.toolset}} : : ${{matrix.compiler}}" > ~/user-config.jam
if [ -n "$GCC_TOOLCHAIN_ROOT" ]
then
echo -n " : <compileflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\" <linkflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\"" >> ~/user-config.jam
fi
echo " ;" >> ~/user-config.jam
fi
fi
- name: Run tests
if: matrix.cmake_tests == ''
run: |
cd ../boost-root
B2_ARGS=("-j" "$BUILD_JOBS" "toolset=${{matrix.toolset}}" "cxxstd=${{matrix.cxxstd}}")
if [ -n "${{matrix.build_variant}}" ]
then
B2_ARGS+=("variant=${{matrix.build_variant}}")
else
B2_ARGS+=("variant=$DEFAULT_BUILD_VARIANT")
fi
if [ -n "${{matrix.threading}}" ]
then
B2_ARGS+=("threading=${{matrix.threading}}")
fi
if [ -n "${{matrix.ubsan}}" ]
then
export UBSAN_OPTIONS="print_stacktrace=1"
B2_ARGS+=("cxxflags=-fsanitize=undefined -fno-sanitize-recover=undefined" "linkflags=-fsanitize=undefined -fuse-ld=gold" "define=UBSAN=1" "debug-symbols=on" "visibility=global")
fi
if [ -n "${{matrix.cxxflags}}" ]
then
B2_ARGS+=("cxxflags=${{matrix.cxxflags}}")
fi
if [ -n "${{matrix.linkflags}}" ]
then
B2_ARGS+=("linkflags=${{matrix.linkflags}}")
fi
B2_ARGS+=("libs/$LIBRARY/test")
./b2 "${B2_ARGS[@]}"

View File

@ -1,202 +0,0 @@
# Copyright 2016, 2017 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
language: cpp
sudo: false
python: "2.7"
branches:
only:
- master
- develop
- /feature\/.*/
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.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
dist: trusty
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: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
- os: linux
compiler: clang++-3.5
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11
addons:
apt:
packages:
- clang-3.5
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
- libstdc++-5-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
- os: linux
compiler: clang++-3.7
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.7
- libstdc++-5-dev
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++-5-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++-5-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
- libstdc++-5-dev
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
- libstdc++-5-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- 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 --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/build
- git submodule update --init libs/config
- git submodule update --init tools/boostdep
- cp -r $TRAVIS_BUILD_DIR/* libs/utility
- python tools/boostdep/depinst/depinst.py utility
- ./bootstrap.sh
- ./b2 headers
script:
- |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- ./b2 libs/utility/test toolset=$TOOLSET cxxstd=$CXXSTD
notifications:
email:
on_success: always

24
CMakeLists.txt Normal file
View File

@ -0,0 +1,24 @@
# Copyright 2018 Peter Dimov
# Copyright 2018 Andrey Semashev
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.20)
project(boost_utility VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_utility INTERFACE)
add_library(Boost::utility ALIAS boost_utility)
target_include_directories(boost_utility INTERFACE include)
target_link_libraries(boost_utility
INTERFACE
Boost::config
Boost::core
Boost::io
Boost::preprocessor
Boost::static_assert
Boost::throw_exception
Boost::type_traits
)

26
README.md Normal file
View File

@ -0,0 +1,26 @@
# ![Boost.Utility](doc/logo.png)
Boost.Utility, part of collection of the [Boost C++ Libraries](https://github.com/boostorg), provides a number of smaller components, too small to be called libraries in their own right. See the documentation for the list of components.
### Directories
* **doc** - Documentation sources
* **include** - Interface headers of Boost.Utility
* **test** - Boost.Utility unit tests
### More information
* [Documentation](https://boost.org/libs/utility)
* [Report bugs](https://github.com/boostorg/utility/issues/new). Be sure to mention Boost version, Boost.Utility component, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt).
### Build status
Branch | GitHub Actions | AppVeyor | Test Matrix | Dependencies |
:-------------: | -------------- | -------- | ----------- | ------------ |
[`master`](https://github.com/boostorg/utility/tree/master) | [![GitHub Actions](https://github.com/boostorg/utility/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/utility/actions?query=branch%3Amaster) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/g09ehuy2o6aq42th/branch/master?svg=true)](https://ci.appveyor.com/project/Lastique/utility/branch/master) | [![Tests](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/utility.html) | [![Dependencies](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/utility.html)
[`develop`](https://github.com/boostorg/utility/tree/develop) | [![GitHub Actions](https://github.com/boostorg/utility/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/utility/actions?query=branch%3Adevelop) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/g09ehuy2o6aq42th/branch/develop?svg=true)](https://ci.appveyor.com/project/Lastique/utility/branch/develop) | [![Tests](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/utility.html) | [![Dependencies](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/utility.html)
### License
Distributed under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt).

100
appveyor.yml Normal file
View File

@ -0,0 +1,100 @@
# Copyright 2016-2019 Peter Dimov
# Copyright 2019 Andrey Semashev
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- master
- develop
- /feature\/.*/
environment:
matrix:
- TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
ADDRMD: 32
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: msvc-12.0,msvc-14.0
ADDRMD: 32,64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: msvc-14.1
CXXSTD: 14,17
ADDRMD: 32,64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- TOOLSET: msvc-14.2
ADDRMD: 32,64
CXXSTD: 14,17
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- TOOLSET: clang-win
ADDRMD: 32
CXXSTD: 14,17
ENV_SCRIPT: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- TOOLSET: clang-win
ADDRMD: 64
CXXSTD: 14,17
ENV_SCRIPT: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- TOOLSET: gcc
CXXSTD: 03,11,14,1z
ADDPATH: C:\cygwin\bin;
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: gcc
CXXSTD: 03,11,14,1z
ADDPATH: C:\cygwin64\bin;
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: gcc
CXXSTD: 03,11,14,1z
ADDPATH: C:\mingw\bin;
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: gcc
CXXSTD: 03,11,14,1z
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: gcc
CXXSTD: 03,11,14,17
ADDPATH: C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: gcc
CXXSTD: 03,11,14,17,2a
ADDPATH: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
install:
- set GIT_FETCH_JOBS=8
- set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- cd ..
- git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule init tools/build
- git submodule init tools/boost_install
- git submodule init libs/headers
- git submodule init libs/assert
- git submodule init libs/config
- git submodule init libs/core
- git submodule init libs/io
- git submodule init libs/preprocessor
- git submodule init libs/static_assert
- git submodule init libs/throw_exception
- git submodule init libs/type_traits
- git submodule init libs/container_hash
- git submodule init libs/integer
- git submodule init libs/detail
- git submodule update --jobs %GIT_FETCH_JOBS%
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\utility\
- cmd /c bootstrap
- b2 -d0 headers
build: off
test_script:
- PATH=%ADDPATH%%PATH%
- if not "%ENV_SCRIPT%" == "" call "%ENV_SCRIPT%"
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- b2 -j %NUMBER_OF_PROCESSORS% libs/utility/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release

View File

@ -493,7 +493,7 @@ call_traits can not be used with reference or array types.</p>
<h4>Example 1:</h4>
<p>The following class is a trivial class that stores some type T
by value (see the <a href="call_traits_test.cpp">call_traits_test.cpp</a>
by value (see the <a href="test/call_traits_test.cpp">call_traits_test.cpp</a>
file), the aim is to illustrate how each of the available
call_traits typedefs may be used:</p>

View File

@ -356,7 +356,7 @@ templates that can be controlled and automated with macros. The
implementation uses the [@../../../preprocessor/index.html Preprocessor library].
* [@http://www.boost.org/people/daryle_walker.html">Daryle Walker] started the
library. Contributed the test file [@../../base_from_member_test.cpp
library. Contributed the test file [@../../test/base_from_member_test.cpp
base_from_member_test.cpp].
[endsect]

View File

@ -1,6 +1,6 @@
[/
/ Copyright (c) 2008 Howard Hinnant
/ Copyright (c) 2009-20012 Vicente J. Botet Escriba
/ Copyright (c) 2009-2012 Vicente J. Botet Escriba
/
/ 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)

BIN
doc/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

539
doc/logo.svg Normal file
View File

@ -0,0 +1,539 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="744.09448819"
height="1052.3622047"
id="svg6858"
version="1.1"
inkscape:version="0.48.4 r9939"
sodipodi:docname="utility.svg">
<defs
id="defs6860">
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4453-7-8-6-7-3-5"
id="linearGradient10687-2-5"
gradientUnits="userSpaceOnUse"
x1="753.02301"
y1="3132.0801"
x2="1146.25"
y2="3132.0801" />
<linearGradient
id="linearGradient4453-7-8-6-7-3-5">
<stop
style="stop-color:#aac4dd;stop-opacity:1;"
offset="0"
id="stop4455-61-8-7-1-2-8" />
<stop
style="stop-color:#c2dbe9;stop-opacity:1;"
offset="1"
id="stop4457-4-1-9-1-12-1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4453-7-8-6-7-3-5"
id="linearGradient10685-2-2"
gradientUnits="userSpaceOnUse"
x1="753.02301"
y1="3132.0801"
x2="1146.25"
y2="3132.0801" />
<linearGradient
id="linearGradient6749">
<stop
style="stop-color:#aac4dd;stop-opacity:1;"
offset="0"
id="stop6751" />
<stop
style="stop-color:#c2dbe9;stop-opacity:1;"
offset="1"
id="stop6753" />
</linearGradient>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath3387-3-6-4-2-8-4">
<path
inkscape:connector-curvature="0"
d="m 862.109,3289.75 -109.086,-190.45 69.122,-124.42 164.511,-0.47 c 0,0 111.044,188.28 116.564,197.63 7.66,0 43.03,0 43.03,0 l -67.03,117.71 -217.111,0 z"
id="path3389-2-0-7-7-8-9" />
</clipPath>
<linearGradient
y2="3132.0801"
x2="1146.25"
y1="3132.0801"
x1="753.02301"
gradientUnits="userSpaceOnUse"
id="linearGradient4492-8-8"
xlink:href="#linearGradient4453-7-8-6-7-3-5"
inkscape:collect="always" />
<linearGradient
id="linearGradient6758">
<stop
style="stop-color:#aac4dd;stop-opacity:1;"
offset="0"
id="stop6760" />
<stop
style="stop-color:#c2dbe9;stop-opacity:1;"
offset="1"
id="stop6762" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4453-7-8-6-7-3-5"
id="linearGradient10691-7-8"
gradientUnits="userSpaceOnUse"
x1="1026.6899"
y1="2937.73"
x2="1463.14"
y2="2937.73" />
<linearGradient
id="linearGradient6765">
<stop
style="stop-color:#aac4dd;stop-opacity:1;"
offset="0"
id="stop6767" />
<stop
style="stop-color:#c2dbe9;stop-opacity:1;"
offset="1"
id="stop6769" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4453-7-8-6-7-3-5"
id="linearGradient10689-4-2"
gradientUnits="userSpaceOnUse"
x1="1026.6899"
y1="2937.73"
x2="1463.14"
y2="2937.73" />
<linearGradient
id="linearGradient6772">
<stop
style="stop-color:#aac4dd;stop-opacity:1;"
offset="0"
id="stop6774" />
<stop
style="stop-color:#c2dbe9;stop-opacity:1;"
offset="1"
id="stop6776" />
</linearGradient>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath3369-1-5-6-1-0-7">
<path
inkscape:connector-curvature="0"
d="m 1131.64,3128.5 -104.95,-181.12 116.38,-200.42 208.05,0.94 112.02,191.63 -112.08,188.97 -219.42,0 z"
id="path3371-89-4-1-6-0-1" />
</clipPath>
<linearGradient
y2="2937.73"
x2="1463.14"
y1="2937.73"
x1="1026.6899"
gradientUnits="userSpaceOnUse"
id="linearGradient4498-5-7"
xlink:href="#linearGradient4453-7-8-6-7-3-5"
inkscape:collect="always" />
<linearGradient
id="linearGradient6781">
<stop
style="stop-color:#aac4dd;stop-opacity:1;"
offset="0"
id="stop6783" />
<stop
style="stop-color:#c2dbe9;stop-opacity:1;"
offset="1"
id="stop6785" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4459-1-2-8-9-9-5"
id="linearGradient10695-9-9"
gradientUnits="userSpaceOnUse"
x1="646.55499"
y1="2736.25"
x2="1088.27"
y2="2736.25" />
<linearGradient
id="linearGradient4459-1-2-8-9-9-5">
<stop
id="stop4461-2-1-5-2-5-0"
offset="0"
style="stop-color:#839bc2;stop-opacity:1;" />
<stop
id="stop4463-3-2-8-7-30-3"
offset="1"
style="stop-color:#9fb6d4;stop-opacity:1;" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4459-1-2-8-9-9-5"
id="linearGradient10693-9-4"
gradientUnits="userSpaceOnUse"
x1="646.55499"
y1="2736.25"
x2="1088.27"
y2="2736.25" />
<linearGradient
id="linearGradient6792">
<stop
id="stop6794"
offset="0"
style="stop-color:#839bc2;stop-opacity:1;" />
<stop
id="stop6796"
offset="1"
style="stop-color:#9fb6d4;stop-opacity:1;" />
</linearGradient>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath3351-4-7-3-5-95-0">
<path
inkscape:connector-curvature="0"
d="m 757.242,2926.25 -110.687,-189.11 110.656,-190.89 219.437,0 111.622,189.1 -111.59,190.9 -219.438,0 z"
id="path3353-1-9-3-4-1-1" />
</clipPath>
<linearGradient
y2="2736.25"
x2="1088.27"
y1="2736.25"
x1="646.55499"
gradientUnits="userSpaceOnUse"
id="linearGradient4510-1-5"
xlink:href="#linearGradient4459-1-2-8-9-9-5"
inkscape:collect="always" />
<linearGradient
id="linearGradient6801">
<stop
id="stop6803"
offset="0"
style="stop-color:#839bc2;stop-opacity:1;" />
<stop
id="stop6805"
offset="1"
style="stop-color:#9fb6d4;stop-opacity:1;" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#radialGradient3327-8-4-8-0-2-4"
id="radialGradient10699-1-3"
gradientUnits="userSpaceOnUse"
cx="997.46997"
cy="2896.25"
fx="997.46997"
fy="2896.25"
r="583.73999" />
<radialGradient
fx="0"
fy="0"
cx="0"
cy="0"
r="1"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(58.375,0,0,-58.375,99.75,289.625)"
spreadMethod="pad"
id="radialGradient3327-8-4-8-0-2-4">
<stop
style="stop-opacity:1;stop-color:#aeaeb3"
offset="0"
id="stop3329-7-0-1-0-33-2" />
<stop
style="stop-opacity:1;stop-color:#ffffff"
offset="0.949438"
id="stop3331-4-3-0-0-97-3" />
<stop
style="stop-opacity:1;stop-color:#ffffff"
offset="1"
id="stop3333-2-4-9-7-2-2" />
</radialGradient>
<radialGradient
r="583.73999"
fy="2896.25"
fx="997.46997"
cy="2896.25"
cx="997.46997"
gradientUnits="userSpaceOnUse"
id="radialGradient13050"
xlink:href="#radialGradient3327-8-4-8-0-2-4"
inkscape:collect="always" />
<radialGradient
fx="0"
fy="0"
cx="0"
cy="0"
r="1"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(58.375,0,0,-58.375,99.75,289.625)"
spreadMethod="pad"
id="radialGradient6813">
<stop
style="stop-opacity:1;stop-color:#aeaeb3"
offset="0"
id="stop6815" />
<stop
style="stop-opacity:1;stop-color:#ffffff"
offset="0.949438"
id="stop6817" />
<stop
style="stop-opacity:1;stop-color:#ffffff"
offset="1"
id="stop6819" />
</radialGradient>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath3323-7-2-4-5-3-4">
<path
inkscape:connector-curvature="0"
d="m 997.469,2312.51 c -322.379,0 -583.739,261.36 -583.739,583.74 0,322.38 261.36,583.74 583.739,583.74 322.381,0 583.741,-261.36 583.741,-583.74 0,-322.38 -261.36,-583.74 -583.741,-583.74"
id="path3325-9-2-9-5-04-9" />
</clipPath>
<radialGradient
r="583.73999"
fy="2896.25"
fx="997.46997"
cy="2896.25"
cx="997.46997"
gradientUnits="userSpaceOnUse"
id="radialGradient4516-8-2"
xlink:href="#radialGradient3327-8-4-8-0-2-4"
inkscape:collect="always" />
<radialGradient
fx="0"
fy="0"
cx="0"
cy="0"
r="1"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(58.375,0,0,-58.375,99.75,289.625)"
spreadMethod="pad"
id="radialGradient6824">
<stop
style="stop-opacity:1;stop-color:#aeaeb3"
offset="0"
id="stop6826" />
<stop
style="stop-opacity:1;stop-color:#ffffff"
offset="0.949438"
id="stop6828" />
<stop
style="stop-opacity:1;stop-color:#ffffff"
offset="1"
id="stop6830" />
</radialGradient>
<radialGradient
r="583.73999"
fy="2896.25"
fx="997.46997"
cy="2896.25"
cx="997.46997"
gradientUnits="userSpaceOnUse"
id="radialGradient6856"
xlink:href="#radialGradient3327-8-4-8-0-2-4"
inkscape:collect="always" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.4"
inkscape:cx="234.05635"
inkscape:cy="581.46313"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1680"
inkscape:window-height="982"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid3066" />
</sodipodi:namedview>
<metadata
id="metadata6863">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g3319-1-2-5-1-4-4"
transform="matrix(0.10419818,0,0,-0.10419818,137.10955,897.00327)"
style="fill:url(#radialGradient10699-1-3);fill-opacity:1"
inkscape:export-filename="C:\Users\Adam\Desktop\bg_logo1.png"
inkscape:export-xdpi="63.625523"
inkscape:export-ydpi="63.625523">
<g
clip-path="url(#clipPath3323-7-2-4-5-3-4)"
id="g3321-9-2-7-4-3-9"
style="fill:url(#radialGradient6856);fill-opacity:1">
<path
id="path3335-8-7-3-8-92-0"
style="fill:url(#radialGradient4516-8-2);fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 997.469,2312.51 c -322.379,0 -583.739,261.36 -583.739,583.74 0,322.38 261.36,583.74 583.739,583.74 322.381,0 583.741,-261.36 583.741,-583.74 0,-322.38 -261.36,-583.74 -583.741,-583.74"
inkscape:connector-curvature="0" />
</g>
</g>
<g
id="g3347-6-8-3-7-4-4"
transform="matrix(0.125,0,0,-0.125,112.08304,959.82207)"
style="fill:url(#linearGradient10695-9-9);fill-opacity:1"
inkscape:export-filename="C:\Users\Adam\Desktop\bg_logo1.png"
inkscape:export-xdpi="63.625523"
inkscape:export-ydpi="63.625523">
<g
clip-path="url(#clipPath3351-4-7-3-5-95-0)"
id="g3349-5-5-4-7-9-4"
style="fill:url(#linearGradient10693-9-4);fill-opacity:1">
<path
id="path3361-0-8-2-9-0-9"
style="fill:url(#linearGradient4510-1-5);fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 757.242,2926.25 -110.687,-189.11 110.656,-190.89 219.437,0 111.622,189.1 -111.59,190.9 -219.438,0"
inkscape:connector-curvature="0" />
</g>
</g>
<path
id="path3363-6-9-0-1-5-8"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 194.34816,617.68335 13.106,-22.3925 25.99649,0 13.21487,22.60874 -13.21487,22.39125 -25.99649,0 -13.106,-22.60749 z m 40.53761,-24.8925 -28.86524,0 -0.72412,1.23749 -13.106,22.39251 -0.73575,1.25625 0.73087,1.26 13.106,22.60744 0.72263,1.24634 28.86374,0 0.72512,-1.22884 13.215,-22.39119 0.74625,-1.265 -0.74,-1.26751 -13.21537,-22.60875 -0.72313,-1.23874"
inkscape:connector-curvature="0"
inkscape:export-filename="C:\Users\Adam\Desktop\bg_logo1.png"
inkscape:export-xdpi="63.625523"
inkscape:export-ydpi="63.625523" />
<g
id="g3365-0-4-1-9-7-5"
transform="matrix(0.125,0,0,-0.125,112.08304,959.82207)"
style="fill:url(#linearGradient10691-7-8);fill-opacity:1"
inkscape:export-filename="C:\Users\Adam\Desktop\bg_logo1.png"
inkscape:export-xdpi="63.625523"
inkscape:export-ydpi="63.625523">
<g
clip-path="url(#clipPath3369-1-5-6-1-0-7)"
id="g3367-2-4-2-8-4-3"
style="fill:url(#linearGradient10689-4-2);fill-opacity:1">
<path
id="path3379-4-6-7-6-7-2"
style="fill:url(#linearGradient4498-5-7);fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 1131.64,3128.5 -104.95,-181.12 116.38,-200.42 208.05,0.94 112.02,191.63 -112.08,188.97 -219.42,0"
inkscape:connector-curvature="0" />
</g>
</g>
<path
id="path3381-6-8-0-0-66-3"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 241.86427,591.39959 12.3925,-21.38999 25.99625,0 13.27125,22.37625 -13.27125,22.7025 -24.56875,0.11 -13.82,-23.79876 z m 39.8125,-23.88999 -28.86125,0 -0.7225,1.24625 -12.3925,21.39 -0.72625,1.255 0.7275,1.25374 13.82,23.79876 0.7275,1.25125 1.44625,-0.006 24.56875,-0.11 1.4275,-0.006 0.72,-1.2325 13.27125,-22.7025 0.7425,-1.27 -0.75125,-1.26625 -13.27125,-22.37625 -0.72625,-1.225"
inkscape:connector-curvature="0"
inkscape:export-filename="C:\Users\Adam\Desktop\bg_logo1.png"
inkscape:export-xdpi="63.625523"
inkscape:export-ydpi="63.625523" />
<g
id="g3383-5-5-2-2-3-0"
transform="matrix(0.125,0,0,-0.125,112.08304,959.82207)"
style="fill:url(#linearGradient10687-2-5);fill-opacity:1"
inkscape:export-filename="C:\Users\Adam\Desktop\bg_logo1.png"
inkscape:export-xdpi="63.625523"
inkscape:export-ydpi="63.625523">
<g
clip-path="url(#clipPath3387-3-6-4-2-8-4)"
id="g3385-0-6-4-8-0-1"
style="fill:url(#linearGradient10685-2-2);fill-opacity:1">
<path
id="path3397-9-6-1-6-9-7"
style="fill:url(#linearGradient4492-8-8);fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 862.109,3289.75 -109.086,-190.45 69.122,-124.42 164.511,-0.47 c 0,0 111.044,188.28 116.564,197.63 7.66,0 43.03,0 43.03,0 l -67.03,117.71 -217.111,0"
inkscape:connector-curvature="0" />
</g>
</g>
<path
id="path3399-6-7-3-2-0-1"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 207.64603,572.41959 12.92424,-22.56624 25.68775,0 6.95625,12.21375 -3.94375,0 -14.56837,24.7025 -19.11525,-0.055 -7.94087,-14.295 z m 40.06574,-25.06624 -28.59012,0 -0.71975,1.2575 -12.92537,22.56625 -0.70112,1.22375 0.68512,1.23249 7.94137,14.295 0.71087,1.2825 1.46638,0.004 19.11525,0.055 1.43212,0.004 0.729,-1.23375 13.84375,-23.47249 6.81625,0 -2.12875,-3.7375 -6.95625,-12.21375 -0.71875,-1.2625"
inkscape:connector-curvature="0"
inkscape:export-filename="C:\Users\Adam\Desktop\bg_logo1.png"
inkscape:export-xdpi="63.625523"
inkscape:export-ydpi="63.625523" />
<g
transform="matrix(1.25,0,0,-1.25,105.02062,972.84257)"
id="g3465-0-8-9"
inkscape:export-filename="C:\Users\Adam\Desktop\bg_logo1.png"
inkscape:export-xdpi="63.625523"
inkscape:export-ydpi="63.625523">
<text
id="text3467-9-0-8"
transform="matrix(1,0,-0.17627963,-1,0,0)"
x="116.98372"
y="-267.77499"
style="font-size:11.81779194px">
<tspan
sodipodi:role="line"
style="font-size:46.39999771px;font-variant:normal;font-weight:normal;writing-mode:lr-tb;fill:#49608a;fill-opacity:1;fill-rule:nonzero;stroke:none;font-family:Denmark;-inkscape-font-specification:Denmark"
x="116.98372"
y="-267.77499"
id="tspan13239">UTILITY</tspan>
<tspan
sodipodi:role="line"
style="font-size:46.39999771px;font-variant:normal;font-weight:normal;writing-mode:lr-tb;fill:#49608a;fill-opacity:1;fill-rule:nonzero;stroke:none;font-family:Denmark;-inkscape-font-specification:Denmark"
x="116.98372"
y="-209.77499"
id="tspan11278-3" />
</text>
<text
id="text3471-0-51-2"
transform="matrix(0.99235617,0,-0.17763746,-1.0077027,0,0)"
style="font-size:38.40000153px"
x="112.74373"
y="-306.75479">
<tspan
id="tspan3473-6-0-9"
sodipodi:role="line"
style="font-size:38.40000153px;font-variant:normal;font-weight:normal;writing-mode:lr-tb;fill:#49608a;fill-opacity:1;fill-rule:nonzero;stroke:none;font-family:Denmark;-inkscape-font-specification:Denmark"
x="112.74373"
y="-306.75479">boost</tspan>
</text>
</g>
<path
style="fill:#ffffff;fill-opacity:1;stroke:none"
d="m 201.43967,613.81579 4.64114,4.2175 3.3738,-3.71306 -0.92817,-0.84354 1.68708,-1.85636 20.53445,20.81026 4.2175,-4.64111 -22.22144,-18.95384 c 0,0 1.69594,-1.83698 2.53062,-2.78454 2.53905,-2.76559 5.98925,-4.72587 5.98925,-4.72587 0,0 -6.03647,0.58224 -8.76507,2.21476 -0.84428,0.92751 -6.75676,7.40649 -6.75676,7.40649 l -0.92819,-0.84355 -3.37382,3.71308"
id="path13283"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccccccccc" />
<g
id="g3086"
transform="matrix(0.99872217,-0.05053738,0.05053738,0.99872217,-31.539183,11.181538)">
<path
sodipodi:nodetypes="ccccccccc"
inkscape:connector-curvature="0"
id="path13243"
d="m 227.74101,611.16418 -15.09943,12.783 2.55659,3.01989 15.09944,-12.78302 c 3.56324,2.16769 7.58975,-1.2411 7.0464,-5.96538 l -4.02652,3.40879 -2.55659,-3.01989 4.02652,-3.40879 c -3.56324,-2.16769 -8.59639,2.0933 -7.04641,5.9654 z"
style="fill:#ffffff;fill-opacity:1;stroke:none" />
<path
sodipodi:nodetypes="ccccccccc"
inkscape:connector-curvature="0"
id="path13243-1"
d="m 215.25729,626.9851 15.08951,-12.7947 -2.55893,-3.01791 -15.08952,12.79471 c -3.56492,-2.16491 -7.58878,1.24699 -7.04177,5.97085 l 4.02388,-3.41192 2.55892,3.01791 -4.02387,3.41192 c 3.56491,2.16492 8.59476,-2.09997 7.04178,-5.97086 z"
style="fill:#ffffff;fill-opacity:1;stroke:none" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -156,6 +156,11 @@ String-like operations:
[section History]
[/===============]
[heading boost 1.71]
* Glen Fernandes updated the implementation of the stream insertion operator to
write directly to the `basic_streambuf` and refactored that functionality into
a common utility.
[heading boost 1.53]
* Introduced

View File

@ -100,7 +100,7 @@ struct call_traits<T&>
typedef T& param_type; // hh removed const
};
#if BOOST_WORKAROUND( __BORLANDC__, < 0x5A0 )
#if BOOST_WORKAROUND( BOOST_BORLANDC, < 0x5A0 )
// these are illegal specialisations; cv-qualifies applied to
// references have no effect according to [8.3.2p1],
// C++ Builder requires them though as it treats cv-qualified

View File

@ -24,6 +24,7 @@
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/is_empty.hpp>
#include <boost/type_traits/is_final.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/call_traits.hpp>
@ -42,6 +43,14 @@ class compressed_pair;
namespace details
{
template<class T, bool E = boost::is_final<T>::value>
struct compressed_pair_empty
: ::boost::false_type { };
template<class T>
struct compressed_pair_empty<T, false>
: ::boost::is_empty<T> { };
// JM altered 26 Jan 2000:
template <class T1, class T2, bool IsSame, bool FirstEmpty, bool SecondEmpty>
struct compressed_pair_switch;
@ -343,8 +352,8 @@ class compressed_pair
T1,
T2,
::boost::is_same<typename remove_cv<T1>::type, typename remove_cv<T2>::type>::value,
::boost::is_empty<T1>::value,
::boost::is_empty<T2>::value>::value>
::boost::details::compressed_pair_empty<T1>::value,
::boost::details::compressed_pair_empty<T2>::value>::value>
{
private:
typedef details::compressed_pair_imp<T1, T2,
@ -352,8 +361,8 @@ private:
T1,
T2,
::boost::is_same<typename remove_cv<T1>::type, typename remove_cv<T2>::type>::value,
::boost::is_empty<T1>::value,
::boost::is_empty<T2>::value>::value> base;
::boost::details::compressed_pair_empty<T1>::value,
::boost::details::compressed_pair_empty<T2>::value>::value> base;
public:
typedef T1 first_type;
typedef T2 second_type;
@ -388,8 +397,8 @@ class compressed_pair<T, T>
T,
T,
::boost::is_same<typename remove_cv<T>::type, typename remove_cv<T>::type>::value,
::boost::is_empty<T>::value,
::boost::is_empty<T>::value>::value>
::boost::details::compressed_pair_empty<T>::value,
::boost::details::compressed_pair_empty<T>::value>::value>
{
private:
typedef details::compressed_pair_imp<T, T,
@ -397,8 +406,8 @@ private:
T,
T,
::boost::is_same<typename remove_cv<T>::type, typename remove_cv<T>::type>::value,
::boost::is_empty<T>::value,
::boost::is_empty<T>::value>::value> base;
::boost::details::compressed_pair_empty<T>::value,
::boost::details::compressed_pair_empty<T>::value>::value> base;
public:
typedef T first_type;
typedef T second_type;

View File

@ -109,6 +109,15 @@
# pragma warning( disable : 4284 ) // complaint about return type of
#endif // operator-> not begin a UDT
// Define BOOST_OPERATORS_CONSTEXPR to be like BOOST_CONSTEXPR but empty under MSVC < v19.22
#if BOOST_WORKAROUND(BOOST_MSVC, < 1922)
#define BOOST_OPERATORS_CONSTEXPR
#elif defined __sun
#define BOOST_OPERATORS_CONSTEXPR
#else
#define BOOST_OPERATORS_CONSTEXPR BOOST_CONSTEXPR
#endif
// In this section we supply the xxxx1 and xxxx2 forms of the operator
// templates, which are explicitly targeted at the 1-type-argument and
// 2-type-argument operator forms, respectively.
@ -132,34 +141,34 @@ template <typename T> class empty_base {};
template <class T, class U, class B = operators_detail::empty_base<T> >
struct less_than_comparable2 : B
{
friend bool operator<=(const T& x, const U& y) { return !static_cast<bool>(x > y); }
friend bool operator>=(const T& x, const U& y) { return !static_cast<bool>(x < y); }
friend bool operator>(const U& x, const T& y) { return y < x; }
friend bool operator<(const U& x, const T& y) { return y > x; }
friend bool operator<=(const U& x, const T& y) { return !static_cast<bool>(y < x); }
friend bool operator>=(const U& x, const T& y) { return !static_cast<bool>(y > x); }
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const T& x, const U& y) { return !static_cast<bool>(x > y); }
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const T& x, const U& y) { return !static_cast<bool>(x < y); }
friend BOOST_OPERATORS_CONSTEXPR bool operator>(const U& x, const T& y) { return y < x; }
friend BOOST_OPERATORS_CONSTEXPR bool operator<(const U& x, const T& y) { return y > x; }
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const U& x, const T& y) { return !static_cast<bool>(y < x); }
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const U& x, const T& y) { return !static_cast<bool>(y > x); }
};
template <class T, class B = operators_detail::empty_base<T> >
struct less_than_comparable1 : B
{
friend bool operator>(const T& x, const T& y) { return y < x; }
friend bool operator<=(const T& x, const T& y) { return !static_cast<bool>(y < x); }
friend bool operator>=(const T& x, const T& y) { return !static_cast<bool>(x < y); }
friend BOOST_OPERATORS_CONSTEXPR bool operator>(const T& x, const T& y) { return y < x; }
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const T& x, const T& y) { return !static_cast<bool>(y < x); }
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const T& x, const T& y) { return !static_cast<bool>(x < y); }
};
template <class T, class U, class B = operators_detail::empty_base<T> >
struct equality_comparable2 : B
{
friend bool operator==(const U& y, const T& x) { return x == y; }
friend bool operator!=(const U& y, const T& x) { return !static_cast<bool>(x == y); }
friend bool operator!=(const T& y, const U& x) { return !static_cast<bool>(y == x); }
friend BOOST_OPERATORS_CONSTEXPR bool operator==(const U& y, const T& x) { return x == y; }
friend BOOST_OPERATORS_CONSTEXPR bool operator!=(const U& y, const T& x) { return !static_cast<bool>(x == y); }
friend BOOST_OPERATORS_CONSTEXPR bool operator!=(const T& y, const U& x) { return !static_cast<bool>(y == x); }
};
template <class T, class B = operators_detail::empty_base<T> >
struct equality_comparable1 : B
{
friend bool operator!=(const T& x, const T& y) { return !static_cast<bool>(x == y); }
friend BOOST_OPERATORS_CONSTEXPR bool operator!=(const T& x, const T& y) { return !static_cast<bool>(x == y); }
};
// A macro which produces "name_2left" from "name".
@ -362,7 +371,7 @@ BOOST_BINARY_OPERATOR( right_shiftable, >> )
template <class T, class U, class B = operators_detail::empty_base<T> >
struct equivalent2 : B
{
friend bool operator==(const T& x, const U& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator==(const T& x, const U& y)
{
return !static_cast<bool>(x < y) && !static_cast<bool>(x > y);
}
@ -371,7 +380,7 @@ struct equivalent2 : B
template <class T, class B = operators_detail::empty_base<T> >
struct equivalent1 : B
{
friend bool operator==(const T&x, const T&y)
friend BOOST_OPERATORS_CONSTEXPR bool operator==(const T&x, const T&y)
{
return !static_cast<bool>(x < y) && !static_cast<bool>(y < x);
}
@ -380,28 +389,28 @@ struct equivalent1 : B
template <class T, class U, class B = operators_detail::empty_base<T> >
struct partially_ordered2 : B
{
friend bool operator<=(const T& x, const U& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const T& x, const U& y)
{ return static_cast<bool>(x < y) || static_cast<bool>(x == y); }
friend bool operator>=(const T& x, const U& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const T& x, const U& y)
{ return static_cast<bool>(x > y) || static_cast<bool>(x == y); }
friend bool operator>(const U& x, const T& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator>(const U& x, const T& y)
{ return y < x; }
friend bool operator<(const U& x, const T& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator<(const U& x, const T& y)
{ return y > x; }
friend bool operator<=(const U& x, const T& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const U& x, const T& y)
{ return static_cast<bool>(y > x) || static_cast<bool>(y == x); }
friend bool operator>=(const U& x, const T& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const U& x, const T& y)
{ return static_cast<bool>(y < x) || static_cast<bool>(y == x); }
};
template <class T, class B = operators_detail::empty_base<T> >
struct partially_ordered1 : B
{
friend bool operator>(const T& x, const T& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator>(const T& x, const T& y)
{ return y < x; }
friend bool operator<=(const T& x, const T& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator<=(const T& x, const T& y)
{ return static_cast<bool>(x < y) || static_cast<bool>(x == y); }
friend bool operator>=(const T& x, const T& y)
friend BOOST_OPERATORS_CONSTEXPR bool operator>=(const T& x, const T& y)
{ return static_cast<bool>(y < x) || static_cast<bool>(x == y); }
};

View File

@ -9,13 +9,16 @@
#ifndef BOOST_UTILITY_HPP
#define BOOST_UTILITY_HPP
#include <boost/utility/addressof.hpp>
// Use of this header is discouraged and it will be deprecated.
// Please include one or more of the headers below instead.
#include <boost/utility/base_from_member.hpp>
#include <boost/utility/binary.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/utility/identity_type.hpp>
#include <boost/core/addressof.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/core/checked_delete.hpp>
#include <boost/core/noncopyable.hpp>
#include <boost/next_prior.hpp>
#endif // BOOST_UTILITY_HPP

View File

@ -0,0 +1,58 @@
#ifndef BOOST_UTILITY_DETAIL_MINSTD_RAND_HPP_INCLUDED
#define BOOST_UTILITY_DETAIL_MINSTD_RAND_HPP_INCLUDED
// Copyright 2017 Peter Dimov
//
// 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
//
// An implementation of minstd_rand that does not require
// the Random library
#include <boost/cstdint.hpp>
namespace boost
{
namespace detail
{
class minstd_rand
{
private:
boost::uint_least32_t x_;
enum { a = 48271, m = 2147483647 };
public:
minstd_rand(): x_( 1 )
{
}
explicit minstd_rand( boost::uint_least32_t x ): x_( x % m )
{
if( x_ == 0 )
{
x_ = 1;
}
}
boost::uint_least32_t operator()()
{
boost::uint_least64_t y = x_;
y = ( a * y ) % m;
x_ = static_cast<boost::uint_least32_t>( y );
return x_;
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_UTILITY_DETAIL_MINSTD_RAND_HPP_INCLUDED

View File

@ -22,19 +22,19 @@
# define BOOST_RESULT_OF_ARGS BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)
#endif
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct tr1_result_of<F(BOOST_RESULT_OF_ARGS)>
: mpl::if_<
mpl::or_< is_pointer<F>, is_member_function_pointer<F> >
: conditional<
is_pointer<F>::value || is_member_function_pointer<F>::value
, boost::detail::tr1_result_of_impl<
typename remove_cv<F>::type,
typename remove_cv<F>::type(BOOST_RESULT_OF_ARGS),
(boost::detail::has_result_type<F>::value)>
(boost::detail::result_of_has_result_type<F>::value)>
, boost::detail::tr1_result_of_impl<
F,
F(BOOST_RESULT_OF_ARGS),
(boost::detail::has_result_type<F>::value)> >::type { };
(boost::detail::result_of_has_result_type<F>::value)> >::type { };
#endif
#ifdef BOOST_RESULT_OF_USE_DECLTYPE
@ -46,7 +46,7 @@ struct result_of<F(BOOST_RESULT_OF_ARGS)>
#ifdef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct result_of<F(BOOST_RESULT_OF_ARGS)>
: mpl::if_<mpl::or_<detail::has_result_type<F>, detail::has_result<F> >,
: conditional<detail::result_of_has_result_type<F>::value || detail::result_of_has_result<F>::value,
tr1_result_of<F(BOOST_RESULT_OF_ARGS)>,
detail::cpp0x_result_of<F(BOOST_RESULT_OF_ARGS)> >::type { };
#endif // BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
@ -57,8 +57,8 @@ namespace detail {
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct cpp0x_result_of<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
: mpl::if_<
is_member_function_pointer<F>
: conditional<
is_member_function_pointer<F>::value
, detail::tr1_result_of_impl<
typename remove_cv<F>::type,
typename remove_cv<F>::type(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false
@ -93,11 +93,11 @@ struct BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION())<F *>
template<typename F>
struct BOOST_PP_CAT(result_of_select_call_wrapper_type_, BOOST_PP_ITERATION())
: mpl::eval_if<
is_class<typename remove_reference<F>::type>,
: conditional<
is_class<typename remove_reference<F>::type>::value,
result_of_wrap_callable_class<F>,
mpl::identity<BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION())<typename remove_cv<typename remove_reference<F>::type>::type> >
>
type_identity<BOOST_PP_CAT(result_of_callable_fun_, BOOST_PP_ITERATION())<typename remove_cv<typename remove_reference<F>::type>::type> >
>::type
{};
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), typename T)>
@ -108,7 +108,7 @@ struct BOOST_PP_CAT(result_of_is_callable_, BOOST_PP_ITERATION()) {
(boost::declval<wrapper_t>()(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), boost::declval<T, >() BOOST_PP_INTERCEPT)), result_of_weird_type())
))
);
typedef mpl::bool_<value> type;
typedef integral_constant<bool, value> type;
};
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
@ -151,7 +151,7 @@ struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)),
#else // defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
template<typename F BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct result_of<F(BOOST_RESULT_OF_ARGS)>
: tr1_result_of<F(BOOST_RESULT_OF_ARGS)> { };
@ -177,7 +177,7 @@ struct tr1_result_of_impl<R (&)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), F
typedef R type;
};
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
template<typename R, typename FArgs BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct tr1_result_of_impl<R (T0::*)
(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_ITERATION(),T)),

View File

@ -0,0 +1,190 @@
// Boost result_of library
// Copyright Douglas Gregor 2004. 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)
// Copyright Daniel Walker, Eric Niebler, Michel Morin 2008-2012.
// 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)
// For more information, see http://www.boost.org/libs/utility
#ifndef BOOST_RESULT_OF_HPP
# error Boost result_of - do not include this file!
#endif
template<typename F, typename... Args>
struct tr1_result_of<F(Args...)>
: conditional<
is_pointer<F>::value || is_member_function_pointer<F>::value
, boost::detail::tr1_result_of_impl<
typename remove_cv<F>::type,
typename remove_cv<F>::type(Args...),
(boost::detail::result_of_has_result_type<F>::value)>
, boost::detail::tr1_result_of_impl<
F,
F(Args...),
(boost::detail::result_of_has_result_type<F>::value)> >::type { };
#ifdef BOOST_RESULT_OF_USE_DECLTYPE
template<typename F, typename... Args>
struct result_of<F(Args...)>
: detail::cpp0x_result_of<F(Args...)> { };
#endif // BOOST_RESULT_OF_USE_DECLTYPE
#ifdef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
template<typename F, typename... Args>
struct result_of<F(Args...)>
: conditional<detail::result_of_has_result_type<F>::value || detail::result_of_has_result<F>::value,
tr1_result_of<F(Args...)>,
detail::cpp0x_result_of<F(Args...)> >::type { };
#endif // BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
#if defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)
namespace detail {
template<typename F, typename... Args>
struct cpp0x_result_of<F(Args...)>
: conditional<
is_member_function_pointer<F>::value
, detail::tr1_result_of_impl<
typename remove_cv<F>::type,
typename remove_cv<F>::type(Args...), false
>
, detail::cpp0x_result_of_impl<
F(Args...)
>
>::type
{};
#ifdef BOOST_NO_SFINAE_EXPR
template<typename F>
struct result_of_callable_fun_2;
template<typename R, typename... Args>
struct result_of_callable_fun_2<R(Args...)> {
R operator()(Args...) const;
typedef result_of_private_type const &(*pfn_t)(...);
operator pfn_t() const volatile;
};
template<typename F>
struct result_of_callable_fun
: result_of_callable_fun_2<F>
{};
template<typename F>
struct result_of_callable_fun<F *>
: result_of_callable_fun_2<F>
{};
template<typename F>
struct result_of_select_call_wrapper_type
: conditional<
is_class<typename remove_reference<F>::type>::value,
result_of_wrap_callable_class<F>,
type_identity<result_of_callable_fun<typename remove_cv<typename remove_reference<F>::type>::type> >
>::type
{};
template<typename F, typename... Args>
struct result_of_is_callable {
typedef typename result_of_select_call_wrapper_type<F>::type wrapper_t;
static const bool value = (
sizeof(result_of_no_type) == sizeof(detail::result_of_is_private_type(
(boost::declval<wrapper_t>()(boost::declval<Args>()...), result_of_weird_type())
))
);
typedef integral_constant<bool, value> type;
};
template<typename F, typename... Args>
struct cpp0x_result_of_impl<F(Args...), true>
: lazy_enable_if<
result_of_is_callable<F, Args...>
, cpp0x_result_of_impl<F(Args...), false>
>
{};
template<typename F, typename... Args>
struct cpp0x_result_of_impl<F(Args...), false>
{
typedef decltype(
boost::declval<F>()(
boost::declval<Args>()...
)
) type;
};
#else // BOOST_NO_SFINAE_EXPR
template<typename F, typename... Args>
struct cpp0x_result_of_impl<F(Args...),
typename result_of_always_void<decltype(
boost::declval<F>()(
boost::declval<Args>()...
)
)>::type> {
typedef decltype(
boost::declval<F>()(
boost::declval<Args>()...
)
) type;
};
#endif // BOOST_NO_SFINAE_EXPR
} // namespace detail
#else // defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK)
template<typename F, typename... Args>
struct result_of<F(Args...)>
: tr1_result_of<F(Args...)> { };
#endif // defined(BOOST_RESULT_OF_USE_DECLTYPE)
namespace detail {
template<typename R, typename FArgs, typename... Args>
struct tr1_result_of_impl<R (*)(Args...), FArgs, false>
{
typedef R type;
};
template<typename R, typename FArgs, typename... Args>
struct tr1_result_of_impl<R (&)(Args...), FArgs, false>
{
typedef R type;
};
template<typename R, typename FArgs, typename C, typename... Args>
struct tr1_result_of_impl<R (C::*)(Args...), FArgs, false>
{
typedef R type;
};
template<typename R, typename FArgs, typename C, typename... Args>
struct tr1_result_of_impl<R (C::*)(Args...) const, FArgs, false>
{
typedef R type;
};
template<typename R, typename FArgs, typename C, typename... Args>
struct tr1_result_of_impl<R (C::*)(Args...) volatile, FArgs, false>
{
typedef R type;
};
template<typename R, typename FArgs, typename C, typename... Args>
struct tr1_result_of_impl<R (C::*)(Args...) const volatile, FArgs, false>
{
typedef R type;
};
}

View File

@ -10,27 +10,31 @@
#define BOOST_RESULT_OF_HPP
#include <boost/config.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/iteration/iterate.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
#include <boost/preprocessor/facilities/intercept.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/mpl/has_xxx.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/or.hpp>
#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_member_function_pointer.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/utility/declval.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/declval.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/type_identity.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/core/enable_if.hpp>
#ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES
# undef BOOST_RESULT_OF_NO_VARIADIC_TEMPLATES
# define BOOST_RESULT_OF_NO_VARIADIC_TEMPLATES
#endif
#ifdef BOOST_RESULT_OF_NO_VARIADIC_TEMPLATES
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/iteration/iterate.hpp>
# include <boost/preprocessor/repetition/enum_params.hpp>
# include <boost/preprocessor/repetition/enum_trailing_params.hpp>
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
# include <boost/preprocessor/repetition/enum_shifted_params.hpp>
# include <boost/preprocessor/facilities/intercept.hpp>
#endif
#ifndef BOOST_RESULT_OF_NUM_ARGS
# define BOOST_RESULT_OF_NUM_ARGS 16
@ -47,10 +51,6 @@
BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK cannot be defined at the same time.
#endif
#if defined(BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK) && defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE)
# error Cannot fallback to decltype if BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE is not defined.
#endif
#ifndef BOOST_RESULT_OF_USE_TR1
# ifndef BOOST_RESULT_OF_USE_DECLTYPE
# ifndef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
@ -71,11 +71,40 @@ template<typename F> struct tr1_result_of; // a TR1-style implementation of resu
#if !defined(BOOST_NO_SFINAE)
namespace detail {
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
typedef char result_of_yes_type; // sizeof(result_of_yes_type) == 1
typedef char (&result_of_no_type)[2]; // sizeof(result_of_no_type) == 2
template<class T> struct result_of_has_type {};
template<class T> struct result_of_has_result_type_impl
{
template<class U> static result_of_yes_type f( result_of_has_type<typename U::result_type>* );
template<class U> static result_of_no_type f( ... );
typedef boost::integral_constant<bool, sizeof(f<T>(0)) == sizeof(result_of_yes_type)> type;
};
template<class T> struct result_of_has_result_type: result_of_has_result_type_impl<T>::type
{
};
// Work around a nvcc bug by only defining has_result when it's needed.
#ifdef BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK
BOOST_MPL_HAS_XXX_TEMPLATE_DEF(result)
template<template<class> class C> struct result_of_has_template {};
template<class T> struct result_of_has_result_impl
{
template<class U> static result_of_yes_type f( result_of_has_template<U::template result>* );
template<class U> static result_of_no_type f( ... );
typedef boost::integral_constant<bool, sizeof(f<T>(0)) == sizeof(result_of_yes_type)> type;
};
template<class T> struct result_of_has_result: result_of_has_result_impl<T>::type
{
};
#endif
template<typename F, typename FArgs, bool HasResultType> struct tr1_result_of_impl;
@ -97,9 +126,6 @@ struct result_of_weird_type {
friend result_of_private_type operator,(result_of_private_type, result_of_weird_type);
};
typedef char result_of_yes_type; // sizeof(result_of_yes_type) == 1
typedef char (&result_of_no_type)[2]; // sizeof(result_of_no_type) == 2
template<typename T>
result_of_no_type result_of_is_private_type(T const &);
result_of_yes_type result_of_is_private_type(result_of_private_type);
@ -180,10 +206,10 @@ struct tr1_result_of_impl<F, FArgs, true>
};
template<typename FArgs>
struct is_function_with_no_args : mpl::false_ {};
struct is_function_with_no_args : false_type {};
template<typename F>
struct is_function_with_no_args<F(void)> : mpl::true_ {};
struct is_function_with_no_args<F(void)> : true_type {};
template<typename F, typename FArgs>
struct result_of_nested_result : F::template result<FArgs>
@ -191,15 +217,19 @@ struct result_of_nested_result : F::template result<FArgs>
template<typename F, typename FArgs>
struct tr1_result_of_impl<F, FArgs, false>
: mpl::if_<is_function_with_no_args<FArgs>,
: conditional<is_function_with_no_args<FArgs>::value,
result_of_void_impl<F>,
result_of_nested_result<F, FArgs> >::type
{};
} // end namespace detail
#define BOOST_PP_ITERATION_PARAMS_1 (3,(0,BOOST_RESULT_OF_NUM_ARGS,<boost/utility/detail/result_of_iterate.hpp>))
#include BOOST_PP_ITERATE()
#ifndef BOOST_RESULT_OF_NO_VARIADIC_TEMPLATES
# include <boost/utility/detail/result_of_variadic.hpp>
#else
# define BOOST_PP_ITERATION_PARAMS_1 (3,(0,BOOST_RESULT_OF_NUM_ARGS,<boost/utility/detail/result_of_iterate.hpp>))
# include BOOST_PP_ITERATE()
#endif
#if 0
// inform dependency trackers, as they can't see through macro includes

View File

@ -1,5 +1,6 @@
/*
Copyright (c) Marshall Clow 2012-2015.
Copyright (c) Glen Joseph Fernandes 2019 (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)
@ -17,6 +18,7 @@
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/io/ostream_put.hpp>
#include <boost/utility/string_ref_fwd.hpp>
#include <boost/throw_exception.hpp>
@ -181,6 +183,7 @@ namespace boost {
}
size_type find(basic_string_ref s) const {
if (s.empty()) return 0;
const_iterator iter = std::search ( this->cbegin (), this->cend (),
s.cbegin (), s.cend (), traits::eq );
return iter == this->cend () ? npos : std::distance ( this->cbegin (), iter );
@ -193,6 +196,7 @@ namespace boost {
}
size_type rfind(basic_string_ref s) const {
if (s.empty()) return 0;
const_reverse_iterator iter = std::search ( this->crbegin (), this->crend (),
s.crbegin (), s.crend (), traits::eq );
return iter == this->crend () ? npos : (std::distance(iter, this->crend()) - s.size());
@ -419,52 +423,11 @@ namespace boost {
return basic_string_ref<charT, traits>(x) >= y;
}
namespace detail {
template<class charT, class traits>
inline void sr_insert_fill_chars(std::basic_ostream<charT, traits>& os, std::size_t n) {
enum { chunk_size = 8 };
charT fill_chars[chunk_size];
std::fill_n(fill_chars, static_cast< std::size_t >(chunk_size), os.fill());
for (; n >= chunk_size && os.good(); n -= chunk_size)
os.write(fill_chars, static_cast< std::size_t >(chunk_size));
if (n > 0 && os.good())
os.write(fill_chars, n);
}
template<class charT, class traits>
void sr_insert_aligned(std::basic_ostream<charT, traits>& os, const basic_string_ref<charT,traits>& str) {
const std::size_t size = str.size();
const std::size_t alignment_size = static_cast< std::size_t >(os.width()) - size;
const bool align_left = (os.flags() & std::basic_ostream<charT, traits>::adjustfield) == std::basic_ostream<charT, traits>::left;
if (!align_left) {
detail::sr_insert_fill_chars(os, alignment_size);
if (os.good())
os.write(str.data(), size);
}
else {
os.write(str.data(), size);
if (os.good())
detail::sr_insert_fill_chars(os, alignment_size);
}
}
} // namespace detail
// Inserter
template<class charT, class traits>
inline std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os, const basic_string_ref<charT,traits>& str) {
if (os.good()) {
const std::size_t size = str.size();
const std::size_t w = static_cast< std::size_t >(os.width());
if (w <= size)
os.write(str.data(), size);
else
detail::sr_insert_aligned(os, str);
os.width(0);
}
return os;
return boost::io::ostream_put(os, str.data(), str.size());
}
#if 0

View File

@ -1,6 +1,7 @@
/*
Copyright (c) Marshall Clow 2012-2015.
Copyright (c) Beman Dawes 2015
Copyright (c) Glen Joseph Fernandes 2019 (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)
@ -19,6 +20,7 @@
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/io/ostream_put.hpp>
#include <boost/utility/string_view_fwd.hpp>
#include <boost/throw_exception.hpp>
@ -183,7 +185,7 @@ namespace boost {
if (pos > size())
BOOST_THROW_EXCEPTION(std::out_of_range("string_view::copy" ));
size_type rlen = (std::min)(n, len_ - pos);
traits_type::copy(s, data() + pos, rlen);
traits_type::copy(s, data() + pos, rlen);
return rlen;
}
@ -245,12 +247,27 @@ namespace boost {
return npos;
if (s.empty())
return pos;
const_iterator iter = std::search(this->cbegin() + pos, this->cend(),
s.cbegin (), s.cend (), traits::eq);
return iter == this->cend () ? npos : std::distance(this->cbegin (), iter);
if (s.size() > size() - pos)
return npos;
const charT* cur = ptr_ + pos;
const charT* last = cend() - s.size() + 1;
for (; cur != last ; ++cur) {
cur = traits::find(cur, last - cur, s[0]);
if (!cur)
return npos;
if (traits::compare(cur, s.cbegin(), s.size()) == 0)
return cur - ptr_;
}
return npos;
}
BOOST_CXX14_CONSTEXPR size_type find(charT c, size_type pos = 0) const BOOST_NOEXCEPT {
if (pos > size())
return npos;
const charT* ret_ptr = traits::find(ptr_ + pos, len_ - pos, c);
if (ret_ptr)
return ret_ptr - ptr_;
return npos;
}
BOOST_CXX14_CONSTEXPR size_type find(charT c, size_type pos = 0) const BOOST_NOEXCEPT
{ return find(basic_string_view(&c, 1), pos); }
BOOST_CXX14_CONSTEXPR size_type find(const charT* s, size_type pos, size_type n) const BOOST_NOEXCEPT
{ return find(basic_string_view(s, n), pos); }
BOOST_CXX14_CONSTEXPR size_type find(const charT* s, size_type pos = 0) const BOOST_NOEXCEPT
@ -287,7 +304,7 @@ namespace boost {
return iter == this->cend () ? npos : std::distance ( this->cbegin (), iter );
}
BOOST_CXX14_CONSTEXPR size_type find_first_of(charT c, size_type pos = 0) const BOOST_NOEXCEPT
{ return find_first_of(basic_string_view(&c, 1), pos); }
{ return find(c, pos); }
BOOST_CXX14_CONSTEXPR size_type find_first_of(const charT* s, size_type pos, size_type n) const BOOST_NOEXCEPT
{ return find_first_of(basic_string_view(s, n), pos); }
BOOST_CXX14_CONSTEXPR size_type find_first_of(const charT* s, size_type pos = 0) const BOOST_NOEXCEPT
@ -555,53 +572,12 @@ namespace boost {
return basic_string_view<charT, traits>(x) >= y;
}
namespace detail {
template<class charT, class traits>
inline void sv_insert_fill_chars(std::basic_ostream<charT, traits>& os, std::size_t n) {
enum { chunk_size = 8 };
charT fill_chars[chunk_size];
std::fill_n(fill_chars, static_cast< std::size_t >(chunk_size), os.fill());
for (; n >= chunk_size && os.good(); n -= chunk_size)
os.write(fill_chars, static_cast< std::size_t >(chunk_size));
if (n > 0 && os.good())
os.write(fill_chars, n);
}
template<class charT, class traits>
void sv_insert_aligned(std::basic_ostream<charT, traits>& os, const basic_string_view<charT,traits>& str) {
const std::size_t size = str.size();
const std::size_t alignment_size = static_cast< std::size_t >(os.width()) - size;
const bool align_left = (os.flags() & std::basic_ostream<charT, traits>::adjustfield) == std::basic_ostream<charT, traits>::left;
if (!align_left) {
detail::sv_insert_fill_chars(os, alignment_size);
if (os.good())
os.write(str.data(), size);
}
else {
os.write(str.data(), size);
if (os.good())
detail::sv_insert_fill_chars(os, alignment_size);
}
}
} // namespace detail
// Inserter
template<class charT, class traits>
inline std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os,
const basic_string_view<charT,traits>& str) {
if (os.good()) {
const std::size_t size = str.size();
const std::size_t w = static_cast< std::size_t >(os.width());
if (w <= size)
os.write(str.data(), size);
else
detail::sv_insert_aligned(os, str);
os.width(0);
}
return os;
return boost::io::ostream_put(os, str.data(), str.size());
}
#if 0
@ -675,6 +651,13 @@ namespace boost {
}
#endif
// Forward declaration of Boost.ContainerHash function
template <class It> std::size_t hash_range(It, It);
template <class charT, class traits>
std::size_t hash_value(basic_string_view<charT, traits> s) {
return boost::hash_range(s.begin(), s.end());
}
}
#if 0

View File

@ -1,4 +1,5 @@
// (C) Copyright 2002-2008, Fernando Luis Cacciola Carballal.
// Copyright 2020 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@ -21,15 +22,10 @@
// issues, by clearing the bytes of T, before constructing the T object it
// contains. More details on these issues are at libs/utility/value_init.htm
#include <boost/aligned_storage.hpp>
#include <boost/config.hpp> // For BOOST_NO_COMPLETE_VALUE_INITIALIZATION.
#include <boost/detail/workaround.hpp>
#include <boost/static_assert.hpp>
#include <boost/type_traits/cv_traits.hpp>
#include <boost/type_traits/alignment_of.hpp>
#include <boost/swap.hpp>
#include <cstring>
#include <new>
#include <cstddef>
#ifdef BOOST_MSVC
#pragma warning(push)
@ -60,92 +56,58 @@
namespace boost {
namespace detail {
struct zero_init
{
zero_init()
{
}
zero_init( void * p, std::size_t n )
{
std::memset( p, 0, n );
}
};
} // namespace detail
template<class T>
class initialized
#if BOOST_DETAIL_VALUE_INIT_WORKAROUND
: detail::zero_init
#endif
{
private :
struct wrapper
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
typename
#endif
remove_const<T>::type data;
private:
BOOST_GPU_ENABLED
wrapper()
:
data()
{
}
BOOST_GPU_ENABLED
wrapper(T const & arg)
:
data(arg)
{
}
};
mutable
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
typename
#endif
aligned_storage<sizeof(wrapper), alignment_of<wrapper>::value>::type x;
BOOST_GPU_ENABLED
wrapper * wrapper_address() const
{
return static_cast<wrapper *>( static_cast<void*>(&x));
}
T data_;
public :
BOOST_GPU_ENABLED
initialized()
{
initialized():
#if BOOST_DETAIL_VALUE_INIT_WORKAROUND
std::memset(&x, 0, sizeof(x));
zero_init( &const_cast< char& >( reinterpret_cast<char const volatile&>( data_ ) ), sizeof( data_ ) ),
#endif
new (wrapper_address()) wrapper();
data_()
{
}
BOOST_GPU_ENABLED
initialized(initialized const & arg)
explicit initialized(T const & arg): data_( arg )
{
new (wrapper_address()) wrapper( static_cast<wrapper const &>(*(arg.wrapper_address())));
}
BOOST_GPU_ENABLED
explicit initialized(T const & arg)
{
new (wrapper_address()) wrapper(arg);
}
BOOST_GPU_ENABLED
initialized & operator=(initialized const & arg)
{
// Assignment is only allowed when T is non-const.
BOOST_STATIC_ASSERT( ! is_const<T>::value );
*wrapper_address() = static_cast<wrapper const &>(*(arg.wrapper_address()));
return *this;
}
BOOST_GPU_ENABLED
~initialized()
{
wrapper_address()->wrapper::~wrapper();
}
BOOST_GPU_ENABLED
T const & data() const
{
return wrapper_address()->data;
return data_;
}
BOOST_GPU_ENABLED
T& data()
{
return wrapper_address()->data;
return data_;
}
BOOST_GPU_ENABLED
@ -157,13 +119,13 @@ class initialized
BOOST_GPU_ENABLED
operator T const &() const
{
return wrapper_address()->data;
return data_;
}
BOOST_GPU_ENABLED
operator T&()
{
return wrapper_address()->data;
return data_;
}
} ;

View File

@ -12,29 +12,31 @@
<p>The Boost Utility Library isn't really a single library at all. It is just a
collection for components too small to be called libraries in their own right.</p>
<p>But that doesn't mean there isn't useful stuff here. Take a look:</p>
<blockquote>
<p>
<a href="../core/doc/html/core/addressof.html">addressof</a> (moved to the Boost.Core library)<br>
<a href="doc/html/base_from_member.html">base_from_member</a><br>
<a href="utility.htm#BOOST_BINARY">BOOST_BINARY</a><br>
<a href="call_traits.htm">call_traits</a><br>
<a href="../core/doc/html/core/checked_delete.html">checked_delete</a> (moved to the Boost.Core library)<br>
<a href="doc/html/compressed_pair.html">compressed_pair</a><br>
<a href="doc/html/declval.html">declval</a><br>
<a href="../core/doc/html/core/enable_if.html">enable_if</a> (moved to the Boost.Core library)<br>
<a href="in_place_factories.html">in_place_factory</a><br>
<a href="iterator_adaptors.htm">iterator_adaptors</a><br>
<a href="../iterator/doc/generator_iterator.htm">generator iterator adaptors</a> (moved to the Boost.Iterator library)<br>
<a href="../iterator/doc/html/iterator/algorithms/next_prior.html">next/prior</a> (moved to the Boost.Iterator library)<br>
<a href="../core/doc/html/core/noncopyable.html">noncopyable</a> (moved to the Boost.Core library)<br>
<a href="operators.htm">operators</a><br>
<a href="utility.htm#result_of">result_of</a><br>
<a href="throw_exception.html">throw_exception</a><br>
<a href="utility.htm">utility</a><br>
<a href="doc/html/string_ref.html">string_ref</a><br>
<a href="value_init.htm">value_init</a><br>
</p>
</blockquote>
<ul>
<li><a href="doc/html/base_from_member.html">base_from_member</a></li>
<li><a href="utility.htm#BOOST_BINARY">BOOST_BINARY</a></li>
<li><a href="call_traits.htm">call_traits</a></li>
<li><a href="doc/html/compressed_pair.html">compressed_pair</a></li>
<li><a href="in_place_factories.html">in_place_factory</a></li>
<li><a href="iterator_adaptors.htm">iterator_adaptors</a></li>
<li><a href="operators.htm">operators</a></li>
<li><a href="utility.htm#result_of">result_of</a></li>
<li><a href="throw_exception.html">throw_exception</a></li>
<li><a href="utility.htm">utility</a></li>
<li><a href="doc/html/string_ref.html">string_ref</a></li>
<li><a href="value_init.htm">value_init</a></li>
</ul>
<p>Over time useful stuff here has moved to more appropriate Boost libraries:</p>
<ul>
<li><a href="../core/doc/html/core/addressof.html">addressof</a> (moved to Boost.Core)</li>
<li><a href="../core/doc/html/core/checked_delete.html">checked_delete</a> (moved to Boost.Core)</li>
<li><a href="../type_traits/doc/html/boost_typetraits/reference/declval.html">declval</a> (moved to Boost.TypeTraits)</li>
<li><a href="../core/doc/html/core/enable_if.html">enable_if</a> (moved to Boost.Core)</li>
<li><a href="../iterator/doc/generator_iterator.htm">generator iterator adaptors</a> (moved to Boost.Iterator)</li>
<li><a href="../iterator/doc/html/iterator/algorithms/next_prior.html">next/prior</a> (moved to Boost.Iterator)</li>
<li><a href="../core/doc/html/core/noncopyable.html">noncopyable</a> (moved to Boost.Core)</li>
<li><a href="../io/doc/html/io.html">ostream_string</a> (moved to Boost.IO)</li>
</ul>
<hr>
<p>&copy; Copyright Beman Dawes, 2001</p>
<p>Distributed under the Boost Software License, Version 1.0. (See

View File

@ -13,7 +13,8 @@
"Memory",
"Miscellaneous",
"Patterns"
]
],
"cxxstd": "03"
},
{
"key": "utility/call_traits",
@ -25,7 +26,8 @@
"documentation": "call_traits.htm",
"category": [
"Generic"
]
],
"cxxstd": "03"
},
{
"key": "utility/compressed_pair",
@ -38,7 +40,8 @@
"category": [
"Data",
"Patterns"
]
],
"cxxstd": "03"
},
{
"key": "utility/identity_type",
@ -53,7 +56,8 @@
],
"maintainers": [
"Lorenzo Caminiti <lorcaminiti -at- gmail.com>"
]
],
"cxxstd": "03"
},
{
"key": "utility/in_place_factories",
@ -65,7 +69,8 @@
"documentation": "in_place_factories.html",
"category": [
"Generic"
]
],
"cxxstd": "03"
},
{
"key": "utility/operators",
@ -83,7 +88,8 @@
],
"maintainers": [
"Daniel Frey <d.frey -at- gmx.de>"
]
],
"cxxstd": "03"
},
{
"key": "utility/result_of",
@ -96,7 +102,22 @@
"authors": "",
"maintainers": [
"Daniel Walker <daniel.j.walker -at- gmail.com>"
]
],
"cxxstd": "03"
},
{
"key": "utility/string_ref",
"name": "string_ref",
"description": "String view templates.",
"documentation": "doc/html/string_ref.html",
"category": [
"Containers"
],
"authors": "Marshall Clow",
"maintainers": [
"Marshall Clow <marshall -at- idio.com>"
],
"cxxstd": "03"
},
{
"key": "utility/value_initialized",
@ -108,6 +129,7 @@
"documentation": "value_init.htm",
"category": [
"Miscellaneous"
]
],
"cxxstd": "03"
}
]

View File

@ -119,8 +119,8 @@
also want <code>x &gt; y, x &gt;= y,</code> and <code>x &lt;= y</code>.
Moreover, unless your class has really surprising behavior, some of these
related operators can be defined in terms of others (e.g. <code>x &gt;= y
&lt;=&gt; !(x &lt; y)</code>). Replicating this boilerplate for multiple
classes is both tedious and error-prone. The <cite><a href=
is equivalent to !(x &lt; y)</code>). Replicating this boilerplate for
multiple classes is both tedious and error-prone. The <cite><a href=
"../../boost/operators.hpp">boost/operators.hpp</a></cite> templates help
by generating operators for you at namespace scope based on other
operators you've defined in your class.</p>
@ -454,7 +454,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
</caption>
<tr>
<td colspan="3">
<td colspan="4">
<table align="center" border="1">
<caption>
<em>Key</em>
@ -482,6 +482,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<th>Supplied Operations</th>
<th>Requirements</th>
<th>Propagates <code>constexpr</code>?</th>
</tr>
<tr>
@ -496,6 +498,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>t &lt; t1</code>.<br>
Return convertible to <code>bool</code>. See the <a href=
"#ordering">Ordering Note</a>.</td>
<td>Since <code>C++11</code><br>
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC &lt; v19.22</a>)</span></td>
</tr>
<tr>
@ -513,6 +518,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>t &lt; u</code>. <code>t &gt; u</code>.<br>
Returns convertible to <code>bool</code>. See the <a href=
"#ordering">Ordering Note</a>.</td>
<td>Since <code>C++11</code><br>
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC &lt; v19.22</a>)</span></td>
</tr>
<tr>
@ -524,6 +532,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>t == t1</code>.<br>
Return convertible to <code>bool</code>.</td>
<td>Since <code>C++11</code><br>
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC &lt; v19.22</a>)</span></td>
</tr>
<tr>
@ -537,6 +548,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>t == u</code>.<br>
Return convertible to <code>bool</code>.</td>
<td>Since <code>C++11</code><br>
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC &lt; v19.22</a>)</span></td>
</tr>
<tr>
@ -548,6 +562,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp += t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -560,6 +576,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp += u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -572,6 +590,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp -= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -584,6 +604,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp -= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -594,6 +616,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(u); temp -= t</code>.<br>
Return convertible to <code>T</code>.</td>
<td>No</td>
</tr>
<tr>
@ -606,6 +630,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp *= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -619,6 +645,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp *= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -630,6 +658,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp /= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -641,6 +671,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp /= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -651,6 +683,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(u); temp /= t</code>.<br>
Return convertible to <code>T</code>.</td>
<td>No</td>
</tr>
<tr>
@ -662,6 +696,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp %= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -673,6 +709,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp %= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -683,6 +721,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(u); temp %= t</code>.<br>
Return convertible to <code>T</code>.</td>
<td>No</td>
</tr>
<tr>
@ -694,6 +734,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp |= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -706,6 +748,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp |= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -717,6 +761,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp &amp;= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -729,6 +775,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp &amp;= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -740,6 +788,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp ^= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -752,6 +802,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp ^= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -762,6 +814,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); ++t</code><br>
Return convertible to <code>T</code>.</td>
<td>No</td>
</tr>
<tr>
@ -772,6 +826,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); --t;</code><br>
Return convertible to <code>T</code>.</td>
<td>No</td>
</tr>
<tr>
@ -784,6 +840,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp &lt;&lt;= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -796,6 +854,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp &lt;&lt;= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -808,6 +868,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp &gt;&gt;= t1</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -820,6 +882,8 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>T temp(t); temp &gt;&gt;= u</code>.<br>
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>No</td>
</tr>
<tr>
@ -831,6 +895,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>t &lt; t1</code>.<br>
Return convertible to <code>bool</code>. See the <a href=
"#ordering">Ordering Note</a>.</td>
<td>Since <code>C++11</code><br>
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC &lt; v19.22</a>)</span></td>
</tr>
<tr>
@ -842,6 +909,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>t &lt; u</code>. <code>t &gt; u</code>.<br>
Returns convertible to <code>bool</code>. See the <a href=
"#ordering">Ordering Note</a>.</td>
<td>Since <code>C++11</code><br>
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC &lt; v19.22</a>)</span></td>
</tr>
<tr>
@ -856,6 +926,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
<td><code>t &lt; t1</code>. <code>t == t1</code>.<br>
Returns convertible to <code>bool</code>. See the <a href=
"#ordering">Ordering Note</a>.</td>
<td>Since <code>C++11</code><br>
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC &lt; v19.22</a>)</span></td>
</tr>
<tr>
@ -874,6 +947,9 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
u</code>.<br>
Returns convertible to <code>bool</code>. See the <a href=
"#ordering">Ordering Note</a>.</td>
<td>Since <code>C++11</code><br>
<span style="font-size:small;">(except <a href="https://developercommunity.visualstudio.com/content/problem/414193/rejects-valid-constexpr-marked-friend-function-def.html">MSVC &lt; v19.22</a>)</span></td>
</tr>
</table>
@ -1586,7 +1662,7 @@ T operator+( T lhs, const T&amp; rhs )
<h3><a name="a_demo">Arithmetic Operators Demonstration</a> and Test
Program</h3>
<p>The <cite><a href="operators_test.cpp">operators_test.cpp</a></cite>
<p>The <cite><a href="test/operators_test.cpp">operators_test.cpp</a></cite>
program demonstrates the use of the arithmetic operator templates, and
can also be used to verify correct operation. Check the compiler status
report for the test results with selected platforms.</p>
@ -1998,7 +2074,7 @@ struct function_output_iterator
<h3><a name="i_demo">Iterator Demonstration</a> and Test Program</h3>
<p>The <cite><a href="iterators_test.cpp">iterators_test.cpp</a></cite>
<p>The <cite><a href="test/iterators_test.cpp">iterators_test.cpp</a></cite>
program demonstrates the use of the iterator templates, and can also be
used to verify correct operation. The following is the custom iterator
defined in the test program. It demonstrates a correct (though trivial)
@ -2064,7 +2140,7 @@ public:
<dt><a href="http://www.boost.org/people/beman_dawes.html">Beman Dawes</a></dt>
<dd>Contributed <cite><a href=
"operators_test.cpp">operators_test.cpp</a></cite>.</dd>
"test/operators_test.cpp">operators_test.cpp</a></cite>.</dd>
<dt><a href="http://www.boost.org/people/daryle_walker.html">Daryle Walker</a></dt>

View File

@ -1,322 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Shared Container Iterator Documentation</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<img src="../../boost.png" alt="boost.png (6897 bytes)"
align="center" width="277" height="86">
<h1>Shared Container Iterator</h1>
Defined in header
<a href="../../boost/shared_container_iterator.hpp">boost/shared_container_iterator.hpp</a>
<p>
The purpose of the shared container iterator is to attach the lifetime
of a container to the lifetime of its iterators. In other words, the
container will not be deleted until after all its iterators are
destroyed. The shared container iterator is typically used to
implement functions that return iterators over a range of objects that
only need to exist for the lifetime of the iterators. By returning a
pair of shared iterators from a function, the callee can return a
heap-allocated range of objects whose lifetime is automatically managed.
<p>
The shared container iterator augments an iterator over a shared
container. It maintains a reference count on the shared
container. If only shared container iterators hold references to
the container, the container's lifetime will end when the last shared
container iterator over it is destroyed. In any case, the shared
container is guaranteed to persist beyond the lifetime of all
the iterators. In all other ways, the
shared container iterator behaves the same as its base iterator.
<h2>Synopsis</h2>
<pre>
namespace boost {
template &lt;typename <a href="http://www.sgi.com/tech/stl/Container.html">Container</a>&gt;
class shared_container_iterator;
template &lt;typename <a href="http://www.sgi.com/tech/stl/Container.html">Container</a>&gt;
shared_container_iterator&lt;Container&gt;
make_shared_container_iterator(typename Container::iterator base,
boost::shared_ptr&lt;Container&gt; const&amp; container);
std::pair&lt;
typename shared_container_iterator&lt;Container&gt;,
typename shared_container_iterator&lt;Container&gt;
&gt;
make_shared_container_range(boost::shared_ptr&lt;Container&gt; const&amp; container);
}
</pre>
<hr>
<h2><a name="generator">The Shared Container Iterator Type</a></h2>
<pre>
template &lt;typename Container&gt; class shared_container_iterator;
</pre>
The class template <tt>shared_container_iterator</tt>
is the shared container iterator type. The <tt>Container</tt> template
type argument must model the
<a href="http://www.sgi.com/tech/stl/Container.html">Container</a>
concept.
<h3>Example</h3>
<p>
The following example illustrates how to create an iterator that
regulates the lifetime of a reference counted <tt>std::vector</tt>.
Though the original shared pointer <tt>ints</tt> ceases to exist
after <tt>set_range()</tt> returns, the
<tt>shared_counter_iterator</tt> objects maintain references to the
underlying vector and thereby extend the container's lifetime.
<p>
<a href="./shared_iterator_example1.cpp">shared_iterator_example1.cpp</a>:
<PRE>
<font color="#008040">#include "shared_container_iterator.hpp"</font>
<font color="#008040">#include "boost/shared_ptr.hpp"</font>
<font color="#008040">#include &lt;algorithm&gt;</font>
<font color="#008040">#include &lt;iostream&gt;</font>
<font color="#008040">#include &lt;vector&gt;</font>
<B>typedef</B> boost::shared_container_iterator&lt; std::vector&lt;<B>int</B>&gt; &gt; iterator;
<B>void</B> set_range(iterator& i, iterator& end) {
boost::shared_ptr&lt; std::vector&lt;<B>int</B>&gt; &gt; ints(<B>new</B> std::vector&lt;<B>int</B>&gt;());
ints-&gt;push_back(<font color="#0000A0">0</font>);
ints-&gt;push_back(<font color="#0000A0">1</font>);
ints-&gt;push_back(<font color="#0000A0">2</font>);
ints-&gt;push_back(<font color="#0000A0">3</font>);
ints-&gt;push_back(<font color="#0000A0">4</font>);
ints-&gt;push_back(<font color="#0000A0">5</font>);
i = iterator(ints-&gt;begin(),ints);
end = iterator(ints-&gt;end(),ints);
}
<B>int</B> main() {
iterator i,end;
set_range(i,end);
std::copy(i,end,std::ostream_iterator&lt;<B>int</B>&gt;(std::cout,<font color="#0000FF">","</font>));
std::cout.put(<font color="#0000FF">'\n'</font>);
<B>return</B> <font color="#0000A0">0</font>;
}
</PRE>
The output from this part is:
<pre>
0,1,2,3,4,5,
</pre>
<h3>Template Parameters</h3>
<Table border>
<TR>
<TH>Parameter</TH><TH>Description</TH>
</TR>
<TR>
<TD><a
href="http://www.sgi.com/tech/stl/Container.html"><tt>Container</tt></a></TD>
<TD>The type of the container that we wish to iterate over. It must be
a model of the
<a href="http://www.sgi.com/tech/stl/Container.html"><tt>Container</tt></a>
concept.
</TD>
</TR>
</Table>
<h3>Model of</h3>
The <tt>shared_container_iterator<Container></tt> type models the
same iterator concept as the base iterator
(<tt>Container::iterator</tt>).
<h3>Members</h3>
The shared container iterator type implements the member functions and
operators required of the <a
href="http://www.sgi.com/tech/stl/RandomAccessIterator.html">Random Access Iterator</a>
concept, though only operations defined for the base iterator will be valid.
In addition it has the following constructor:
<pre>
shared_container_iterator(Container::iterator const&amp; it,
boost::shared_ptr&lt;Container&gt; const&amp; container)
</pre>
<p>
<hr>
<p>
<h2><a name="make_iterator">The Shared Container Iterator Object Generator</a></h2>
<pre>
template &lt;typename Container&gt;
shared_container_iterator&lt;Container&gt;
make_shared_container_iterator(Container::iterator base,
boost::shared_ptr&lt;Container&gt; const&amp; container)
</pre>
This function provides an alternative to directly constructing a
shared container iterator. Using the object generator, a shared
container iterator can be created and passed to a function without
explicitly specifying its type.
<h3>Example</h3>
This example, similar to the previous, uses
<tt>make_shared_container_iterator()</tt> to create the iterators.
<p>
<a href="./shared_iterator_example2.cpp">shared_iterator_example2.cpp</a>:
<PRE>
<font color="#008040">#include "shared_container_iterator.hpp"</font>
<font color="#008040">#include "boost/shared_ptr.hpp"</font>
<font color="#008040">#include &lt;algorithm&gt;</font>
<font color="#008040">#include &lt;iterator&gt;</font>
<font color="#008040">#include &lt;iostream&gt;</font>
<font color="#008040">#include &lt;vector&gt;</font>
<B>template</B> &lt;<B>typename</B> Iterator&gt;
<B>void</B> print_range_nl (Iterator begin, Iterator end) {
<B>typedef</B> <B>typename</B> std::iterator_traits&lt;Iterator&gt;::value_type val;
std::copy(begin,end,std::ostream_iterator&lt;val&gt;(std::cout,<font color="#0000FF">","</font>));
std::cout.put(<font color="#0000FF">'\n'</font>);
}
<B>int</B> main() {
<B>typedef</B> boost::shared_ptr&lt; std::vector&lt;<B>int</B>&gt; &gt; ints_t;
{
ints_t ints(<B>new</B> std::vector&lt;<B>int</B>&gt;());
ints-&gt;push_back(<font color="#0000A0">0</font>);
ints-&gt;push_back(<font color="#0000A0">1</font>);
ints-&gt;push_back(<font color="#0000A0">2</font>);
ints-&gt;push_back(<font color="#0000A0">3</font>);
ints-&gt;push_back(<font color="#0000A0">4</font>);
ints-&gt;push_back(<font color="#0000A0">5</font>);
print_range_nl(boost::make_shared_container_iterator(ints-&gt;begin(),ints),
boost::make_shared_container_iterator(ints-&gt;end(),ints));
}
<B>return</B> <font color="#0000A0">0</font>;
}
</PRE>
Observe that the <tt>shared_container_iterator</tt> type is never
explicitly named. The output from this example is the same as the previous.
<h2><a name="make_range">The Shared Container Iterator Range Generator</a></h2>
<pre>
template &lt;typename Container&gt;
std::pair&lt
shared_container_iterator&lt;Container&gt;,
shared_container_iterator&lt;Container&gt;
&gt;
make_shared_container_range(boost::shared_ptr&lt;Container&gt; const&amp; container);
</pre>
Class <tt>shared_container_iterator</tt> is meant primarily to return,
using iterators, a range of values that we can guarantee will be alive as
long as the iterators are. This is a convenience
function to do just that. It is equivalent to
<pre>
std::make_pair(make_shared_container_iterator(container-&gt;begin(),container),
make_shared_container_iterator(container-&gt;end(),container));
</pre>
<h3>Example</h3>
In the following example, a range of values is returned as a pair of
<tt>shared_container_iterator</tt> objects.
<p>
<a href="./shared_iterator_example3.cpp">shared_iterator_example3.cpp</a>:
<PRE>
<font color="#008040">#include "shared_container_iterator.hpp"</font>
<font color="#008040">#include "boost/shared_ptr.hpp"</font>
<font color="#008040">#include "boost/tuple/tuple.hpp" // for boost::tie</font>
<font color="#008040">#include &lt;algorithm&gt; // for std::copy</font>
<font color="#008040">#include &lt;iostream&gt; </font>
<font color="#008040">#include &lt;vector&gt;</font>
<B>typedef</B> boost::shared_container_iterator&lt; std::vector&lt;<B>int</B>&gt; &gt; iterator;
std::pair&lt;iterator,iterator&gt;
return_range() {
boost::shared_ptr&lt; std::vector&lt;<B>int</B>&gt; &gt; range(<B>new</B> std::vector&lt;<B>int</B>&gt;());
range-&gt;push_back(<font color="#0000A0">0</font>);
range-&gt;push_back(<font color="#0000A0">1</font>);
range-&gt;push_back(<font color="#0000A0">2</font>);
range-&gt;push_back(<font color="#0000A0">3</font>);
range-&gt;push_back(<font color="#0000A0">4</font>);
range-&gt;push_back(<font color="#0000A0">5</font>);
<B>return</B> boost::make_shared_container_range(range);
}
<B>int</B> main() {
iterator i,end;
boost::tie(i,end) = return_range();
std::copy(i,end,std::ostream_iterator&lt;<B>int</B>&gt;(std::cout,<font color="#0000FF">","</font>));
std::cout.put(<font color="#0000FF">'\n'</font>);
<B>return</B> <font color="#0000A0">0</font>;
}
</PRE>
Though the <tt>range</tt> object only lives for the duration of the
<tt>return_range</tt> call, the reference counted
<tt>std::vector</tt> will live until <tt>i</tt> and <tt>end</tt>
are both destroyed. The output from this example is the same as
the previous two.
<hr>
<!-- hhmts start -->
Last modified: Mon Aug 11 11:27:03 EST 2003
<!-- hhmts end -->
<p><EFBFBD> Copyright 2003 The Trustees of Indiana University.
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)</p>
</body>
</html>

View File

@ -1,42 +0,0 @@
// Copyright 2003 The Trustees of Indiana University.
// 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/shared_container_iterator.hpp"
#include "boost/shared_ptr.hpp"
#include <algorithm>
#include <iostream>
#include <vector>
typedef boost::shared_container_iterator< std::vector<int> > iterator;
void set_range(iterator& i, iterator& end) {
boost::shared_ptr< std::vector<int> > ints(new std::vector<int>());
ints->push_back(0);
ints->push_back(1);
ints->push_back(2);
ints->push_back(3);
ints->push_back(4);
ints->push_back(5);
i = iterator(ints->begin(),ints);
end = iterator(ints->end(),ints);
}
int main() {
iterator i,end;
set_range(i,end);
std::copy(i,end,std::ostream_iterator<int>(std::cout,","));
std::cout.put('\n');
return 0;
}

View File

@ -1,43 +0,0 @@
// Copyright 2003 The Trustees of Indiana University.
// 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/shared_container_iterator.hpp"
#include "boost/shared_ptr.hpp"
#include <algorithm>
#include <iterator>
#include <iostream>
#include <vector>
template <typename Iterator>
void print_range_nl (Iterator begin, Iterator end) {
typedef typename std::iterator_traits<Iterator>::value_type val;
std::copy(begin,end,std::ostream_iterator<val>(std::cout,","));
std::cout.put('\n');
}
int main() {
typedef boost::shared_ptr< std::vector<int> > ints_t;
{
ints_t ints(new std::vector<int>());
ints->push_back(0);
ints->push_back(1);
ints->push_back(2);
ints->push_back(3);
ints->push_back(4);
ints->push_back(5);
print_range_nl(boost::make_shared_container_iterator(ints->begin(),ints),
boost::make_shared_container_iterator(ints->end(),ints));
}
return 0;
}

View File

@ -1,41 +0,0 @@
// Copyright 2003 The Trustees of Indiana University.
// 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/shared_container_iterator.hpp"
#include "boost/shared_ptr.hpp"
#include "boost/tuple/tuple.hpp" // for boost::tie
#include <algorithm> // for std::copy
#include <iostream>
#include <vector>
typedef boost::shared_container_iterator< std::vector<int> > iterator;
std::pair<iterator,iterator>
return_range() {
boost::shared_ptr< std::vector<int> > range(new std::vector<int>());
range->push_back(0);
range->push_back(1);
range->push_back(2);
range->push_back(3);
range->push_back(4);
range->push_back(5);
return boost::make_shared_container_range(range);
}
int main() {
iterator i,end;
boost::tie(i,end) = return_range();
std::copy(i,end,std::ostream_iterator<int>(std::cout,","));
std::cout.put('\n');
return 0;
}

View File

@ -8,11 +8,6 @@
# bring in rules for testing
import testing ;
alias unit_test_framework
: # sources
/boost//unit_test_framework
;
run base_from_member_test.cpp ;
run base_from_member_ref_test.cpp ;
@ -20,27 +15,29 @@ run binary_test.cpp ;
run call_traits_test.cpp : -u ;
run compressed_pair_test.cpp ../../test/build//boost_test_exec_monitor/<link>static ;
run compressed_pair_test.cpp ;
run compressed_pair_final_test.cpp ;
run iterators_test.cpp ../../test/build//boost_test_exec_monitor/<link>static ;
run iterators_test.cpp ;
run operators_test.cpp ../../test/build//boost_test_exec_monitor/<link>static ;
run operators_test.cpp ;
compile operators_constexpr_test.cpp ;
compile result_of_test.cpp ;
run shared_iterator_test.cpp ;
# compile-fail string_ref_from_rvalue.cpp ;
run string_ref_test1.cpp unit_test_framework ;
run string_ref_test2.cpp unit_test_framework ;
run string_ref_test_io.cpp unit_test_framework ;
run string_ref_test1.cpp ;
run string_ref_test2.cpp ;
run string_ref_test_io.cpp ;
# compile-fail string_view_from_rvalue.cpp ;
compile string_view_constexpr_test1.cpp ;
run string_view_test1.cpp unit_test_framework ;
run string_view_test2.cpp unit_test_framework ;
run string_view_test_io.cpp unit_test_framework ;
run string_view_test1.cpp ;
run string_view_test2.cpp ;
run string_view_test_io.cpp ;
run value_init_test.cpp ;
run value_init_test2.cpp ;
run value_init_test3.cpp ;
run value_init_workaround_test.cpp ;
run initialized_test.cpp ;
compile-fail value_init_test_fail1.cpp ;

View File

@ -10,7 +10,7 @@
#include <boost/utility/base_from_member.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
struct foo : boost::base_from_member<int&>
{

View File

@ -10,10 +10,9 @@
// 14 Jun 2003 Adjusted code for Boost.Test changes (Daryle Walker)
// 29 Aug 2001 Initial Version (Daryle Walker)
#include <boost/test/minimal.hpp> // for BOOST_CHECK, main
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp> // for BOOST_NO_MEMBER_TEMPLATES
#include <boost/cstdlib.hpp> // for boost::exit_success
#include <boost/noncopyable.hpp> // for boost::noncopyable
#include <boost/utility/base_from_member.hpp> // for boost::base_from_member
@ -172,13 +171,13 @@ object_registrar obj_reg;
// Main functionality
int
test_main( int , char * [] )
main()
{
BOOST_CHECK( obj_reg.db_.empty() );
BOOST_CHECK( obj_reg.defrauders_in_.empty() );
BOOST_CHECK( obj_reg.defrauders_out_.empty() );
BOOST_CHECK( obj_reg.overeager_.empty() );
BOOST_CHECK( obj_reg.overkilled_.empty() );
BOOST_TEST( obj_reg.db_.empty() );
BOOST_TEST( obj_reg.defrauders_in_.empty() );
BOOST_TEST( obj_reg.defrauders_out_.empty() );
BOOST_TEST( obj_reg.overeager_.empty() );
BOOST_TEST( obj_reg.overkilled_.empty() );
// Make a separate block to examine pre- and post-effects
{
@ -186,20 +185,20 @@ test_main( int , char * [] )
using std::endl;
bad_class bc;
BOOST_CHECK( obj_reg.db_.size() == 3 );
BOOST_CHECK( obj_reg.defrauders_in_.size() == 1 );
BOOST_TEST( obj_reg.db_.size() == 3 );
BOOST_TEST( obj_reg.defrauders_in_.size() == 1 );
good_class_1 gc1;
BOOST_CHECK( obj_reg.db_.size() == 6 );
BOOST_CHECK( obj_reg.defrauders_in_.size() == 1 );
BOOST_TEST( obj_reg.db_.size() == 6 );
BOOST_TEST( obj_reg.defrauders_in_.size() == 1 );
good_class_2 gc2;
BOOST_CHECK( obj_reg.db_.size() == 11 );
BOOST_CHECK( obj_reg.defrauders_in_.size() == 1 );
BOOST_TEST( obj_reg.db_.size() == 11 );
BOOST_TEST( obj_reg.defrauders_in_.size() == 1 );
BOOST_CHECK( obj_reg.defrauders_out_.empty() );
BOOST_CHECK( obj_reg.overeager_.empty() );
BOOST_CHECK( obj_reg.overkilled_.empty() );
BOOST_TEST( obj_reg.defrauders_out_.empty() );
BOOST_TEST( obj_reg.overeager_.empty() );
BOOST_TEST( obj_reg.overkilled_.empty() );
// Getting the addresses of the objects ensure
// that they're used, and not optimized away.
@ -208,13 +207,13 @@ test_main( int , char * [] )
cout << "Object 'gc2' is at " << &gc2 << '.' << endl;
}
BOOST_CHECK( obj_reg.db_.empty() );
BOOST_CHECK( obj_reg.defrauders_in_.size() == 1 );
BOOST_CHECK( obj_reg.defrauders_out_.size() == 1 );
BOOST_CHECK( obj_reg.overeager_.empty() );
BOOST_CHECK( obj_reg.overkilled_.empty() );
BOOST_TEST( obj_reg.db_.empty() );
BOOST_TEST( obj_reg.defrauders_in_.size() == 1 );
BOOST_TEST( obj_reg.defrauders_out_.size() == 1 );
BOOST_TEST( obj_reg.overeager_.empty() );
BOOST_TEST( obj_reg.overkilled_.empty() );
return boost::exit_success;
return boost::report_errors();
}

View File

@ -6,7 +6,7 @@
http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <boost/test/minimal.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/utility/binary.hpp>
#include <algorithm>
#include <cstddef>
@ -614,34 +614,34 @@ typedef char (&unsigned_long_int_id_type)[unsigned_long_int_id];
unsigned_int_id_type binary_type_checker( unsigned int );
unsigned_long_int_id_type binary_type_checker( unsigned long int );
int test_main( int, char *[] )
int main()
{
BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_1_bit ) );
BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_2_bits ) );
BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_3_bits ) );
BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_4_bits ) );
BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_5_bits ) );
BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_6_bits ) );
BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_7_bits ) );
BOOST_CHECK( is_ascending_from_0_array( unsigned_ints_8_bits ) );
BOOST_TEST( is_ascending_from_0_array( unsigned_ints_1_bit ) );
BOOST_TEST( is_ascending_from_0_array( unsigned_ints_2_bits ) );
BOOST_TEST( is_ascending_from_0_array( unsigned_ints_3_bits ) );
BOOST_TEST( is_ascending_from_0_array( unsigned_ints_4_bits ) );
BOOST_TEST( is_ascending_from_0_array( unsigned_ints_5_bits ) );
BOOST_TEST( is_ascending_from_0_array( unsigned_ints_6_bits ) );
BOOST_TEST( is_ascending_from_0_array( unsigned_ints_7_bits ) );
BOOST_TEST( is_ascending_from_0_array( unsigned_ints_8_bits ) );
BOOST_CHECK( std::equal( &random_unsigned_ints_hex[0]
BOOST_TEST( std::equal( &random_unsigned_ints_hex[0]
, random_unsigned_ints_hex + num_random_test_values
, &random_unsigned_ints_binary[0]
)
);
BOOST_CHECK( sizeof( binary_type_checker( BOOST_BINARY_U( 110100 1010 ) ) )
BOOST_TEST( sizeof( binary_type_checker( BOOST_BINARY_U( 110100 1010 ) ) )
== unsigned_int_id
);
BOOST_CHECK( sizeof( binary_type_checker( BOOST_BINARY_UL( 11110 ) ) )
BOOST_TEST( sizeof( binary_type_checker( BOOST_BINARY_UL( 11110 ) ) )
== unsigned_long_int_id
);
BOOST_CHECK( sizeof( binary_type_checker( BOOST_BINARY_LU( 10 0001 ) ) )
BOOST_TEST( sizeof( binary_type_checker( BOOST_BINARY_LU( 10 0001 ) ) )
== unsigned_long_int_id
);
return 0;
return boost::report_errors();
}

View File

@ -376,7 +376,7 @@ void call_traits_test<T, true>::assert_construct(typename boost::call_traits<T>:
reference r = t;
const_reference cr = t;
reference r2 = r;
#ifndef __BORLANDC__
#ifndef BOOST_BORLANDC
// C++ Builder buglet:
const_reference cr2 = r;
#endif
@ -393,7 +393,7 @@ void call_traits_test<T, true>::assert_construct(typename boost::call_traits<T>:
unused_variable(v3);
unused_variable(v4);
unused_variable(v5);
#ifndef __BORLANDC__
#ifndef BOOST_BORLANDC
unused_variable(r2);
unused_variable(cr2);
#endif

View File

@ -0,0 +1,55 @@
/*
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)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_FINAL)
#include <boost/compressed_pair.hpp>
#include <boost/core/lightweight_test.hpp>
struct type1 {
operator bool() const {
return false;
}
};
struct type2 final {
operator bool() const {
return false;
}
};
#if !defined(BOOST_IS_FINAL)
namespace boost {
template<>
struct is_final<type2>
: true_type { };
} /* boost*/
#endif
template<class T1, class T2>
void test()
{
boost::compressed_pair<T1, T2> p;
BOOST_TEST(!p.first());
BOOST_TEST(!p.second());
}
int main()
{
test<type1, type2>();
test<type2, type1>();
test<type2, type2>();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@ -14,7 +14,7 @@
#include <cassert>
#include <boost/compressed_pair.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/core/lightweight_test.hpp>
using namespace boost;
@ -79,47 +79,47 @@ void compressed_pair_tester<T1, T2>::test(first_param_type p1, second_param_type
// first param construct:
boost::compressed_pair<T1,T2> cp2(p1);
cp2.second() = p2;
BOOST_CHECK(cp2.first() == p1);
BOOST_CHECK(cp2.second() == p2);
BOOST_TEST(cp2.first() == p1);
BOOST_TEST(cp2.second() == p2);
// second param construct:
boost::compressed_pair<T1,T2> cp3(p2);
cp3.first() = p1;
BOOST_CHECK(cp3.second() == p2);
BOOST_CHECK(cp3.first() == p1);
BOOST_TEST(cp3.second() == p2);
BOOST_TEST(cp3.first() == p1);
// both param construct:
boost::compressed_pair<T1,T2> cp4(p1, p2);
BOOST_CHECK(cp4.first() == p1);
BOOST_CHECK(cp4.second() == p2);
BOOST_TEST(cp4.first() == p1);
BOOST_TEST(cp4.second() == p2);
boost::compressed_pair<T1,T2> cp5(p3, p4);
BOOST_CHECK(cp5.first() == p3);
BOOST_CHECK(cp5.second() == p4);
BOOST_TEST(cp5.first() == p3);
BOOST_TEST(cp5.second() == p4);
// check const members:
const boost::compressed_pair<T1,T2>& cpr1 = cp4;
BOOST_CHECK(cpr1.first() == p1);
BOOST_CHECK(cpr1.second() == p2);
BOOST_TEST(cpr1.first() == p1);
BOOST_TEST(cpr1.second() == p2);
// copy construct:
boost::compressed_pair<T1,T2> cp6(cp4);
BOOST_CHECK(cp6.first() == p1);
BOOST_CHECK(cp6.second() == p2);
BOOST_TEST(cp6.first() == p1);
BOOST_TEST(cp6.second() == p2);
// assignment:
cp1 = cp4;
BOOST_CHECK(cp1.first() == p1);
BOOST_CHECK(cp1.second() == p2);
BOOST_TEST(cp1.first() == p1);
BOOST_TEST(cp1.second() == p2);
cp1 = cp5;
BOOST_CHECK(cp1.first() == p3);
BOOST_CHECK(cp1.second() == p4);
BOOST_TEST(cp1.first() == p3);
BOOST_TEST(cp1.second() == p4);
// swap:
cp4.swap(cp5);
BOOST_CHECK(cp4.first() == p3);
BOOST_CHECK(cp4.second() == p4);
BOOST_CHECK(cp5.first() == p1);
BOOST_CHECK(cp5.second() == p2);
BOOST_TEST(cp4.first() == p3);
BOOST_TEST(cp4.second() == p4);
BOOST_TEST(cp5.first() == p1);
BOOST_TEST(cp5.second() == p2);
swap(cp4,cp5);
BOOST_CHECK(cp4.first() == p1);
BOOST_CHECK(cp4.second() == p2);
BOOST_CHECK(cp5.first() == p3);
BOOST_CHECK(cp5.second() == p4);
BOOST_TEST(cp4.first() == p1);
BOOST_TEST(cp4.second() == p2);
BOOST_TEST(cp5.first() == p3);
BOOST_TEST(cp5.second() == p4);
}
//
@ -148,20 +148,20 @@ void compressed_pair_reference_tester<T1, T2>::test(first_param_type p1, second_
#endif
// both param construct:
boost::compressed_pair<T1,T2> cp4(p1, p2);
BOOST_CHECK(cp4.first() == p1);
BOOST_CHECK(cp4.second() == p2);
BOOST_TEST(cp4.first() == p1);
BOOST_TEST(cp4.second() == p2);
boost::compressed_pair<T1,T2> cp5(p3, p4);
BOOST_CHECK(cp5.first() == p3);
BOOST_CHECK(cp5.second() == p4);
BOOST_TEST(cp5.first() == p3);
BOOST_TEST(cp5.second() == p4);
// check const members:
const boost::compressed_pair<T1,T2>& cpr1 = cp4;
BOOST_CHECK(cpr1.first() == p1);
BOOST_CHECK(cpr1.second() == p2);
BOOST_TEST(cpr1.first() == p1);
BOOST_TEST(cpr1.second() == p2);
// copy construct:
boost::compressed_pair<T1,T2> cp6(cp4);
BOOST_CHECK(cp6.first() == p1);
BOOST_CHECK(cp6.second() == p2);
BOOST_TEST(cp6.first() == p1);
BOOST_TEST(cp6.second() == p2);
// assignment:
// VC6 bug:
// When second() is an empty class, VC6 performs the
@ -174,8 +174,8 @@ void compressed_pair_reference_tester<T1, T2>::test(first_param_type p1, second_
// settings - some generate the problem others do not.
cp4.first() = p3;
cp4.second() = p4;
BOOST_CHECK(cp4.first() == p3);
BOOST_CHECK(cp4.second() == p4);
BOOST_TEST(cp4.first() == p3);
BOOST_TEST(cp4.second() == p4);
}
//
// supplimentary tests for case where first arg only is a reference type:
@ -199,8 +199,8 @@ void compressed_pair_reference1_tester<T1, T2>::test(first_param_type p1, second
// first param construct:
boost::compressed_pair<T1,T2> cp2(p1);
cp2.second() = p2;
BOOST_CHECK(cp2.first() == p1);
BOOST_CHECK(cp2.second() == p2);
BOOST_TEST(cp2.first() == p1);
BOOST_TEST(cp2.second() == p2);
#endif
}
//
@ -225,8 +225,8 @@ void compressed_pair_reference2_tester<T1, T2>::test(first_param_type p1, second
// second param construct:
boost::compressed_pair<T1,T2> cp3(p2);
cp3.first() = p1;
BOOST_CHECK(cp3.second() == p2);
BOOST_CHECK(cp3.first() == p1);
BOOST_TEST(cp3.second() == p2);
BOOST_TEST(cp3.first() == p1);
#endif
}
@ -253,14 +253,14 @@ void compressed_pair_array1_tester<T1, T2>::test(first_param_type p1, second_par
// second param construct:
boost::compressed_pair<T1,T2> cp3(p2);
cp3.first()[0] = p1[0];
BOOST_CHECK(cp3.second() == p2);
BOOST_CHECK(cp3.first()[0] == p1[0]);
BOOST_TEST(cp3.second() == p2);
BOOST_TEST(cp3.first()[0] == p1[0]);
// check const members:
const boost::compressed_pair<T1,T2>& cpr1 = cp3;
BOOST_CHECK(cpr1.first()[0] == p1[0]);
BOOST_CHECK(cpr1.second() == p2);
BOOST_TEST(cpr1.first()[0] == p1[0]);
BOOST_TEST(cpr1.second() == p2);
BOOST_CHECK(sizeof(T1) == sizeof(cp1.first()));
BOOST_TEST(sizeof(T1) == sizeof(cp1.first()));
}
template <class T1, class T2>
@ -283,14 +283,14 @@ void compressed_pair_array2_tester<T1, T2>::test(first_param_type p1, second_par
// first param construct:
boost::compressed_pair<T1,T2> cp2(p1);
cp2.second()[0] = p2[0];
BOOST_CHECK(cp2.first() == p1);
BOOST_CHECK(cp2.second()[0] == p2[0]);
BOOST_TEST(cp2.first() == p1);
BOOST_TEST(cp2.second()[0] == p2[0]);
// check const members:
const boost::compressed_pair<T1,T2>& cpr1 = cp2;
BOOST_CHECK(cpr1.first() == p1);
BOOST_CHECK(cpr1.second()[0] == p2[0]);
BOOST_TEST(cpr1.first() == p1);
BOOST_TEST(cpr1.second()[0] == p2[0]);
BOOST_CHECK(sizeof(T2) == sizeof(cp1.second()));
BOOST_TEST(sizeof(T2) == sizeof(cp1.second()));
}
template <class T1, class T2>
@ -312,18 +312,18 @@ void compressed_pair_array_tester<T1, T2>::test(first_param_type p1, second_para
boost::compressed_pair<T1,T2> cp1;
cp1.first()[0] = p1[0];
cp1.second()[0] = p2[0];
BOOST_CHECK(cp1.first()[0] == p1[0]);
BOOST_CHECK(cp1.second()[0] == p2[0]);
BOOST_TEST(cp1.first()[0] == p1[0]);
BOOST_TEST(cp1.second()[0] == p2[0]);
// check const members:
const boost::compressed_pair<T1,T2>& cpr1 = cp1;
BOOST_CHECK(cpr1.first()[0] == p1[0]);
BOOST_CHECK(cpr1.second()[0] == p2[0]);
BOOST_TEST(cpr1.first()[0] == p1[0]);
BOOST_TEST(cpr1.second()[0] == p2[0]);
BOOST_CHECK(sizeof(T1) == sizeof(cp1.first()));
BOOST_CHECK(sizeof(T2) == sizeof(cp1.second()));
BOOST_TEST(sizeof(T1) == sizeof(cp1.first()));
BOOST_TEST(sizeof(T2) == sizeof(cp1.second()));
}
int test_main(int, char *[])
int main()
{
// declare some variables to pass to the tester:
non_empty1 ne1(2);
@ -383,13 +383,5 @@ int test_main(int, char *[])
compressed_pair_array2_tester<empty_POD_UDT,non_empty2[2]>::test(e1, nea3, e1, nea4);
// T1 == T2, both non-empty
compressed_pair_array_tester<non_empty1[2],non_empty1[2]>::test(nea1, nea1, nea2, nea2);
return 0;
return boost::report_errors();
}
unsigned int expected_failures = 0;

View File

@ -9,7 +9,7 @@
// 2 May 2010 (Created) Niels Dekker
#include <boost/utility/value_init.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <string>

View File

@ -12,11 +12,9 @@
// library (Daryle Walker)
// 12 Dec 99 Initial version with iterator operators (Jeremy Siek)
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp> // for main
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
#include <boost/cstdlib.hpp> // for boost::exit_success
#include <boost/operators.hpp> // for boost::random_access_iterator_helper
#include <cstddef> // for std::ptrdiff_t, std::size_t
@ -126,7 +124,7 @@ typename test_opr<T, R, P>::iter_type const
// Main testing function
int
test_main( int , char * [] )
main()
{
using std::string;
@ -136,7 +134,7 @@ test_main( int , char * [] )
test1_type::master_test( "non-const string" );
test2_type::master_test( "const string" );
return boost::exit_success;
return boost::report_errors();
}
// Tests for all of the operators added by random_access_iterator_helper
@ -174,7 +172,7 @@ test_opr<T, R, P>::post_increment_test
oss << *i++ << ' ';
}
BOOST_CHECK( oss.str() == "apple orange pear peach grape plum ");
BOOST_TEST( oss.str() == "apple orange pear peach grape plum ");
}
// Test post-decrement
@ -193,7 +191,7 @@ test_opr<T, R, P>::post_decrement_test
oss << *i << ' ';
}
BOOST_CHECK( oss.str() == "plum grape peach pear orange apple ");
BOOST_TEST( oss.str() == "plum grape peach pear orange apple ");
}
// Test indirect structure referral
@ -211,7 +209,7 @@ test_opr<T, R, P>::indirect_referral_test
oss << i->size() << ' ';
}
BOOST_CHECK( oss.str() == "5 6 4 5 5 4 ");
BOOST_TEST( oss.str() == "5 6 4 5 5 4 ");
}
// Test offset addition
@ -230,7 +228,7 @@ test_opr<T, R, P>::offset_addition_test
oss << *i << ' ';
}
BOOST_CHECK( oss.str() == "apple pear grape ");
BOOST_TEST( oss.str() == "apple pear grape ");
}
// Test offset addition, in reverse order
@ -249,7 +247,7 @@ test_opr<T, R, P>::reverse_offset_addition_test
oss << *i << ' ';
}
BOOST_CHECK( oss.str() == "apple pear grape ");
BOOST_TEST( oss.str() == "apple pear grape ");
}
// Test offset subtraction
@ -272,7 +270,7 @@ test_opr<T, R, P>::offset_subtraction_test
}
}
BOOST_CHECK( oss.str() == "grape pear apple ");
BOOST_TEST( oss.str() == "grape pear apple ");
}
// Test comparisons
@ -296,10 +294,10 @@ test_opr<T, R, P>::comparison_test
{
ptrdiff_t const j_offset = j - fruit_begin;
BOOST_CHECK( (i != j) == (i_offset != j_offset) );
BOOST_CHECK( (i > j) == (i_offset > j_offset) );
BOOST_CHECK( (i <= j) == (i_offset <= j_offset) );
BOOST_CHECK( (i >= j) == (i_offset >= j_offset) );
BOOST_TEST( (i != j) == (i_offset != j_offset) );
BOOST_TEST( (i > j) == (i_offset > j_offset) );
BOOST_TEST( (i <= j) == (i_offset <= j_offset) );
BOOST_TEST( (i >= j) == (i_offset >= j_offset) );
}
}
cout << std::endl;
@ -320,5 +318,5 @@ test_opr<T, R, P>::indexing_test
oss << fruit_begin[ k ] << ' ';
}
BOOST_CHECK( oss.str() == "apple orange pear peach grape plum ");
BOOST_TEST( oss.str() == "apple orange pear peach grape plum ");
}

View File

@ -0,0 +1,59 @@
/*
Copyright 2020 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_CONSTEXPR) && \
(!defined(BOOST_MSVC) || (BOOST_MSVC >= 1922))
#include <boost/operators.hpp>
#include <boost/static_assert.hpp>
namespace {
class Value
: boost::operators<Value> {
public:
BOOST_OPERATORS_CONSTEXPR explicit Value(int v)
: v_(v) { }
BOOST_OPERATORS_CONSTEXPR bool
operator<(const Value& x) const {
return v_ < x.v_;
}
BOOST_OPERATORS_CONSTEXPR bool
operator==(const Value& x) const {
return v_ == x.v_;
}
private:
int v_;
};
} // namespace
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) == Value(2)));
BOOST_STATIC_ASSERT(Value(1) != Value(2));
BOOST_STATIC_ASSERT(Value(1) < Value(2));
BOOST_STATIC_ASSERT(Value(1) <= Value(2));
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) > Value(2)));
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) >= Value(2)));
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(2) == Value(1)));
BOOST_STATIC_ASSERT(Value(2) != Value(1));
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(2) < Value(1)));
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(2) <= Value(1)));
BOOST_STATIC_ASSERT(Value(2) > Value(1));
BOOST_STATIC_ASSERT(Value(2) >= Value(1));
BOOST_STATIC_ASSERT(Value(1) == Value(1));
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) != Value(1)));
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) < Value(1)));
BOOST_STATIC_ASSERT(Value(1) <= Value(1));
BOOST_STATIC_ASSERT(!static_cast<bool>(Value(1) > Value(1)));
BOOST_STATIC_ASSERT(Value(1) >= Value(1));
#endif

View File

@ -21,17 +21,13 @@
// 12 Dec 99 Minor update, output confirmation message.
// 15 Nov 99 Initial version
#define BOOST_INCLUDE_MAIN
#include <boost/config.hpp> // for BOOST_MSVC
#include <boost/cstdlib.hpp> // for boost::exit_success
#include <boost/operators.hpp> // for the tested items
#include <boost/random/linear_congruential.hpp> // for boost::minstd_rand
#include <boost/test/test_tools.hpp> // for main
#include <boost/utility/detail/minstd_rand.hpp> // for boost::detail::minstd_rand
#include <boost/core/lightweight_test.hpp>
#include <iostream> // for std::cout (std::endl indirectly)
namespace
{
// avoiding a template version of true_value so as to not confuse VC++
@ -53,9 +49,9 @@ namespace
void operator!() const;
public:
convertible_to_bool( const bool value ) : _value( value ) {}
convertible_to_bool( const bool value ) : _value( value ) {}
operator unspecified_bool_type() const
operator unspecified_bool_type() const
{ return _value ? &convertible_to_bool::_value : 0; }
};
@ -67,14 +63,14 @@ namespace
, boost::shiftable<Wrapped1<T> >
{
public:
explicit Wrapped1( T v = T() ) : _value(v) {}
T value() const { return _value; }
explicit Wrapped1( T v = T() ) : _value(v) {}
T value() const { return _value; }
convertible_to_bool operator<(const Wrapped1& x) const
convertible_to_bool operator<(const Wrapped1& x) const
{ return _value < x._value; }
convertible_to_bool operator==(const Wrapped1& x) const
convertible_to_bool operator==(const Wrapped1& x) const
{ return _value == x._value; }
Wrapped1& operator+=(const Wrapped1& x)
{ _value += x._value; return *this; }
Wrapped1& operator-=(const Wrapped1& x)
@ -95,14 +91,14 @@ namespace
{ _value <<= x._value; return *this; }
Wrapped1& operator>>=(const Wrapped1& x)
{ _value >>= x._value; return *this; }
Wrapped1& operator++() { ++_value; return *this; }
Wrapped1& operator--() { --_value; return *this; }
Wrapped1& operator++() { ++_value; return *this; }
Wrapped1& operator--() { --_value; return *this; }
private:
T _value;
};
template <class T>
T true_value(Wrapped1<T> x) { return x.value(); }
T true_value(Wrapped1<T> x) { return x.value(); }
template <class T, class U>
class Wrapped2
@ -119,7 +115,7 @@ namespace
{ return _value < x._value; }
convertible_to_bool operator==(const Wrapped2& x) const
{ return _value == x._value; }
Wrapped2& operator+=(const Wrapped2& x)
{ _value += x._value; return *this; }
Wrapped2& operator-=(const Wrapped2& x)
@ -142,7 +138,7 @@ namespace
{ _value >>= x._value; return *this; }
Wrapped2& operator++() { ++_value; return *this; }
Wrapped2& operator--() { --_value; return *this; }
convertible_to_bool operator<(U u) const
{ return _value < u; }
convertible_to_bool operator>(U u) const
@ -166,7 +162,7 @@ namespace
};
template <class T, class U>
T true_value(Wrapped2<T,U> x) { return x.value(); }
template <class T>
class Wrapped3
: boost::equivalent<Wrapped3<T> >
@ -179,12 +175,12 @@ namespace
convertible_to_bool operator<(const Wrapped3& x) const
{ return _value < x._value; }
private:
T _value;
};
template <class T>
T true_value(Wrapped3<T> x) { return x.value(); }
T true_value(Wrapped3<T> x) { return x.value(); }
template <class T, class U>
class Wrapped4
@ -201,7 +197,7 @@ namespace
convertible_to_bool operator<(const Wrapped4& x) const
{ return _value < x._value; }
convertible_to_bool operator<(U u) const
{ return _value < u; }
convertible_to_bool operator>(U u) const
@ -212,7 +208,7 @@ namespace
};
template <class T, class U>
T true_value(Wrapped4<T,U> x) { return x.value(); }
// U must be convertible to T
template <class T, class U>
class Wrapped5
@ -252,7 +248,7 @@ namespace
};
template <class T, class U>
T true_value(Wrapped5<T,U> x) { return x.value(); }
// U must be convertible to T
template <class T, class U>
class Wrapped6
@ -294,7 +290,7 @@ namespace
};
template <class T, class U>
T true_value(Wrapped6<T,U> x) { return x.value(); }
// MyInt uses only the single template-argument form of all_operators<>
typedef Wrapped1<int> MyInt;
@ -311,19 +307,19 @@ namespace
template <class X1, class Y1, class X2, class Y2>
void sanity_check(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
BOOST_CHECK( true_value(y1) == true_value(y2) );
BOOST_CHECK( true_value(x1) == true_value(x2) );
BOOST_TEST( true_value(y1) == true_value(y2) );
BOOST_TEST( true_value(x1) == true_value(x2) );
}
template <class X1, class Y1, class X2, class Y2>
void test_less_than_comparable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
BOOST_CHECK( static_cast<bool>(x1 < y1) == static_cast<bool>(x2 < y2) );
BOOST_CHECK( static_cast<bool>(x1 <= y1) == static_cast<bool>(x2 <= y2) );
BOOST_CHECK( static_cast<bool>(x1 >= y1) == static_cast<bool>(x2 >= y2) );
BOOST_CHECK( static_cast<bool>(x1 > y1) == static_cast<bool>(x2 > y2) );
BOOST_TEST( static_cast<bool>(x1 < y1) == static_cast<bool>(x2 < y2) );
BOOST_TEST( static_cast<bool>(x1 <= y1) == static_cast<bool>(x2 <= y2) );
BOOST_TEST( static_cast<bool>(x1 >= y1) == static_cast<bool>(x2 >= y2) );
BOOST_TEST( static_cast<bool>(x1 > y1) == static_cast<bool>(x2 > y2) );
}
template <class X1, class Y1, class X2, class Y2>
void test_less_than_comparable(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
@ -335,10 +331,10 @@ namespace
template <class X1, class Y1, class X2, class Y2>
void test_equality_comparable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
BOOST_CHECK( static_cast<bool>(x1 == y1) == static_cast<bool>(x2 == y2) );
BOOST_CHECK( static_cast<bool>(x1 != y1) == static_cast<bool>(x2 != y2) );
BOOST_TEST( static_cast<bool>(x1 == y1) == static_cast<bool>(x2 == y2) );
BOOST_TEST( static_cast<bool>(x1 != y1) == static_cast<bool>(x2 != y2) );
}
template <class X1, class Y1, class X2, class Y2>
void test_equality_comparable(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
@ -350,9 +346,9 @@ namespace
template <class X1, class Y1, class X2, class Y2>
void test_multipliable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
BOOST_CHECK( (x1 * y1).value() == (x2 * y2) );
BOOST_TEST( (x1 * y1).value() == (x2 * y2) );
}
template <class X1, class Y1, class X2, class Y2>
void test_multipliable(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
@ -361,21 +357,21 @@ namespace
test_multipliable_aux( y1, x1, y2, x2 );
}
template <class A, class B>
void test_value_equality(A a, B b)
{
BOOST_CHECK(a.value() == b);
}
template <class A, class B>
void test_value_equality(A a, B b)
{
BOOST_TEST(a.value() == b);
}
#define TEST_OP_R(op) test_value_equality(x1 op y1, x2 op y2)
#define TEST_OP_L(op) test_value_equality(y1 op x1, y2 op x2)
template <class X1, class Y1, class X2, class Y2>
void test_addable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
TEST_OP_R(+);
}
template <class X1, class Y1, class X2, class Y2>
void test_addable(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
@ -405,7 +401,7 @@ namespace
if ( y2 != 0 )
TEST_OP_R(/);
}
template <class X1, class Y1, class X2, class Y2>
void test_dividable_left(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
@ -421,7 +417,7 @@ namespace
if ( y2 != 0 )
TEST_OP_R(%);
}
template <class X1, class Y1, class X2, class Y2>
void test_modable_left(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
@ -435,7 +431,7 @@ namespace
{
TEST_OP_R(^);
}
template <class X1, class Y1, class X2, class Y2>
void test_xorable(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
@ -443,13 +439,13 @@ namespace
test_xorable_aux( x1, y1, x2, y2 );
test_xorable_aux( y1, x1, y2, x2 );
}
template <class X1, class Y1, class X2, class Y2>
void test_andable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
TEST_OP_R(&);
}
template <class X1, class Y1, class X2, class Y2>
void test_andable(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
@ -457,13 +453,13 @@ namespace
test_andable_aux( x1, y1, x2, y2 );
test_andable_aux( y1, x1, y2, x2 );
}
template <class X1, class Y1, class X2, class Y2>
void test_orable_aux(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
TEST_OP_R(|);
}
template <class X1, class Y1, class X2, class Y2>
void test_orable(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
@ -471,37 +467,37 @@ namespace
test_orable_aux( x1, y1, x2, y2 );
test_orable_aux( y1, x1, y2, x2 );
}
template <class X1, class Y1, class X2, class Y2>
void test_left_shiftable(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
sanity_check( x1, y1, x2, y2 );
TEST_OP_R(<<);
}
template <class X1, class Y1, class X2, class Y2>
void test_right_shiftable(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
sanity_check( x1, y1, x2, y2 );
TEST_OP_R(>>);
}
template <class X1, class X2>
void test_incrementable(X1 x1, X2 x2)
{
sanity_check( x1, x1, x2, x2 );
BOOST_CHECK( (x1++).value() == x2++ );
BOOST_CHECK( x1.value() == x2 );
BOOST_TEST( (x1++).value() == x2++ );
BOOST_TEST( x1.value() == x2 );
}
template <class X1, class X2>
void test_decrementable(X1 x1, X2 x2)
{
sanity_check( x1, x1, x2, x2 );
BOOST_CHECK( (x1--).value() == x2-- );
BOOST_CHECK( x1.value() == x2 );
BOOST_TEST( (x1--).value() == x2-- );
BOOST_TEST( x1.value() == x2 );
}
template <class X1, class Y1, class X2, class Y2>
void test_all(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
@ -520,7 +516,7 @@ namespace
test_incrementable( x1, x2 );
test_decrementable( x1, x2 );
}
template <class X1, class Y1, class X2, class Y2>
void test_left(X1 x1, Y1 y1, X2 x2, Y2 y2)
{
@ -532,12 +528,12 @@ namespace
template <class Big, class Small>
struct tester
{
void operator()(boost::minstd_rand& randomizer) const
void operator()(boost::detail::minstd_rand& randomizer) const
{
Big b1 = Big( randomizer() );
Big b2 = Big( randomizer() );
Small s = Small( randomizer() );
test_all( Wrapped1<Big>(b1), Wrapped1<Big>(b2), b1, b2 );
test_all( Wrapped2<Big, Small>(b1), s, b1, s );
}
@ -546,11 +542,11 @@ namespace
template <class Big, class Small>
struct tester_left
{
void operator()(boost::minstd_rand& randomizer) const
void operator()(boost::detail::minstd_rand& randomizer) const
{
Big b1 = Big( randomizer() );
Small s = Small( randomizer() );
test_left( Wrapped6<Big, Small>(b1), s, b1, s );
}
};
@ -603,10 +599,10 @@ template Wrapped6<unsigned long, unsigned char>;
template Wrapped6<unsigned int, unsigned char>;
#endif
#define PRIVATE_EXPR_TEST(e, t) BOOST_CHECK( ((e), (t)) )
#define PRIVATE_EXPR_TEST(e, t) BOOST_TEST( ((e), (t)) )
int
test_main( int , char * [] )
main()
{
using std::cout;
using std::endl;
@ -615,18 +611,20 @@ test_main( int , char * [] )
Point x;
x = x + Point(3, 4);
x = x - Point(3, 4);
cout << "Created point, and operated on it." << endl;
#if !defined(UBSAN)
// Using random values produce UB in various tests, such as shifting by more than the left operand capacity or signed integer overflows
for (int n = 0; n < 1000; ++n) // was 10,000 but took too long (Beman)
{
boost::minstd_rand r;
boost::detail::minstd_rand r;
tester<long, int>()(r);
tester<long, signed char>()(r);
tester<long, long>()(r);
tester<int, int>()(r);
tester<int, signed char>()(r);
tester<unsigned long, unsigned int>()(r);
tester<unsigned long, unsigned char>()(r);
tester<unsigned long, unsigned long>()(r);
@ -641,29 +639,30 @@ test_main( int , char * [] )
tester_left<unsigned long, unsigned char>()(r);
tester_left<unsigned int, unsigned char>()(r);
}
cout << "Did random tester loop." << endl;
#endif // !defined(UBSAN)
MyInt i1(1);
MyInt i2(2);
MyInt i;
BOOST_CHECK( i1.value() == 1 );
BOOST_CHECK( i2.value() == 2 );
BOOST_CHECK( i.value() == 0 );
BOOST_TEST( i1.value() == 1 );
BOOST_TEST( i2.value() == 2 );
BOOST_TEST( i.value() == 0 );
cout << "Created MyInt objects.\n";
PRIVATE_EXPR_TEST( (i = i2), (i.value() == 2) );
BOOST_CHECK( static_cast<bool>(i2 == i) );
BOOST_CHECK( static_cast<bool>(i1 != i2) );
BOOST_CHECK( static_cast<bool>(i1 < i2) );
BOOST_CHECK( static_cast<bool>(i1 <= i2) );
BOOST_CHECK( static_cast<bool>(i <= i2) );
BOOST_CHECK( static_cast<bool>(i2 > i1) );
BOOST_CHECK( static_cast<bool>(i2 >= i1) );
BOOST_CHECK( static_cast<bool>(i2 >= i) );
BOOST_TEST( static_cast<bool>(i2 == i) );
BOOST_TEST( static_cast<bool>(i1 != i2) );
BOOST_TEST( static_cast<bool>(i1 < i2) );
BOOST_TEST( static_cast<bool>(i1 <= i2) );
BOOST_TEST( static_cast<bool>(i <= i2) );
BOOST_TEST( static_cast<bool>(i2 > i1) );
BOOST_TEST( static_cast<bool>(i2 >= i1) );
BOOST_TEST( static_cast<bool>(i2 >= i) );
PRIVATE_EXPR_TEST( (i = i1 + i2), (i.value() == 3) );
PRIVATE_EXPR_TEST( (i = i + i2), (i.value() == 5) );
@ -687,197 +686,197 @@ test_main( int , char * [] )
MyLong j2(2);
MyLong j;
BOOST_CHECK( j1.value() == 1 );
BOOST_CHECK( j2.value() == 2 );
BOOST_CHECK( j.value() == 0 );
BOOST_TEST( j1.value() == 1 );
BOOST_TEST( j2.value() == 2 );
BOOST_TEST( j.value() == 0 );
cout << "Created MyLong objects.\n";
PRIVATE_EXPR_TEST( (j = j2), (j.value() == 2) );
BOOST_CHECK( static_cast<bool>(j2 == j) );
BOOST_CHECK( static_cast<bool>(2 == j) );
BOOST_CHECK( static_cast<bool>(j2 == 2) );
BOOST_CHECK( static_cast<bool>(j == j2) );
BOOST_CHECK( static_cast<bool>(j1 != j2) );
BOOST_CHECK( static_cast<bool>(j1 != 2) );
BOOST_CHECK( static_cast<bool>(1 != j2) );
BOOST_CHECK( static_cast<bool>(j1 < j2) );
BOOST_CHECK( static_cast<bool>(1 < j2) );
BOOST_CHECK( static_cast<bool>(j1 < 2) );
BOOST_CHECK( static_cast<bool>(j1 <= j2) );
BOOST_CHECK( static_cast<bool>(1 <= j2) );
BOOST_CHECK( static_cast<bool>(j1 <= j) );
BOOST_CHECK( static_cast<bool>(j <= j2) );
BOOST_CHECK( static_cast<bool>(2 <= j2) );
BOOST_CHECK( static_cast<bool>(j <= 2) );
BOOST_CHECK( static_cast<bool>(j2 > j1) );
BOOST_CHECK( static_cast<bool>(2 > j1) );
BOOST_CHECK( static_cast<bool>(j2 > 1) );
BOOST_CHECK( static_cast<bool>(j2 >= j1) );
BOOST_CHECK( static_cast<bool>(2 >= j1) );
BOOST_CHECK( static_cast<bool>(j2 >= 1) );
BOOST_CHECK( static_cast<bool>(j2 >= j) );
BOOST_CHECK( static_cast<bool>(2 >= j) );
BOOST_CHECK( static_cast<bool>(j2 >= 2) );
BOOST_CHECK( static_cast<bool>((j1 + 2) == 3) );
BOOST_CHECK( static_cast<bool>((1 + j2) == 3) );
BOOST_TEST( static_cast<bool>(j2 == j) );
BOOST_TEST( static_cast<bool>(2 == j) );
BOOST_TEST( static_cast<bool>(j2 == 2) );
BOOST_TEST( static_cast<bool>(j == j2) );
BOOST_TEST( static_cast<bool>(j1 != j2) );
BOOST_TEST( static_cast<bool>(j1 != 2) );
BOOST_TEST( static_cast<bool>(1 != j2) );
BOOST_TEST( static_cast<bool>(j1 < j2) );
BOOST_TEST( static_cast<bool>(1 < j2) );
BOOST_TEST( static_cast<bool>(j1 < 2) );
BOOST_TEST( static_cast<bool>(j1 <= j2) );
BOOST_TEST( static_cast<bool>(1 <= j2) );
BOOST_TEST( static_cast<bool>(j1 <= j) );
BOOST_TEST( static_cast<bool>(j <= j2) );
BOOST_TEST( static_cast<bool>(2 <= j2) );
BOOST_TEST( static_cast<bool>(j <= 2) );
BOOST_TEST( static_cast<bool>(j2 > j1) );
BOOST_TEST( static_cast<bool>(2 > j1) );
BOOST_TEST( static_cast<bool>(j2 > 1) );
BOOST_TEST( static_cast<bool>(j2 >= j1) );
BOOST_TEST( static_cast<bool>(2 >= j1) );
BOOST_TEST( static_cast<bool>(j2 >= 1) );
BOOST_TEST( static_cast<bool>(j2 >= j) );
BOOST_TEST( static_cast<bool>(2 >= j) );
BOOST_TEST( static_cast<bool>(j2 >= 2) );
BOOST_TEST( static_cast<bool>((j1 + 2) == 3) );
BOOST_TEST( static_cast<bool>((1 + j2) == 3) );
PRIVATE_EXPR_TEST( (j = j1 + j2), (j.value() == 3) );
BOOST_CHECK( static_cast<bool>((j + 2) == 5) );
BOOST_CHECK( static_cast<bool>((3 + j2) == 5) );
BOOST_TEST( static_cast<bool>((j + 2) == 5) );
BOOST_TEST( static_cast<bool>((3 + j2) == 5) );
PRIVATE_EXPR_TEST( (j = j + j2), (j.value() == 5) );
BOOST_CHECK( static_cast<bool>((j - 1) == 4) );
BOOST_TEST( static_cast<bool>((j - 1) == 4) );
PRIVATE_EXPR_TEST( (j = j - j1), (j.value() == 4) );
BOOST_CHECK( static_cast<bool>((j * 2) == 8) );
BOOST_CHECK( static_cast<bool>((4 * j2) == 8) );
BOOST_TEST( static_cast<bool>((j * 2) == 8) );
BOOST_TEST( static_cast<bool>((4 * j2) == 8) );
PRIVATE_EXPR_TEST( (j = j * j2), (j.value() == 8) );
BOOST_CHECK( static_cast<bool>((j / 2) == 4) );
BOOST_TEST( static_cast<bool>((j / 2) == 4) );
PRIVATE_EXPR_TEST( (j = j / j2), (j.value() == 4) );
BOOST_CHECK( static_cast<bool>((j % 3) == 1) );
BOOST_TEST( static_cast<bool>((j % 3) == 1) );
PRIVATE_EXPR_TEST( (j = j % ( j - j1 )), (j.value() == 1) );
PRIVATE_EXPR_TEST( (j = j2 + j2), (j.value() == 4) );
BOOST_CHECK( static_cast<bool>((1 | j2 | j) == 7) );
BOOST_CHECK( static_cast<bool>((j1 | 2 | j) == 7) );
BOOST_CHECK( static_cast<bool>((j1 | j2 | 4) == 7) );
BOOST_TEST( static_cast<bool>((1 | j2 | j) == 7) );
BOOST_TEST( static_cast<bool>((j1 | 2 | j) == 7) );
BOOST_TEST( static_cast<bool>((j1 | j2 | 4) == 7) );
PRIVATE_EXPR_TEST( (j = j1 | j2 | j), (j.value() == 7) );
BOOST_CHECK( static_cast<bool>((7 & j2) == 2) );
BOOST_CHECK( static_cast<bool>((j & 2) == 2) );
BOOST_TEST( static_cast<bool>((7 & j2) == 2) );
BOOST_TEST( static_cast<bool>((j & 2) == 2) );
PRIVATE_EXPR_TEST( (j = j & j2), (j.value() == 2) );
PRIVATE_EXPR_TEST( (j = j | j1), (j.value() == 3) );
BOOST_CHECK( static_cast<bool>((3 ^ j1) == 2) );
BOOST_CHECK( static_cast<bool>((j ^ 1) == 2) );
BOOST_TEST( static_cast<bool>((3 ^ j1) == 2) );
BOOST_TEST( static_cast<bool>((j ^ 1) == 2) );
PRIVATE_EXPR_TEST( (j = j ^ j1), (j.value() == 2) );
PRIVATE_EXPR_TEST( (j = ( j + j1 ) * ( j2 | j1 )), (j.value() == 9) );
BOOST_CHECK( static_cast<bool>((j1 << 2) == 4) );
BOOST_CHECK( static_cast<bool>((j2 << 1) == 4) );
BOOST_TEST( static_cast<bool>((j1 << 2) == 4) );
BOOST_TEST( static_cast<bool>((j2 << 1) == 4) );
PRIVATE_EXPR_TEST( (j = j1 << j2), (j.value() == 4) );
BOOST_CHECK( static_cast<bool>((j >> 2) == 1) );
BOOST_CHECK( static_cast<bool>((j2 >> 1) == 1) );
BOOST_TEST( static_cast<bool>((j >> 2) == 1) );
BOOST_TEST( static_cast<bool>((j2 >> 1) == 1) );
PRIVATE_EXPR_TEST( (j = j2 >> j1), (j.value() == 1) );
cout << "Performed tests on MyLong objects.\n";
MyChar k1(1);
MyChar k2(2);
MyChar k;
BOOST_CHECK( k1.value() == 1 );
BOOST_CHECK( k2.value() == 2 );
BOOST_CHECK( k.value() == 0 );
BOOST_TEST( k1.value() == 1 );
BOOST_TEST( k2.value() == 2 );
BOOST_TEST( k.value() == 0 );
cout << "Created MyChar objects.\n";
PRIVATE_EXPR_TEST( (k = k2), (k.value() == 2) );
BOOST_CHECK( static_cast<bool>(k2 == k) );
BOOST_CHECK( static_cast<bool>(k1 != k2) );
BOOST_CHECK( static_cast<bool>(k1 < k2) );
BOOST_CHECK( static_cast<bool>(k1 <= k2) );
BOOST_CHECK( static_cast<bool>(k <= k2) );
BOOST_CHECK( static_cast<bool>(k2 > k1) );
BOOST_CHECK( static_cast<bool>(k2 >= k1) );
BOOST_CHECK( static_cast<bool>(k2 >= k) );
BOOST_TEST( static_cast<bool>(k2 == k) );
BOOST_TEST( static_cast<bool>(k1 != k2) );
BOOST_TEST( static_cast<bool>(k1 < k2) );
BOOST_TEST( static_cast<bool>(k1 <= k2) );
BOOST_TEST( static_cast<bool>(k <= k2) );
BOOST_TEST( static_cast<bool>(k2 > k1) );
BOOST_TEST( static_cast<bool>(k2 >= k1) );
BOOST_TEST( static_cast<bool>(k2 >= k) );
cout << "Performed tests on MyChar objects.\n";
MyShort l1(1);
MyShort l2(2);
MyShort l;
BOOST_CHECK( l1.value() == 1 );
BOOST_CHECK( l2.value() == 2 );
BOOST_CHECK( l.value() == 0 );
BOOST_TEST( l1.value() == 1 );
BOOST_TEST( l2.value() == 2 );
BOOST_TEST( l.value() == 0 );
cout << "Created MyShort objects.\n";
PRIVATE_EXPR_TEST( (l = l2), (l.value() == 2) );
BOOST_CHECK( static_cast<bool>(l2 == l) );
BOOST_CHECK( static_cast<bool>(2 == l) );
BOOST_CHECK( static_cast<bool>(l2 == 2) );
BOOST_CHECK( static_cast<bool>(l == l2) );
BOOST_CHECK( static_cast<bool>(l1 != l2) );
BOOST_CHECK( static_cast<bool>(l1 != 2) );
BOOST_CHECK( static_cast<bool>(1 != l2) );
BOOST_CHECK( static_cast<bool>(l1 < l2) );
BOOST_CHECK( static_cast<bool>(1 < l2) );
BOOST_CHECK( static_cast<bool>(l1 < 2) );
BOOST_CHECK( static_cast<bool>(l1 <= l2) );
BOOST_CHECK( static_cast<bool>(1 <= l2) );
BOOST_CHECK( static_cast<bool>(l1 <= l) );
BOOST_CHECK( static_cast<bool>(l <= l2) );
BOOST_CHECK( static_cast<bool>(2 <= l2) );
BOOST_CHECK( static_cast<bool>(l <= 2) );
BOOST_CHECK( static_cast<bool>(l2 > l1) );
BOOST_CHECK( static_cast<bool>(2 > l1) );
BOOST_CHECK( static_cast<bool>(l2 > 1) );
BOOST_CHECK( static_cast<bool>(l2 >= l1) );
BOOST_CHECK( static_cast<bool>(2 >= l1) );
BOOST_CHECK( static_cast<bool>(l2 >= 1) );
BOOST_CHECK( static_cast<bool>(l2 >= l) );
BOOST_CHECK( static_cast<bool>(2 >= l) );
BOOST_CHECK( static_cast<bool>(l2 >= 2) );
BOOST_TEST( static_cast<bool>(l2 == l) );
BOOST_TEST( static_cast<bool>(2 == l) );
BOOST_TEST( static_cast<bool>(l2 == 2) );
BOOST_TEST( static_cast<bool>(l == l2) );
BOOST_TEST( static_cast<bool>(l1 != l2) );
BOOST_TEST( static_cast<bool>(l1 != 2) );
BOOST_TEST( static_cast<bool>(1 != l2) );
BOOST_TEST( static_cast<bool>(l1 < l2) );
BOOST_TEST( static_cast<bool>(1 < l2) );
BOOST_TEST( static_cast<bool>(l1 < 2) );
BOOST_TEST( static_cast<bool>(l1 <= l2) );
BOOST_TEST( static_cast<bool>(1 <= l2) );
BOOST_TEST( static_cast<bool>(l1 <= l) );
BOOST_TEST( static_cast<bool>(l <= l2) );
BOOST_TEST( static_cast<bool>(2 <= l2) );
BOOST_TEST( static_cast<bool>(l <= 2) );
BOOST_TEST( static_cast<bool>(l2 > l1) );
BOOST_TEST( static_cast<bool>(2 > l1) );
BOOST_TEST( static_cast<bool>(l2 > 1) );
BOOST_TEST( static_cast<bool>(l2 >= l1) );
BOOST_TEST( static_cast<bool>(2 >= l1) );
BOOST_TEST( static_cast<bool>(l2 >= 1) );
BOOST_TEST( static_cast<bool>(l2 >= l) );
BOOST_TEST( static_cast<bool>(2 >= l) );
BOOST_TEST( static_cast<bool>(l2 >= 2) );
cout << "Performed tests on MyShort objects.\n";
MyDoubleInt di1(1);
MyDoubleInt di2(2.);
MyDoubleInt half(0.5);
MyDoubleInt di;
MyDoubleInt tmp;
BOOST_CHECK( di1.value() == 1 );
BOOST_CHECK( di2.value() == 2 );
BOOST_CHECK( di2.value() == 2 );
BOOST_CHECK( di.value() == 0 );
BOOST_TEST( di1.value() == 1 );
BOOST_TEST( di2.value() == 2 );
BOOST_TEST( di2.value() == 2 );
BOOST_TEST( di.value() == 0 );
cout << "Created MyDoubleInt objects.\n";
PRIVATE_EXPR_TEST( (di = di2), (di.value() == 2) );
BOOST_CHECK( static_cast<bool>(di2 == di) );
BOOST_CHECK( static_cast<bool>(2 == di) );
BOOST_CHECK( static_cast<bool>(di == 2) );
BOOST_CHECK( static_cast<bool>(di1 < di2) );
BOOST_CHECK( static_cast<bool>(1 < di2) );
BOOST_CHECK( static_cast<bool>(di1 <= di2) );
BOOST_CHECK( static_cast<bool>(1 <= di2) );
BOOST_CHECK( static_cast<bool>(di2 > di1) );
BOOST_CHECK( static_cast<bool>(di2 > 1) );
BOOST_CHECK( static_cast<bool>(di2 >= di1) );
BOOST_CHECK( static_cast<bool>(di2 >= 1) );
BOOST_CHECK( static_cast<bool>(di1 / di2 == half) );
BOOST_CHECK( static_cast<bool>(di1 / 2 == half) );
BOOST_CHECK( static_cast<bool>(1 / di2 == half) );
BOOST_TEST( static_cast<bool>(di2 == di) );
BOOST_TEST( static_cast<bool>(2 == di) );
BOOST_TEST( static_cast<bool>(di == 2) );
BOOST_TEST( static_cast<bool>(di1 < di2) );
BOOST_TEST( static_cast<bool>(1 < di2) );
BOOST_TEST( static_cast<bool>(di1 <= di2) );
BOOST_TEST( static_cast<bool>(1 <= di2) );
BOOST_TEST( static_cast<bool>(di2 > di1) );
BOOST_TEST( static_cast<bool>(di2 > 1) );
BOOST_TEST( static_cast<bool>(di2 >= di1) );
BOOST_TEST( static_cast<bool>(di2 >= 1) );
BOOST_TEST( static_cast<bool>(di1 / di2 == half) );
BOOST_TEST( static_cast<bool>(di1 / 2 == half) );
BOOST_TEST( static_cast<bool>(1 / di2 == half) );
PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp/=2) == half) );
PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp/=di2) == half) );
BOOST_CHECK( static_cast<bool>(di1 * di2 == di2) );
BOOST_CHECK( static_cast<bool>(di1 * 2 == di2) );
BOOST_CHECK( static_cast<bool>(1 * di2 == di2) );
BOOST_TEST( static_cast<bool>(di1 * di2 == di2) );
BOOST_TEST( static_cast<bool>(di1 * 2 == di2) );
BOOST_TEST( static_cast<bool>(1 * di2 == di2) );
PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp*=2) == di2) );
PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp*=di2) == di2) );
BOOST_CHECK( static_cast<bool>(di2 - di1 == di1) );
BOOST_CHECK( static_cast<bool>(di2 - 1 == di1) );
BOOST_CHECK( static_cast<bool>(2 - di1 == di1) );
BOOST_TEST( static_cast<bool>(di2 - di1 == di1) );
BOOST_TEST( static_cast<bool>(di2 - 1 == di1) );
BOOST_TEST( static_cast<bool>(2 - di1 == di1) );
PRIVATE_EXPR_TEST( (tmp=di2), static_cast<bool>((tmp-=1) == di1) );
PRIVATE_EXPR_TEST( (tmp=di2), static_cast<bool>((tmp-=di1) == di1) );
BOOST_CHECK( static_cast<bool>(di1 + di1 == di2) );
BOOST_CHECK( static_cast<bool>(di1 + 1 == di2) );
BOOST_CHECK( static_cast<bool>(1 + di1 == di2) );
BOOST_TEST( static_cast<bool>(di1 + di1 == di2) );
BOOST_TEST( static_cast<bool>(di1 + 1 == di2) );
BOOST_TEST( static_cast<bool>(1 + di1 == di2) );
PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp+=1) == di2) );
PRIVATE_EXPR_TEST( (tmp=di1), static_cast<bool>((tmp+=di1) == di2) );
@ -888,52 +887,52 @@ test_main( int , char * [] )
MyLongInt li;
MyLongInt tmp2;
BOOST_CHECK( li1.value() == 1 );
BOOST_CHECK( li2.value() == 2 );
BOOST_CHECK( li.value() == 0 );
BOOST_TEST( li1.value() == 1 );
BOOST_TEST( li2.value() == 2 );
BOOST_TEST( li.value() == 0 );
cout << "Created MyLongInt objects.\n";
PRIVATE_EXPR_TEST( (li = li2), (li.value() == 2) );
BOOST_CHECK( static_cast<bool>(li2 == li) );
BOOST_CHECK( static_cast<bool>(2 == li) );
BOOST_CHECK( static_cast<bool>(li == 2) );
BOOST_CHECK( static_cast<bool>(li1 < li2) );
BOOST_CHECK( static_cast<bool>(1 < li2) );
BOOST_CHECK( static_cast<bool>(li1 <= li2) );
BOOST_CHECK( static_cast<bool>(1 <= li2) );
BOOST_CHECK( static_cast<bool>(li2 > li1) );
BOOST_CHECK( static_cast<bool>(li2 > 1) );
BOOST_CHECK( static_cast<bool>(li2 >= li1) );
BOOST_CHECK( static_cast<bool>(li2 >= 1) );
BOOST_CHECK( static_cast<bool>(li1 % li2 == li1) );
BOOST_CHECK( static_cast<bool>(li1 % 2 == li1) );
BOOST_CHECK( static_cast<bool>(1 % li2 == li1) );
BOOST_TEST( static_cast<bool>(li2 == li) );
BOOST_TEST( static_cast<bool>(2 == li) );
BOOST_TEST( static_cast<bool>(li == 2) );
BOOST_TEST( static_cast<bool>(li1 < li2) );
BOOST_TEST( static_cast<bool>(1 < li2) );
BOOST_TEST( static_cast<bool>(li1 <= li2) );
BOOST_TEST( static_cast<bool>(1 <= li2) );
BOOST_TEST( static_cast<bool>(li2 > li1) );
BOOST_TEST( static_cast<bool>(li2 > 1) );
BOOST_TEST( static_cast<bool>(li2 >= li1) );
BOOST_TEST( static_cast<bool>(li2 >= 1) );
BOOST_TEST( static_cast<bool>(li1 % li2 == li1) );
BOOST_TEST( static_cast<bool>(li1 % 2 == li1) );
BOOST_TEST( static_cast<bool>(1 % li2 == li1) );
PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2%=2) == li1) );
PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2%=li2) == li1) );
BOOST_CHECK( static_cast<bool>(li1 / li2 == 0) );
BOOST_CHECK( static_cast<bool>(li1 / 2 == 0) );
BOOST_CHECK( static_cast<bool>(1 / li2 == 0) );
BOOST_TEST( static_cast<bool>(li1 / li2 == 0) );
BOOST_TEST( static_cast<bool>(li1 / 2 == 0) );
BOOST_TEST( static_cast<bool>(1 / li2 == 0) );
PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2/=2) == 0) );
PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2/=li2) == 0) );
BOOST_CHECK( static_cast<bool>(li1 * li2 == li2) );
BOOST_CHECK( static_cast<bool>(li1 * 2 == li2) );
BOOST_CHECK( static_cast<bool>(1 * li2 == li2) );
BOOST_TEST( static_cast<bool>(li1 * li2 == li2) );
BOOST_TEST( static_cast<bool>(li1 * 2 == li2) );
BOOST_TEST( static_cast<bool>(1 * li2 == li2) );
PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2*=2) == li2) );
PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2*=li2) == li2) );
BOOST_CHECK( static_cast<bool>(li2 - li1 == li1) );
BOOST_CHECK( static_cast<bool>(li2 - 1 == li1) );
BOOST_CHECK( static_cast<bool>(2 - li1 == li1) );
BOOST_TEST( static_cast<bool>(li2 - li1 == li1) );
BOOST_TEST( static_cast<bool>(li2 - 1 == li1) );
BOOST_TEST( static_cast<bool>(2 - li1 == li1) );
PRIVATE_EXPR_TEST( (tmp2=li2), static_cast<bool>((tmp2-=1) == li1) );
PRIVATE_EXPR_TEST( (tmp2=li2), static_cast<bool>((tmp2-=li1) == li1) );
BOOST_CHECK( static_cast<bool>(li1 + li1 == li2) );
BOOST_CHECK( static_cast<bool>(li1 + 1 == li2) );
BOOST_CHECK( static_cast<bool>(1 + li1 == li2) );
BOOST_TEST( static_cast<bool>(li1 + li1 == li2) );
BOOST_TEST( static_cast<bool>(li1 + 1 == li2) );
BOOST_TEST( static_cast<bool>(1 + li1 == li2) );
PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2+=1) == li2) );
PRIVATE_EXPR_TEST( (tmp2=li1), static_cast<bool>((tmp2+=li1) == li2) );
cout << "Performed tests on MyLongInt objects.\n";
return boost::exit_success;
return boost::report_errors();
}

View File

@ -1,64 +0,0 @@
// Copyright 2003 The Trustees of Indiana University.
// 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)
// Shared container iterator adaptor
// Author: Ronald Garcia
// See http://boost.org/libs/utility/shared_container_iterator.html
// for documentation.
//
// shared_iterator_test.cpp - Regression tests for shared_container_iterator.
//
#include "boost/shared_container_iterator.hpp"
#include "boost/shared_ptr.hpp"
#include <vector>
#include <cassert>
struct resource {
static int count;
resource() { ++count; }
resource(resource const&) { ++count; }
~resource() { --count; }
};
int resource::count = 0;
typedef std::vector<resource> resources_t;
typedef boost::shared_container_iterator< resources_t > iterator;
void set_range(iterator& i, iterator& end) {
boost::shared_ptr< resources_t > objs(new resources_t());
for (int j = 0; j != 6; ++j)
objs->push_back(resource());
i = iterator(objs->begin(),objs);
end = iterator(objs->end(),objs);
assert(resource::count == 6);
}
int main() {
assert(resource::count == 0);
{
iterator i;
{
iterator end;
set_range(i,end);
assert(resource::count == 6);
}
assert(resource::count == 6);
}
assert(resource::count == 0);
return 0;
}

View File

@ -17,11 +17,9 @@
#error "Unsupported test"
#endif
#include "boost/test/minimal.hpp"
std::string makeatemp() { return "abc"; }
int test_main(int, char **)
int main()
{
boost::basic_string_ref<char> sv(makeatemp());
return 0;

View File

@ -13,17 +13,16 @@
#include <boost/utility/string_ref.hpp>
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#include <boost/core/lightweight_test.hpp>
typedef boost::string_ref string_ref;
// Should be equal
void interop ( const std::string &str, string_ref ref ) {
// BOOST_CHECK ( str == ref );
BOOST_CHECK ( str.size () == ref.size ());
BOOST_CHECK ( std::equal ( str.begin (), str.end (), ref.begin ()));
BOOST_CHECK ( std::equal ( str.rbegin (), str.rend (), ref.rbegin ()));
// BOOST_TEST ( str == ref );
BOOST_TEST ( str.size () == ref.size ());
BOOST_TEST ( std::equal ( str.begin (), str.end (), ref.begin ()));
BOOST_TEST ( std::equal ( str.rbegin (), str.rend (), ref.rbegin ()));
}
void null_tests ( const char *p ) {
@ -34,10 +33,10 @@ void null_tests ( const char *p ) {
string_ref sr4 ( p );
sr4.clear ();
BOOST_CHECK ( sr1 == sr2 );
BOOST_CHECK ( sr1 == sr3 );
BOOST_CHECK ( sr2 == sr3 );
BOOST_CHECK ( sr1 == sr4 );
BOOST_TEST ( sr1 == sr2 );
BOOST_TEST ( sr1 == sr3 );
BOOST_TEST ( sr2 == sr3 );
BOOST_TEST ( sr1 == sr4 );
}
// make sure that substrings work just like strings
@ -94,7 +93,7 @@ const char *test_strings [] = {
NULL
};
BOOST_AUTO_TEST_CASE( test_main )
int main()
{
const char **p = &test_strings[0];
@ -106,4 +105,6 @@ BOOST_AUTO_TEST_CASE( test_main )
p++;
}
return boost::report_errors();
}

View File

@ -12,8 +12,7 @@
#include <boost/utility/string_ref.hpp>
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#include <boost/core/lightweight_test.hpp>
typedef boost::string_ref string_ref;
@ -24,27 +23,27 @@ void ends_with ( const char *arg ) {
const char *p = arg;
while ( *p ) {
BOOST_CHECK ( sr.ends_with ( p ));
BOOST_TEST ( sr.ends_with ( p ));
++p;
}
while ( !sr2.empty ()) {
BOOST_CHECK ( sr.ends_with ( sr2 ));
BOOST_TEST ( sr.ends_with ( sr2 ));
sr2.remove_prefix (1);
}
sr2 = arg;
while ( !sr2.empty ()) {
BOOST_CHECK ( sr.ends_with ( sr2 ));
BOOST_TEST ( sr.ends_with ( sr2 ));
sr2.remove_prefix (1);
}
char ch = sz == 0 ? '\0' : arg [ sz - 1 ];
sr2 = arg;
if ( sz > 0 )
BOOST_CHECK ( sr2.ends_with ( ch ));
BOOST_CHECK ( !sr2.ends_with ( ++ch ));
BOOST_CHECK ( sr2.ends_with ( string_ref ()));
BOOST_TEST ( sr2.ends_with ( ch ));
BOOST_TEST ( !sr2.ends_with ( ++ch ));
BOOST_TEST ( sr2.ends_with ( string_ref ()));
}
void starts_with ( const char *arg ) {
@ -54,21 +53,21 @@ void starts_with ( const char *arg ) {
const char *p = arg + std::strlen ( arg ) - 1;
while ( p >= arg ) {
std::string foo ( arg, p + 1 );
BOOST_CHECK ( sr.starts_with ( foo ));
BOOST_TEST ( sr.starts_with ( foo ));
--p;
}
while ( !sr2.empty ()) {
BOOST_CHECK ( sr.starts_with ( sr2 ));
BOOST_TEST ( sr.starts_with ( sr2 ));
sr2.remove_suffix (1);
}
char ch = *arg;
sr2 = arg;
if ( sz > 0 )
BOOST_CHECK ( sr2.starts_with ( ch ));
BOOST_CHECK ( !sr2.starts_with ( ++ch ));
BOOST_CHECK ( sr2.starts_with ( string_ref ()));
BOOST_TEST ( sr2.starts_with ( ch ));
BOOST_TEST ( !sr2.starts_with ( ++ch ));
BOOST_TEST ( sr2.starts_with ( string_ref ()));
}
void reverse ( const char *arg ) {
@ -78,14 +77,14 @@ void reverse ( const char *arg ) {
string_ref sr2 ( string1 );
std::string string2 ( sr2.rbegin (), sr2.rend ());
BOOST_CHECK ( std::equal ( sr2.rbegin (), sr2.rend (), arg ));
BOOST_CHECK ( string2 == arg );
BOOST_CHECK ( std::equal ( sr1.begin (), sr1.end (), string2.begin ()));
BOOST_TEST ( std::equal ( sr2.rbegin (), sr2.rend (), arg ));
BOOST_TEST ( string2 == arg );
BOOST_TEST ( std::equal ( sr1.begin (), sr1.end (), string2.begin ()));
}
// This helper function eliminates signed vs. unsigned warnings
string_ref::size_type ptr_diff ( const char *res, const char *base ) {
BOOST_CHECK ( res >= base );
BOOST_TEST ( res >= base );
return static_cast<string_ref::size_type> ( res - base );
}
@ -94,12 +93,16 @@ void find ( const char *arg ) {
string_ref sr2;
const char *p;
// When we search for the empty string, we find it at position 0
BOOST_TEST ( sr1.find (sr2) == 0 );
BOOST_TEST ( sr1.rfind(sr2) == 0 );
// Look for each character in the string(searching from the start)
p = arg;
sr1 = arg;
while ( *p ) {
string_ref::size_type pos = sr1.find(*p);
BOOST_CHECK ( pos != string_ref::npos && ( pos <= ptr_diff ( p, arg )));
BOOST_TEST ( pos != string_ref::npos && ( pos <= ptr_diff ( p, arg )));
++p;
}
@ -108,7 +111,7 @@ void find ( const char *arg ) {
sr1 = arg;
while ( *p ) {
string_ref::size_type pos = sr1.rfind(*p);
BOOST_CHECK ( pos != string_ref::npos && pos < sr1.size () && ( pos >= ptr_diff ( p, arg )));
BOOST_TEST ( pos != string_ref::npos && pos < sr1.size () && ( pos >= ptr_diff ( p, arg )));
++p;
}
@ -118,7 +121,7 @@ void find ( const char *arg ) {
while ( *p && *(p+1)) {
string_ref sr3 ( p, 2 );
string_ref::size_type pos = sr1.find ( sr3 );
BOOST_CHECK ( pos != string_ref::npos && pos <= static_cast<string_ref::size_type>( p - arg ));
BOOST_TEST ( pos != string_ref::npos && pos <= static_cast<string_ref::size_type>( p - arg ));
p++;
}
@ -129,9 +132,9 @@ void find ( const char *arg ) {
for ( int ch = 1; ch < 256; ++ch ) {
string_ref::size_type pos = sr1.find(ch);
const char *strp = std::strchr ( arg, ch );
BOOST_CHECK (( strp == NULL ) == ( pos == string_ref::npos ));
BOOST_TEST (( strp == NULL ) == ( pos == string_ref::npos ));
if ( strp != NULL )
BOOST_CHECK ( ptr_diff ( strp, arg ) == pos );
BOOST_TEST ( ptr_diff ( strp, arg ) == pos );
}
sr1 = arg;
@ -141,9 +144,9 @@ void find ( const char *arg ) {
for ( int ch = 1; ch < 256; ++ch ) {
string_ref::size_type pos = sr1.rfind(ch);
const char *strp = std::strrchr ( arg, ch );
BOOST_CHECK (( strp == NULL ) == ( pos == string_ref::npos ));
BOOST_TEST (( strp == NULL ) == ( pos == string_ref::npos ));
if ( strp != NULL )
BOOST_CHECK ( ptr_diff ( strp, arg ) == pos );
BOOST_TEST ( ptr_diff ( strp, arg ) == pos );
}
@ -152,7 +155,7 @@ void find ( const char *arg ) {
sr1 = arg;
while ( !sr1.empty ()) {
string_ref::size_type pos = sr1.find(*p);
BOOST_CHECK ( pos == 0 );
BOOST_TEST ( pos == 0 );
sr1.remove_prefix (1);
++p;
}
@ -162,7 +165,7 @@ void find ( const char *arg ) {
p = arg + std::strlen ( arg ) - 1;
while ( !sr1.empty ()) {
string_ref::size_type pos = sr1.rfind(*p);
BOOST_CHECK ( pos == sr1.size () - 1 );
BOOST_TEST ( pos == sr1.size () - 1 );
sr1.remove_suffix (1);
--p;
}
@ -172,7 +175,7 @@ void find ( const char *arg ) {
p = arg;
while ( !sr1.empty ()) {
string_ref::size_type pos = sr1.find_first_of(*p);
BOOST_CHECK ( pos == 0 );
BOOST_TEST ( pos == 0 );
sr1.remove_prefix (1);
++p;
}
@ -183,7 +186,7 @@ void find ( const char *arg ) {
p = arg + std::strlen ( arg ) - 1;
while ( !sr1.empty ()) {
string_ref::size_type pos = sr1.find_last_of(*p);
BOOST_CHECK ( pos == sr1.size () - 1 );
BOOST_TEST ( pos == sr1.size () - 1 );
sr1.remove_suffix (1);
--p;
}
@ -192,8 +195,8 @@ void find ( const char *arg ) {
sr1 = arg;
sr2 = arg;
while ( !sr1.empty() ) {
BOOST_CHECK ( sr1.find_first_of ( sr2 ) == 0 );
BOOST_CHECK ( sr1.find_first_not_of ( sr2 ) == string_ref::npos );
BOOST_TEST ( sr1.find_first_of ( sr2 ) == 0 );
BOOST_TEST ( sr1.find_first_not_of ( sr2 ) == string_ref::npos );
sr1.remove_prefix ( 1 );
}
@ -202,14 +205,14 @@ void find ( const char *arg ) {
while ( *p ) {
string_ref::size_type pos1 = sr1.find_first_of(*p);
string_ref::size_type pos2 = sr1.find_first_not_of(*p);
BOOST_CHECK ( pos1 != string_ref::npos && pos1 < sr1.size () && pos1 <= ptr_diff ( p, arg ));
BOOST_TEST ( pos1 != string_ref::npos && pos1 < sr1.size () && pos1 <= ptr_diff ( p, arg ));
if ( pos2 != string_ref::npos ) {
for ( size_t i = 0 ; i < pos2; ++i )
BOOST_CHECK ( sr1[i] == *p );
BOOST_CHECK ( sr1 [ pos2 ] != *p );
BOOST_TEST ( sr1[i] == *p );
BOOST_TEST ( sr1 [ pos2 ] != *p );
}
BOOST_CHECK ( pos2 != pos1 );
BOOST_TEST ( pos2 != pos1 );
++p;
}
@ -217,8 +220,8 @@ void find ( const char *arg ) {
sr1 = arg;
sr2 = arg;
while ( !sr1.empty() ) {
BOOST_CHECK ( sr1.find_last_of ( sr2 ) == ( sr1.size () - 1 ));
BOOST_CHECK ( sr1.find_last_not_of ( sr2 ) == string_ref::npos );
BOOST_TEST ( sr1.find_last_of ( sr2 ) == ( sr1.size () - 1 ));
BOOST_TEST ( sr1.find_last_not_of ( sr2 ) == string_ref::npos );
sr1.remove_suffix ( 1 );
}
@ -227,15 +230,15 @@ void find ( const char *arg ) {
while ( *p ) {
string_ref::size_type pos1 = sr1.find_last_of(*p);
string_ref::size_type pos2 = sr1.find_last_not_of(*p);
BOOST_CHECK ( pos1 != string_ref::npos && pos1 < sr1.size () && pos1 >= ptr_diff ( p, arg ));
BOOST_CHECK ( pos2 == string_ref::npos || pos1 < sr1.size ());
BOOST_TEST ( pos1 != string_ref::npos && pos1 < sr1.size () && pos1 >= ptr_diff ( p, arg ));
BOOST_TEST ( pos2 == string_ref::npos || pos1 < sr1.size ());
if ( pos2 != string_ref::npos ) {
for ( size_t i = sr1.size () -1 ; i > pos2; --i )
BOOST_CHECK ( sr1[i] == *p );
BOOST_CHECK ( sr1 [ pos2 ] != *p );
BOOST_TEST ( sr1[i] == *p );
BOOST_TEST ( sr1 [ pos2 ] != *p );
}
BOOST_CHECK ( pos2 != pos1 );
BOOST_TEST ( pos2 != pos1 );
++p;
}
@ -251,11 +254,11 @@ void to_string ( const char *arg ) {
sr1 = arg;
// str2 = sr1.to_string<std::allocator<char> > ();
str2 = sr1.to_string ();
BOOST_CHECK ( str1 == str2 );
BOOST_TEST ( str1 == str2 );
#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
std::string str3 = static_cast<std::string> ( sr1 );
BOOST_CHECK ( str1 == str3 );
BOOST_TEST ( str1 == str3 );
#endif
}
@ -266,28 +269,28 @@ void compare ( const char *arg ) {
str1.assign ( arg );
sr1 = arg;
BOOST_CHECK ( sr1 == sr1); // compare string_ref and string_ref
BOOST_CHECK ( sr1 == str1); // compare string and string_ref
BOOST_CHECK ( str1 == sr1 ); // compare string_ref and string
BOOST_CHECK ( sr1 == arg ); // compare string_ref and pointer
BOOST_CHECK ( arg == sr1 ); // compare pointer and string_ref
BOOST_TEST ( sr1 == sr1); // compare string_ref and string_ref
BOOST_TEST ( sr1 == str1); // compare string and string_ref
BOOST_TEST ( str1 == sr1 ); // compare string_ref and string
BOOST_TEST ( sr1 == arg ); // compare string_ref and pointer
BOOST_TEST ( arg == sr1 ); // compare pointer and string_ref
if ( sr1.size () > 0 ) {
(*str1.rbegin())++;
BOOST_CHECK ( sr1 != str1 );
BOOST_CHECK ( str1 != sr1 );
BOOST_CHECK ( sr1 < str1 );
BOOST_CHECK ( sr1 <= str1 );
BOOST_CHECK ( str1 > sr1 );
BOOST_CHECK ( str1 >= sr1 );
BOOST_TEST ( sr1 != str1 );
BOOST_TEST ( str1 != sr1 );
BOOST_TEST ( sr1 < str1 );
BOOST_TEST ( sr1 <= str1 );
BOOST_TEST ( str1 > sr1 );
BOOST_TEST ( str1 >= sr1 );
(*str1.rbegin()) -= 2;
BOOST_CHECK ( sr1 != str1 );
BOOST_CHECK ( str1 != sr1 );
BOOST_CHECK ( sr1 > str1 );
BOOST_CHECK ( sr1 >= str1 );
BOOST_CHECK ( str1 < sr1 );
BOOST_CHECK ( str1 <= sr1 );
BOOST_TEST ( sr1 != str1 );
BOOST_TEST ( str1 != sr1 );
BOOST_TEST ( sr1 > str1 );
BOOST_TEST ( sr1 >= str1 );
BOOST_TEST ( str1 < sr1 );
BOOST_TEST ( str1 <= sr1 );
}
}
@ -301,7 +304,7 @@ const char *test_strings [] = {
NULL
};
BOOST_AUTO_TEST_CASE( test_main )
int main()
{
const char **p = &test_strings[0];
@ -315,4 +318,6 @@ BOOST_AUTO_TEST_CASE( test_main )
p++;
}
return boost::report_errors();
}

View File

@ -12,8 +12,6 @@
* \brief This header contains tests for stream operations of \c basic_string_ref.
*/
#define BOOST_TEST_MODULE string_ref_test_io
#include <boost/utility/string_ref.hpp>
#include <iomanip>
@ -23,23 +21,10 @@
#include <string>
#include <boost/config.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/core/lightweight_test.hpp>
typedef boost::mpl::vector<
char
#if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_STD_WSTREAMBUF) && !defined(BOOST_NO_INTRINSIC_WCHAR_T)
, wchar_t
#endif
/* Current implementations seem to be missing codecvt facets to convert chars to char16_t and char32_t even though the types are available.
#if !defined(BOOST_NO_CXX11_CHAR16_T)
, char16_t
#endif
#if !defined(BOOST_NO_CXX11_CHAR32_T)
, char32_t
#endif
*/
>::type char_types;
static const char* test_strings[] =
{
@ -72,7 +57,8 @@ struct context
};
// Test regular output
BOOST_AUTO_TEST_CASE_TEMPLATE(string_ref_output, CharT, char_types)
template<class CharT>
void test_string_ref_output()
{
typedef CharT char_type;
typedef std::basic_ostringstream< char_type > ostream_type;
@ -82,11 +68,12 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(string_ref_output, CharT, char_types)
ostream_type strm;
strm << string_ref_type(ctx.abcd);
BOOST_CHECK(strm.str() == ctx.abcd);
BOOST_TEST(strm.str() == ctx.abcd);
}
// Test support for padding
BOOST_AUTO_TEST_CASE_TEMPLATE(padding, CharT, char_types)
template<class CharT>
void test_padding()
{
typedef CharT char_type;
typedef std::basic_ostringstream< char_type > ostream_type;
@ -102,7 +89,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(padding, CharT, char_types)
ostream_type strm_correct;
strm_correct << ctx.begin << std::setw(8) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_TEST(strm_ref.str() == strm_correct.str());
}
// Test for long padding
@ -113,7 +100,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(padding, CharT, char_types)
ostream_type strm_correct;
strm_correct << ctx.begin << std::setw(100) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_TEST(strm_ref.str() == strm_correct.str());
}
// Test that short width does not truncate the string
@ -124,12 +111,13 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(padding, CharT, char_types)
ostream_type strm_correct;
strm_correct << ctx.begin << std::setw(1) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_TEST(strm_ref.str() == strm_correct.str());
}
}
// Test support for padding fill
BOOST_AUTO_TEST_CASE_TEMPLATE(padding_fill, CharT, char_types)
template<class CharT>
void test_padding_fill()
{
typedef CharT char_type;
typedef std::basic_ostringstream< char_type > ostream_type;
@ -143,11 +131,12 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(padding_fill, CharT, char_types)
ostream_type strm_correct;
strm_correct << ctx.begin << std::setfill(static_cast< char_type >('x')) << std::setw(8) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_TEST(strm_ref.str() == strm_correct.str());
}
// Test support for alignment
BOOST_AUTO_TEST_CASE_TEMPLATE(alignment, CharT, char_types)
template<class CharT>
void test_alignment()
{
typedef CharT char_type;
typedef std::basic_ostringstream< char_type > ostream_type;
@ -163,7 +152,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(alignment, CharT, char_types)
ostream_type strm_correct;
strm_correct << ctx.begin << std::left << std::setw(8) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_TEST(strm_ref.str() == strm_correct.str());
}
// Right alignment
@ -174,6 +163,22 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(alignment, CharT, char_types)
ostream_type strm_correct;
strm_correct << ctx.begin << std::right << std::setw(8) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_TEST(strm_ref.str() == strm_correct.str());
}
}
template<class CharT>
void test()
{
test_string_ref_output<CharT>();
test_padding<CharT>();
test_padding_fill<CharT>();
test_alignment<CharT>();
}
int main()
{
test<char>();
test<wchar_t>();
return boost::report_errors();
}

View File

@ -12,25 +12,19 @@
#include <cstddef> // for NULL, std::size_t, std::ptrdiff_t
#include <cstring> // for std::strchr and std::strcmp
#include <cstdlib> // for std::malloc and std::free
#include <cstdio> // for EOF
#include <boost/config.hpp>
#include <boost/utility/string_view.hpp>
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#if __cplusplus < 201402L
BOOST_AUTO_TEST_CASE( test_main ) {}
#else
#if __cplusplus >= 201402L
struct constexpr_char_traits
{
typedef char char_type;
typedef int int_type;
typedef std::streamoff off_type;
typedef std::streampos pos_type;
typedef std::mbstate_t state_type;
typedef char char_type;
typedef int int_type;
typedef std::streamoff off_type;
typedef std::streampos pos_type;
typedef std::mbstate_t state_type;
static void assign(char_type& c1, const char_type& c2) noexcept { c1 = c2; }
static constexpr bool eq(char_type c1, char_type c2) noexcept { return c1 == c2; }
@ -50,11 +44,11 @@ struct constexpr_char_traits
static constexpr int_type eof() noexcept { return EOF; }
};
// yields:
// 0 if for each i in [0,n), X::eq(s1[i],s2[i]) is true;
// else, a negative value if, for some j in [0,n), X::lt(s1[j],s2[j]) is true and
// for each i in [0,j) X::eq(s2[i],s2[i]) is true;
// else a positive value.
// yields:
// 0 if for each i in [0,n), X::eq(s1[i],s2[i]) is true;
// else, a negative value if, for some j in [0,n), X::lt(s1[j],s2[j]) is true and
// for each i in [0,j) X::eq(s2[i],s2[i]) is true;
// else a positive value.
constexpr int constexpr_char_traits::compare(const char_type* s1, const char_type* s2, size_t n) noexcept
{
for (; n != 0; --n, ++s1, ++s2)
@ -78,44 +72,44 @@ constexpr size_t constexpr_char_traits::length(const char_type* s) noexcept
typedef boost::basic_string_view<char, constexpr_char_traits> string_view;
BOOST_AUTO_TEST_CASE( test_main )
int main()
{
constexpr string_view sv1;
constexpr string_view sv2{"abc", 3}; // ptr, len
constexpr string_view sv3{"def"}; // ptr
constexpr const char *s1 = "";
constexpr const char *s2 = "abc";
static_assert( (sv1 == sv1), "" );
static_assert(!(sv1 == sv2), "" );
static_assert( (sv1 != sv2), "" );
static_assert( (sv1 < sv2), "" );
static_assert( (sv1 <= sv2), "" );
static_assert(!(sv1 > sv2), "" );
static_assert(!(sv1 >= sv2), "" );
constexpr const char *s1 = "";
constexpr const char *s2 = "abc";
static_assert(!(s1 == sv2), "" );
static_assert( (s1 != sv2), "" );
static_assert( (s1 < sv2), "" );
static_assert( (s1 <= sv2), "" );
static_assert(!(s1 > sv2), "" );
static_assert(!(s1 >= sv2), "" );
static_assert( (sv1 == sv1), "" );
static_assert(!(sv1 == s2), "" );
static_assert( (sv1 != s2), "" );
static_assert( (sv1 < s2), "" );
static_assert( (sv1 <= s2), "" );
static_assert(!(sv1 > s2), "" );
static_assert(!(sv1 >= s2), "" );
static_assert(!(sv1 == sv2), "" );
static_assert( (sv1 != sv2), "" );
static_assert( (sv1 < sv2), "" );
static_assert( (sv1 <= sv2), "" );
static_assert(!(sv1 > sv2), "" );
static_assert(!(sv1 >= sv2), "" );
static_assert( sv1.compare(sv2) < 0, "" );
static_assert( sv1.compare(sv1) == 0, "" );
static_assert( sv3.compare(sv1) > 0, "" );
static_assert(!(s1 == sv2), "" );
static_assert( (s1 != sv2), "" );
static_assert( (s1 < sv2), "" );
static_assert( (s1 <= sv2), "" );
static_assert(!(s1 > sv2), "" );
static_assert(!(s1 >= sv2), "" );
static_assert( sv1.compare(s2) < 0, "" );
static_assert( sv1.compare(s1) == 0, "" );
static_assert( sv3.compare(s1) > 0, "" );
static_assert(!(sv1 == s2), "" );
static_assert( (sv1 != s2), "" );
static_assert( (sv1 < s2), "" );
static_assert( (sv1 <= s2), "" );
static_assert(!(sv1 > s2), "" );
static_assert(!(sv1 >= s2), "" );
static_assert( sv1.compare(sv2) < 0, "" );
static_assert( sv1.compare(sv1) == 0, "" );
static_assert( sv3.compare(sv1) > 0, "" );
static_assert( sv1.compare(s2) < 0, "" );
static_assert( sv1.compare(s1) == 0, "" );
static_assert( sv3.compare(s1) > 0, "" );
}
#endif

View File

@ -17,11 +17,9 @@
#error "Unsupported test"
#endif
#include "boost/test/minimal.hpp"
std::string makeatemp() { return "abc"; }
int test_main(int, char **)
int main()
{
boost::basic_string_view<char> sv(makeatemp());
return 0;

View File

@ -12,18 +12,18 @@
#include <string>
#include <boost/utility/string_view.hpp>
#include <boost/container_hash/hash.hpp>
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#include <boost/core/lightweight_test.hpp>
typedef boost::string_view string_view;
// Should be equal
void interop ( const std::string &str, string_view ref ) {
// BOOST_CHECK ( str == ref );
BOOST_CHECK ( str.size () == ref.size ());
BOOST_CHECK ( std::equal ( str.begin (), str.end (), ref.begin ()));
BOOST_CHECK ( std::equal ( str.rbegin (), str.rend (), ref.rbegin ()));
// BOOST_TEST ( str == ref );
BOOST_TEST ( str.size () == ref.size ());
BOOST_TEST ( std::equal ( str.begin (), str.end (), ref.begin ()));
BOOST_TEST ( std::equal ( str.rbegin (), str.rend (), ref.rbegin ()));
}
void null_tests ( const char *p ) {
@ -34,10 +34,10 @@ void null_tests ( const char *p ) {
string_view sr4 ( p );
sr4.clear ();
BOOST_CHECK ( sr1 == sr2 );
BOOST_CHECK ( sr1 == sr3 );
BOOST_CHECK ( sr2 == sr3 );
BOOST_CHECK ( sr1 == sr4 );
BOOST_TEST ( sr1 == sr2 );
BOOST_TEST ( sr1 == sr3 );
BOOST_TEST ( sr2 == sr3 );
BOOST_TEST ( sr1 == sr4 );
}
// make sure that substrings work just like strings
@ -86,6 +86,14 @@ void test_remove ( const std::string &str ) {
}
}
void test_hash(const std::string& str) {
string_view ref = str;
BOOST_TEST(boost::hash_value(ref) == boost::hash_value(str));
boost::hash<std::string> hstr;
boost::hash<string_view> hsv;
BOOST_TEST(hsv(ref) == hstr(str));
}
const char *test_strings [] = {
"",
"1",
@ -94,7 +102,7 @@ const char *test_strings [] = {
NULL
};
BOOST_AUTO_TEST_CASE( test_main )
int main()
{
const char **p = &test_strings[0];
@ -103,7 +111,10 @@ BOOST_AUTO_TEST_CASE( test_main )
test_substr ( *p );
test_remove ( *p );
null_tests ( *p );
test_hash( *p );
p++;
}
return boost::report_errors();
}

View File

@ -16,8 +16,7 @@
#include <boost/utility/string_view.hpp>
#include <boost/config.hpp>
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#include <boost/core/lightweight_test.hpp>
typedef boost::string_view string_view;
@ -28,27 +27,27 @@ void ends_with ( const char *arg ) {
const char *p = arg;
while ( *p ) {
BOOST_CHECK ( sr.ends_with ( p ));
BOOST_TEST ( sr.ends_with ( p ));
++p;
}
while ( !sr2.empty ()) {
BOOST_CHECK ( sr.ends_with ( sr2 ));
BOOST_TEST ( sr.ends_with ( sr2 ));
sr2.remove_prefix (1);
}
sr2 = arg;
while ( !sr2.empty ()) {
BOOST_CHECK ( sr.ends_with ( sr2 ));
BOOST_TEST ( sr.ends_with ( sr2 ));
sr2.remove_prefix (1);
}
char ch = sz == 0 ? '\0' : arg [ sz - 1 ];
sr2 = arg;
if ( sz > 0 )
BOOST_CHECK ( sr2.ends_with ( ch ));
BOOST_CHECK ( !sr2.ends_with ( ++ch ));
BOOST_CHECK ( sr2.ends_with ( string_view()));
BOOST_TEST ( sr2.ends_with ( ch ));
BOOST_TEST ( !sr2.ends_with ( ++ch ));
BOOST_TEST ( sr2.ends_with ( string_view()));
}
void starts_with ( const char *arg ) {
@ -58,21 +57,21 @@ void starts_with ( const char *arg ) {
const char *p = arg + std::strlen ( arg ) - 1;
while ( p >= arg ) {
std::string foo ( arg, p + 1 );
BOOST_CHECK ( sr.starts_with ( foo ));
BOOST_TEST ( sr.starts_with ( foo ));
--p;
}
while ( !sr2.empty ()) {
BOOST_CHECK ( sr.starts_with ( sr2 ));
BOOST_TEST ( sr.starts_with ( sr2 ));
sr2.remove_suffix (1);
}
char ch = *arg;
sr2 = arg;
if ( sz > 0 )
BOOST_CHECK ( sr2.starts_with ( ch ));
BOOST_CHECK ( !sr2.starts_with ( ++ch ));
BOOST_CHECK ( sr2.starts_with ( string_view ()));
BOOST_TEST ( sr2.starts_with ( ch ));
BOOST_TEST ( !sr2.starts_with ( ++ch ));
BOOST_TEST ( sr2.starts_with ( string_view ()));
}
void reverse ( const char *arg ) {
@ -82,14 +81,14 @@ void reverse ( const char *arg ) {
string_view sr2 ( string1 );
std::string string2 ( sr2.rbegin (), sr2.rend ());
BOOST_CHECK ( std::equal ( sr2.rbegin (), sr2.rend (), arg ));
BOOST_CHECK ( string2 == arg );
BOOST_CHECK ( std::equal ( sr1.begin (), sr1.end (), string2.begin ()));
BOOST_TEST ( std::equal ( sr2.rbegin (), sr2.rend (), arg ));
BOOST_TEST ( string2 == arg );
BOOST_TEST ( std::equal ( sr1.begin (), sr1.end (), string2.begin ()));
}
// This helper function eliminates signed vs. unsigned warnings
string_view::size_type ptr_diff ( const char *res, const char *base ) {
BOOST_CHECK ( res >= base );
BOOST_TEST ( res >= base );
return static_cast<string_view::size_type> ( res - base );
}
@ -98,12 +97,16 @@ void find ( const char *arg ) {
string_view sr2;
const char *p;
// When we search for the empty string, we find it at position 0
BOOST_TEST ( sr1.find (sr2) == 0 );
BOOST_TEST ( sr1.rfind(sr2) == 0 );
// Look for each character in the string(searching from the start)
p = arg;
sr1 = arg;
while ( *p ) {
string_view::size_type pos = sr1.find(*p);
BOOST_CHECK ( pos != string_view::npos && ( pos <= ptr_diff ( p, arg )));
BOOST_TEST ( pos != string_view::npos && ( pos <= ptr_diff ( p, arg )));
++p;
}
@ -112,7 +115,7 @@ void find ( const char *arg ) {
sr1 = arg;
while ( *p ) {
string_view::size_type pos = sr1.rfind(*p);
BOOST_CHECK ( pos != string_view::npos && pos < sr1.size () && ( pos >= ptr_diff ( p, arg )));
BOOST_TEST ( pos != string_view::npos && pos < sr1.size () && ( pos >= ptr_diff ( p, arg )));
++p;
}
@ -122,7 +125,7 @@ void find ( const char *arg ) {
while ( *p && *(p+1)) {
string_view sr3 ( p, 2 );
string_view::size_type pos = sr1.find ( sr3 );
BOOST_CHECK ( pos != string_view::npos && pos <= static_cast<string_view::size_type>( p - arg ));
BOOST_TEST ( pos != string_view::npos && pos <= static_cast<string_view::size_type>( p - arg ));
p++;
}
@ -133,9 +136,9 @@ void find ( const char *arg ) {
for ( int ch = 1; ch < 256; ++ch ) {
string_view::size_type pos = sr1.find(ch);
const char *strp = std::strchr ( arg, ch );
BOOST_CHECK (( strp == NULL ) == ( pos == string_view::npos ));
BOOST_TEST (( strp == NULL ) == ( pos == string_view::npos ));
if ( strp != NULL )
BOOST_CHECK ( ptr_diff ( strp, arg ) == pos );
BOOST_TEST ( ptr_diff ( strp, arg ) == pos );
}
sr1 = arg;
@ -145,9 +148,9 @@ void find ( const char *arg ) {
for ( int ch = 1; ch < 256; ++ch ) {
string_view::size_type pos = sr1.rfind(ch);
const char *strp = std::strrchr ( arg, ch );
BOOST_CHECK (( strp == NULL ) == ( pos == string_view::npos ));
BOOST_TEST (( strp == NULL ) == ( pos == string_view::npos ));
if ( strp != NULL )
BOOST_CHECK ( ptr_diff ( strp, arg ) == pos );
BOOST_TEST ( ptr_diff ( strp, arg ) == pos );
}
@ -156,7 +159,7 @@ void find ( const char *arg ) {
sr1 = arg;
while ( !sr1.empty ()) {
string_view::size_type pos = sr1.find(*p);
BOOST_CHECK ( pos == 0 );
BOOST_TEST ( pos == 0 );
sr1.remove_prefix (1);
++p;
}
@ -166,7 +169,7 @@ void find ( const char *arg ) {
p = arg + std::strlen ( arg ) - 1;
while ( !sr1.empty ()) {
string_view::size_type pos = sr1.rfind(*p);
BOOST_CHECK ( pos == sr1.size () - 1 );
BOOST_TEST ( pos == sr1.size () - 1 );
sr1.remove_suffix (1);
--p;
}
@ -176,7 +179,7 @@ void find ( const char *arg ) {
p = arg;
while ( !sr1.empty ()) {
string_view::size_type pos = sr1.find_first_of(*p);
BOOST_CHECK ( pos == 0 );
BOOST_TEST ( pos == 0 );
sr1.remove_prefix (1);
++p;
}
@ -187,7 +190,7 @@ void find ( const char *arg ) {
p = arg + std::strlen ( arg ) - 1;
while ( !sr1.empty ()) {
string_view::size_type pos = sr1.find_last_of(*p);
BOOST_CHECK ( pos == sr1.size () - 1 );
BOOST_TEST ( pos == sr1.size () - 1 );
sr1.remove_suffix (1);
--p;
}
@ -196,8 +199,8 @@ void find ( const char *arg ) {
sr1 = arg;
sr2 = arg;
while ( !sr1.empty() ) {
BOOST_CHECK ( sr1.find_first_of ( sr2 ) == 0 );
BOOST_CHECK ( sr1.find_first_not_of ( sr2 ) == string_view::npos );
BOOST_TEST ( sr1.find_first_of ( sr2 ) == 0 );
BOOST_TEST ( sr1.find_first_not_of ( sr2 ) == string_view::npos );
sr1.remove_prefix ( 1 );
}
@ -206,14 +209,14 @@ void find ( const char *arg ) {
while ( *p ) {
string_view::size_type pos1 = sr1.find_first_of(*p);
string_view::size_type pos2 = sr1.find_first_not_of(*p);
BOOST_CHECK ( pos1 != string_view::npos && pos1 < sr1.size () && pos1 <= ptr_diff ( p, arg ));
BOOST_TEST ( pos1 != string_view::npos && pos1 < sr1.size () && pos1 <= ptr_diff ( p, arg ));
if ( pos2 != string_view::npos ) {
for ( size_t i = 0 ; i < pos2; ++i )
BOOST_CHECK ( sr1[i] == *p );
BOOST_CHECK ( sr1 [ pos2 ] != *p );
BOOST_TEST ( sr1[i] == *p );
BOOST_TEST ( sr1 [ pos2 ] != *p );
}
BOOST_CHECK ( pos2 != pos1 );
BOOST_TEST ( pos2 != pos1 );
++p;
}
@ -221,8 +224,8 @@ void find ( const char *arg ) {
sr1 = arg;
sr2 = arg;
while ( !sr1.empty() ) {
BOOST_CHECK ( sr1.find_last_of ( sr2 ) == ( sr1.size () - 1 ));
BOOST_CHECK ( sr1.find_last_not_of ( sr2 ) == string_view::npos );
BOOST_TEST ( sr1.find_last_of ( sr2 ) == ( sr1.size () - 1 ));
BOOST_TEST ( sr1.find_last_not_of ( sr2 ) == string_view::npos );
sr1.remove_suffix ( 1 );
}
@ -231,15 +234,15 @@ void find ( const char *arg ) {
while ( *p ) {
string_view::size_type pos1 = sr1.find_last_of(*p);
string_view::size_type pos2 = sr1.find_last_not_of(*p);
BOOST_CHECK ( pos1 != string_view::npos && pos1 < sr1.size () && pos1 >= ptr_diff ( p, arg ));
BOOST_CHECK ( pos2 == string_view::npos || pos1 < sr1.size ());
BOOST_TEST ( pos1 != string_view::npos && pos1 < sr1.size () && pos1 >= ptr_diff ( p, arg ));
BOOST_TEST ( pos2 == string_view::npos || pos1 < sr1.size ());
if ( pos2 != string_view::npos ) {
for ( size_t i = sr1.size () -1 ; i > pos2; --i )
BOOST_CHECK ( sr1[i] == *p );
BOOST_CHECK ( sr1 [ pos2 ] != *p );
BOOST_TEST ( sr1[i] == *p );
BOOST_TEST ( sr1 [ pos2 ] != *p );
}
BOOST_CHECK ( pos2 != pos1 );
BOOST_TEST ( pos2 != pos1 );
++p;
}
@ -335,14 +338,14 @@ void to_string ( const char *arg ) {
sr1 = arg;
// str2 = sr1.to_string<std::allocator<char> > ();
str2 = sr1.to_string ();
BOOST_CHECK ( str1 == str2 );
BOOST_TEST ( str1 == str2 );
std::basic_string<char, std::char_traits<char>, custom_allocator<char> > str3 = sr1.to_string(custom_allocator<char>());
BOOST_CHECK ( std::strcmp(str1.c_str(), str3.c_str()) == 0 );
BOOST_TEST ( std::strcmp(str1.c_str(), str3.c_str()) == 0 );
#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
std::string str4 = static_cast<std::string> ( sr1 );
BOOST_CHECK ( str1 == str4 );
BOOST_TEST ( str1 == str4 );
#endif
}
@ -353,28 +356,28 @@ void compare ( const char *arg ) {
str1.assign ( arg );
sr1 = arg;
BOOST_CHECK ( sr1 == sr1); // compare string_view and string_view
BOOST_CHECK ( sr1 == str1); // compare string and string_view
BOOST_CHECK ( str1 == sr1 ); // compare string_view and string
BOOST_CHECK ( sr1 == arg ); // compare string_view and pointer
BOOST_CHECK ( arg == sr1 ); // compare pointer and string_view
BOOST_TEST ( sr1 == sr1); // compare string_view and string_view
BOOST_TEST ( sr1 == str1); // compare string and string_view
BOOST_TEST ( str1 == sr1 ); // compare string_view and string
BOOST_TEST ( sr1 == arg ); // compare string_view and pointer
BOOST_TEST ( arg == sr1 ); // compare pointer and string_view
if ( sr1.size () > 0 ) {
(*str1.rbegin())++;
BOOST_CHECK ( sr1 != str1 );
BOOST_CHECK ( str1 != sr1 );
BOOST_CHECK ( sr1 < str1 );
BOOST_CHECK ( sr1 <= str1 );
BOOST_CHECK ( str1 > sr1 );
BOOST_CHECK ( str1 >= sr1 );
BOOST_TEST ( sr1 != str1 );
BOOST_TEST ( str1 != sr1 );
BOOST_TEST ( sr1 < str1 );
BOOST_TEST ( sr1 <= str1 );
BOOST_TEST ( str1 > sr1 );
BOOST_TEST ( str1 >= sr1 );
(*str1.rbegin()) -= 2;
BOOST_CHECK ( sr1 != str1 );
BOOST_CHECK ( str1 != sr1 );
BOOST_CHECK ( sr1 > str1 );
BOOST_CHECK ( sr1 >= str1 );
BOOST_CHECK ( str1 < sr1 );
BOOST_CHECK ( str1 <= sr1 );
BOOST_TEST ( sr1 != str1 );
BOOST_TEST ( str1 != sr1 );
BOOST_TEST ( sr1 > str1 );
BOOST_TEST ( sr1 >= str1 );
BOOST_TEST ( str1 < sr1 );
BOOST_TEST ( str1 <= sr1 );
}
}
@ -388,7 +391,7 @@ const char *test_strings [] = {
NULL
};
BOOST_AUTO_TEST_CASE( test_main )
int main()
{
const char **p = &test_strings[0];
@ -402,4 +405,6 @@ BOOST_AUTO_TEST_CASE( test_main )
p++;
}
return boost::report_errors();
}

View File

@ -12,8 +12,6 @@
* \brief This header contains tests for stream operations of \c basic_string_ref.
*/
#define BOOST_TEST_MODULE string_ref_test_io
#include <boost/utility/string_view.hpp>
#include <iomanip>
@ -23,23 +21,10 @@
#include <string>
#include <boost/config.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/core/lightweight_test.hpp>
typedef boost::mpl::vector<
char
#if !defined(BOOST_NO_STD_WSTRING) && !defined(BOOST_NO_STD_WSTREAMBUF) && !defined(BOOST_NO_INTRINSIC_WCHAR_T)
, wchar_t
#endif
/* Current implementations seem to be missing codecvt facets to convert chars to char16_t and char32_t even though the types are available.
#if !defined(BOOST_NO_CXX11_CHAR16_T)
, char16_t
#endif
#if !defined(BOOST_NO_CXX11_CHAR32_T)
, char32_t
#endif
*/
>::type char_types;
static const char* test_strings[] =
{
@ -72,7 +57,8 @@ struct context
};
// Test regular output
BOOST_AUTO_TEST_CASE_TEMPLATE(string_view_output, CharT, char_types)
template<class CharT>
void test_string_view_output()
{
typedef CharT char_type;
typedef std::basic_ostringstream< char_type > ostream_type;
@ -82,11 +68,12 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(string_view_output, CharT, char_types)
ostream_type strm;
strm << string_view_type(ctx.abcd);
BOOST_CHECK(strm.str() == ctx.abcd);
BOOST_TEST(strm.str() == ctx.abcd);
}
// Test support for padding
BOOST_AUTO_TEST_CASE_TEMPLATE(padding, CharT, char_types)
template<class CharT>
void test_padding()
{
typedef CharT char_type;
typedef std::basic_ostringstream< char_type > ostream_type;
@ -102,7 +89,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(padding, CharT, char_types)
ostream_type strm_correct;
strm_correct << ctx.begin << std::setw(8) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_TEST(strm_ref.str() == strm_correct.str());
}
// Test for long padding
@ -113,7 +100,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(padding, CharT, char_types)
ostream_type strm_correct;
strm_correct << ctx.begin << std::setw(100) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_TEST(strm_ref.str() == strm_correct.str());
}
// Test that short width does not truncate the string
@ -124,12 +111,13 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(padding, CharT, char_types)
ostream_type strm_correct;
strm_correct << ctx.begin << std::setw(1) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_TEST(strm_ref.str() == strm_correct.str());
}
}
// Test support for padding fill
BOOST_AUTO_TEST_CASE_TEMPLATE(padding_fill, CharT, char_types)
template<class CharT>
void test_padding_fill()
{
typedef CharT char_type;
typedef std::basic_ostringstream< char_type > ostream_type;
@ -143,11 +131,12 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(padding_fill, CharT, char_types)
ostream_type strm_correct;
strm_correct << ctx.begin << std::setfill(static_cast< char_type >('x')) << std::setw(8) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_TEST(strm_ref.str() == strm_correct.str());
}
// Test support for alignment
BOOST_AUTO_TEST_CASE_TEMPLATE(alignment, CharT, char_types)
template<class CharT>
void test_alignment()
{
typedef CharT char_type;
typedef std::basic_ostringstream< char_type > ostream_type;
@ -163,7 +152,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(alignment, CharT, char_types)
ostream_type strm_correct;
strm_correct << ctx.begin << std::left << std::setw(8) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_TEST(strm_ref.str() == strm_correct.str());
}
// Right alignment
@ -174,6 +163,22 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(alignment, CharT, char_types)
ostream_type strm_correct;
strm_correct << ctx.begin << std::right << std::setw(8) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_TEST(strm_ref.str() == strm_correct.str());
}
}
template<class CharT>
void test()
{
test_string_view_output<CharT>();
test_padding<CharT>();
test_padding_fill<CharT>();
test_alignment<CharT>();
}
int main()
{
test<char>();
test<wchar_t>();
return boost::report_errors();
}

View File

@ -16,13 +16,13 @@
#include <string>
#include "boost/utility/value_init.hpp"
#include <boost/shared_ptr.hpp>
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
#include <boost/detail/lightweight_test.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config/workaround.hpp>
//
// Sample POD type
@ -218,8 +218,8 @@ void check_initialized_value ( T const& y )
BOOST_TEST ( y == initializedValue ) ;
}
#ifdef __BORLANDC__
#if __BORLANDC__ == 0x582
#ifdef BOOST_BORLANDC
#if BOOST_BORLANDC == 0x582
void check_initialized_value( NonPOD const& )
{
// The initialized_value check is skipped for Borland 5.82
@ -270,9 +270,12 @@ bool test ( T const& y, T const& z )
boost::value_initialized<T> copy2;
copy2 = x;
BOOST_TEST ( boost::get(copy2) == boost::get(x) ) ;
boost::shared_ptr<boost::value_initialized<T> > ptr( new boost::value_initialized<T> );
BOOST_TEST ( y == *ptr ) ;
{
boost::value_initialized<T> * ptr = new boost::value_initialized<T>;
BOOST_TEST ( y == *ptr ) ;
delete ptr;
}
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
boost::value_initialized<T const> cx ;
@ -287,7 +290,7 @@ bool test ( T const& y, T const& z )
return boost::detail::test_errors() == errors_before_test ;
}
int main(int, char **)
int main()
{
BOOST_TEST ( test( 0,1234 ) ) ;
BOOST_TEST ( test( 0.0,12.34 ) ) ;

169
test/value_init_test2.cpp Normal file
View File

@ -0,0 +1,169 @@
// Copyright 2010, Niels Dekker.
//
// 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)
//
// Test program for the boost::value_initialized<T> workaround.
//
// 17 June 2010 (Created) Niels Dekker
#include <boost/utility/value_init.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config/workaround.hpp>
#include <iostream>
namespace
{
struct empty_struct
{
};
// A POD aggregate struct derived from an empty struct.
// Similar to struct Foo1 from Microsoft Visual C++ bug report 484295,
// "VC++ does not value-initialize members of derived classes without
// user-declared constructor", reported in 2009 by Sylvester Hesp:
// https://connect.microsoft.com/VisualStudio/feedback/details/484295
struct derived_struct: empty_struct
{
int data;
};
bool is_value_initialized(const derived_struct& arg)
{
return arg.data == 0;
}
class virtual_destructor_holder
{
public:
int i;
virtual ~virtual_destructor_holder()
{
}
};
bool is_value_initialized(const virtual_destructor_holder& arg)
{
return arg.i == 0;
}
// Equivalent to the Stats class from GCC Bug 33916,
// "Default constructor fails to initialize array members", reported in 2007 by
// Michael Elizabeth Chastain: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
// and fixed for GCC 4.2.4.
class private_int_array_pair
{
friend bool is_value_initialized(const private_int_array_pair& arg);
private:
int first[12];
int second[12];
};
bool is_value_initialized(const private_int_array_pair& arg)
{
for ( unsigned i = 0; i < 12; ++i)
{
if ( (arg.first[i] != 0) || (arg.second[i] != 0) )
{
return false;
}
}
return true;
}
struct int_pair_struct
{
int first;
int second;
};
typedef int int_pair_struct::*ptr_to_member_type;
struct ptr_to_member_struct
{
ptr_to_member_type data;
};
bool is_value_initialized(const ptr_to_member_struct& arg)
{
return arg.data == 0;
}
template <typename T>
bool is_value_initialized(const T(& arg)[2])
{
return
is_value_initialized(arg[0]) &&
is_value_initialized(arg[1]);
}
template <typename T>
bool is_value_initialized(const boost::value_initialized<T>& arg)
{
return is_value_initialized(arg.data());
}
// Returns zero when the specified object is value-initializated, and one otherwise.
// Prints a message to standard output if the value-initialization has failed.
template <class T>
unsigned failed_to_value_initialized(const T& object, const char *const object_name)
{
if ( is_value_initialized(object) )
{
return 0u;
}
else
{
std::cout << "Note: Failed to value-initialize " << object_name << '.' << std::endl;
return 1u;
}
}
// A macro that passed both the name and the value of the specified object to
// the function above here.
#define FAILED_TO_VALUE_INITIALIZE(value) failed_to_value_initialized(value, #value)
// Equivalent to the dirty_stack() function from GCC Bug 33916,
// "Default constructor fails to initialize array members", reported in 2007 by
// Michael Elizabeth Chastain: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33916
void dirty_stack()
{
unsigned char array_on_stack[4096];
for (unsigned i = 0; i < sizeof(array_on_stack); ++i)
{
array_on_stack[i] = 0x11;
}
}
}
int main()
{
#ifdef BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED
std::cout << "BOOST_DETAIL_VALUE_INIT_WORKAROUND_SUGGESTED is defined.\n\n";
#endif
dirty_stack();
BOOST_TEST( is_value_initialized( boost::value_initialized<derived_struct>() ) );
BOOST_TEST( is_value_initialized( boost::value_initialized<virtual_destructor_holder[2]>() ) );
BOOST_TEST( is_value_initialized( boost::value_initialized<private_int_array_pair>() ) );
#if !BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1925) )
// Null pointers to data members are represented as -1 in MSVC, but
// value initialization sets them to all zero. The workaround employed
// by value_initialized<> is to memset the storage to all zero, which
// doesn't help.
BOOST_TEST( is_value_initialized( boost::value_initialized<ptr_to_member_struct>() ) );
#endif
return boost::report_errors();
}

40
test/value_init_test3.cpp Normal file
View File

@ -0,0 +1,40 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
#include <boost/utility/value_init.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>
#if __cplusplus >= 201103L || ( defined(BOOST_MSVC) && BOOST_MSVC >= 1900 )
struct X
{
int a;
char b;
};
struct Y: boost::value_initialized<X>
{
char c = 42;
};
int main()
{
Y y;
BOOST_TEST_EQ( y.data().a, 0 );
BOOST_TEST_EQ( y.data().b, 0 );
BOOST_TEST_EQ( y.c, 42 );
return boost::report_errors();
}
#else
BOOST_PRAGMA_MESSAGE( "Skipping test because compiler doesn't support in-class member initializers" )
int main() {}
#endif

View File

@ -13,13 +13,11 @@
#include "boost/utility/value_init.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
#include "boost/test/minimal.hpp"
int test_main(int, char **)
int main()
{
boost::value_initialized<int> const x_c ;
@ -27,11 +25,3 @@ int test_main(int, char **)
return 0;
}
unsigned int expected_failures = 0;

View File

@ -13,13 +13,11 @@
#include "boost/utility/value_init.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
#include "boost/test/minimal.hpp"
int test_main(int, char **)
int main()
{
boost::value_initialized<int const> cx ;
@ -27,10 +25,3 @@ int test_main(int, char **)
return 0;
}
unsigned int expected_failures = 0;

View File

@ -13,13 +13,11 @@
#include "boost/utility/value_init.hpp"
#ifdef __BORLANDC__
#ifdef BOOST_BORLANDC
#pragma hdrstop
#endif
#include "boost/test/minimal.hpp"
int test_main(int, char **)
int main()
{
boost::value_initialized<int const> const cx_c ;
@ -27,11 +25,3 @@ int test_main(int, char **)
return 0;
}
unsigned int expected_failures = 0;