forked from boostorg/iterator
Compare commits
77 Commits
boost-1.70.0
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| ae5d7d8c0c | |||
| d72d57fa39 | |||
| c98f965388 | |||
| d09f78ae9b | |||
| a9dabd3c65 | |||
| 80bb1ac9e4 | |||
| d11499c08c | |||
| 6d02c36718 | |||
| 85b542e1b6 | |||
| e8fbd92a61 | |||
| 7c9b4296a1 | |||
| 0a95636faf | |||
| 5777e9944b | |||
| 853ba3d3c7 | |||
| f82627f2cc | |||
| ed1d96f251 | |||
| ce52aee3ce | |||
| 17355c5ad0 | |||
| 9504b3bced | |||
| 2cc45f1694 | |||
| a3269e536f | |||
| 129245a985 | |||
| 1a80896934 | |||
| ee2d3a6596 | |||
| cd24487161 | |||
| dd37a27067 | |||
| 7b6edb6a7d | |||
| c924b42749 | |||
| 85d935bf68 | |||
| d175ba2450 | |||
| 75ba1a50c9 | |||
| e4ab917f79 | |||
| c901bd6d7a | |||
| eb0d01126a | |||
| abe6fbfd4b | |||
| 7a200905dd | |||
| acf35d2a87 | |||
| 5ebbe941be | |||
| 72308ef787 | |||
| 9124869bcc | |||
| 216b442d23 | |||
| c858138495 | |||
| 1c6f85d4f9 | |||
| 0a59f555ca | |||
| 18337e990b | |||
| 1447c566d1 | |||
| fc281fa58a | |||
| b76c273946 | |||
| f396a8fef0 | |||
| 5a6013e21f | |||
| 6dfb175cef | |||
| 72a7fb1b73 | |||
| f4b47fd266 | |||
| 2c0145bff0 | |||
| 987151dde6 | |||
| 8e457e716b | |||
| 32f4f4d086 | |||
| 72f0ebe8d0 | |||
| d7ad43a925 | |||
| 733c0fb9cb | |||
| 5b18ae976e | |||
| da8604615e | |||
| 8fc94469da | |||
| b86c817481 | |||
| 9649d42392 | |||
| 0c5f0b822a | |||
| dc7bf5cc05 | |||
| 80ec58bb3b | |||
| c2929ea6c6 | |||
| 4fe679bb0d | |||
| fdcd8439c0 | |||
| 3a8728a595 | |||
| 897ff65fdc | |||
| bfe2a004d2 | |||
| d528fc0b11 | |||
| 540f999d0b | |||
| 54dee0db96 |
@@ -0,0 +1,508 @@
|
|||||||
|
# Copyright 2021-2022 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.6
|
||||||
|
cxxstd: "0x"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:16.04
|
||||||
|
install:
|
||||||
|
- g++-4.6
|
||||||
|
sources:
|
||||||
|
- "ppa:ubuntu-toolchain-r/test"
|
||||||
|
- toolset: gcc-4.7
|
||||||
|
cxxstd: "11"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:16.04
|
||||||
|
install:
|
||||||
|
- g++-4.7
|
||||||
|
- toolset: gcc-4.8
|
||||||
|
cxxstd: "11"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:18.04
|
||||||
|
install:
|
||||||
|
- g++-4.8
|
||||||
|
- toolset: gcc-4.9
|
||||||
|
cxxstd: "11"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:16.04
|
||||||
|
install:
|
||||||
|
- g++-4.9
|
||||||
|
- toolset: gcc-5
|
||||||
|
cxxstd: "11,14,1z"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:16.04
|
||||||
|
install:
|
||||||
|
- g++-5
|
||||||
|
- toolset: gcc-6
|
||||||
|
cxxstd: "11,14,1z"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:18.04
|
||||||
|
install:
|
||||||
|
- g++-6
|
||||||
|
- toolset: gcc-7
|
||||||
|
cxxstd: "11,14,17"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:18.04
|
||||||
|
install:
|
||||||
|
- g++-7
|
||||||
|
- toolset: gcc-8
|
||||||
|
cxxstd: "11,14,17,2a"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:18.04
|
||||||
|
install:
|
||||||
|
- g++-8
|
||||||
|
- toolset: gcc-9
|
||||||
|
cxxstd: "11,14,17,2a"
|
||||||
|
os: ubuntu-20.04
|
||||||
|
install:
|
||||||
|
- g++-9
|
||||||
|
- toolset: gcc-10
|
||||||
|
cxxstd: "11,14,17,20"
|
||||||
|
os: ubuntu-20.04
|
||||||
|
install:
|
||||||
|
- g++-10
|
||||||
|
- toolset: gcc-11
|
||||||
|
cxxstd: "11,14,17,20,23"
|
||||||
|
os: ubuntu-22.04
|
||||||
|
install:
|
||||||
|
- g++-11
|
||||||
|
- toolset: gcc-12
|
||||||
|
cxxstd: "11,14,17,20,23"
|
||||||
|
os: ubuntu-22.04
|
||||||
|
install:
|
||||||
|
- g++-12
|
||||||
|
- name: UBSAN
|
||||||
|
toolset: gcc-11
|
||||||
|
cxxstd: "11,14,17,20,23"
|
||||||
|
ubsan: 1
|
||||||
|
build_variant: debug
|
||||||
|
os: ubuntu-22.04
|
||||||
|
install:
|
||||||
|
- g++-11
|
||||||
|
|
||||||
|
# Linux, clang
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-3.5
|
||||||
|
cxxstd: "11"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:16.04
|
||||||
|
install:
|
||||||
|
- clang-3.5
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-3.6
|
||||||
|
cxxstd: "11,14"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:16.04
|
||||||
|
install:
|
||||||
|
- clang-3.6
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-3.7
|
||||||
|
cxxstd: "11,14"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:16.04
|
||||||
|
install:
|
||||||
|
- clang-3.7
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-3.8
|
||||||
|
cxxstd: "11,14"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:16.04
|
||||||
|
install:
|
||||||
|
- clang-3.8
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-3.9
|
||||||
|
cxxstd: "11,14"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:18.04
|
||||||
|
install:
|
||||||
|
- clang-3.9
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-4.0
|
||||||
|
cxxstd: "11,14"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:18.04
|
||||||
|
install:
|
||||||
|
- clang-4.0
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-5.0
|
||||||
|
cxxstd: "11,14,1z"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:18.04
|
||||||
|
install:
|
||||||
|
- clang-5.0
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-6.0
|
||||||
|
cxxstd: "11,14,17"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:18.04
|
||||||
|
install:
|
||||||
|
- clang-6.0
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-7
|
||||||
|
cxxstd: "11,14,17"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: 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: "11,14,17,2a"
|
||||||
|
os: ubuntu-latest
|
||||||
|
container: ubuntu:18.04
|
||||||
|
install:
|
||||||
|
- clang-8
|
||||||
|
- g++-7
|
||||||
|
gcc_toolchain: 7
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-9
|
||||||
|
cxxstd: "11,14,17,2a"
|
||||||
|
os: ubuntu-20.04
|
||||||
|
install:
|
||||||
|
- clang-9
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-10
|
||||||
|
cxxstd: "11,14,17,20"
|
||||||
|
os: ubuntu-20.04
|
||||||
|
install:
|
||||||
|
- clang-10
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-11
|
||||||
|
cxxstd: "11,14,17,20"
|
||||||
|
os: ubuntu-22.04
|
||||||
|
install:
|
||||||
|
- clang-11
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-12
|
||||||
|
cxxstd: "11,14,17,20,2b"
|
||||||
|
os: ubuntu-22.04
|
||||||
|
install:
|
||||||
|
- clang-12
|
||||||
|
- g++-11
|
||||||
|
gcc_toolchain: 11
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-13
|
||||||
|
cxxstd: "11,14,17,20,2b"
|
||||||
|
os: ubuntu-22.04
|
||||||
|
install:
|
||||||
|
- clang-13
|
||||||
|
- g++-11
|
||||||
|
gcc_toolchain: 11
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-14
|
||||||
|
cxxstd: "11,14,17,20,2b"
|
||||||
|
os: ubuntu-22.04
|
||||||
|
install:
|
||||||
|
- clang-14
|
||||||
|
- g++-11
|
||||||
|
gcc_toolchain: 11
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-15
|
||||||
|
cxxstd: "11,14,17,20,2b"
|
||||||
|
os: ubuntu-22.04
|
||||||
|
install:
|
||||||
|
- clang-15
|
||||||
|
- g++-11
|
||||||
|
gcc_toolchain: 11
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-15
|
||||||
|
cxxstd: "11,14,17,20,2b"
|
||||||
|
os: ubuntu-22.04
|
||||||
|
install:
|
||||||
|
- clang-15
|
||||||
|
- libc++-15-dev
|
||||||
|
- libc++abi-15-dev
|
||||||
|
cxxflags: -stdlib=libc++
|
||||||
|
linkflags: -stdlib=libc++
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-16
|
||||||
|
cxxstd: "11,14,17,20,2b"
|
||||||
|
os: ubuntu-22.04
|
||||||
|
install:
|
||||||
|
- clang-16
|
||||||
|
sources:
|
||||||
|
- "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main"
|
||||||
|
source_keys:
|
||||||
|
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||||
|
- toolset: clang
|
||||||
|
compiler: clang++-16
|
||||||
|
cxxstd: "11,14,17,20,2b"
|
||||||
|
os: ubuntu-22.04
|
||||||
|
install:
|
||||||
|
- clang-16
|
||||||
|
- libc++-16-dev
|
||||||
|
- libc++abi-16-dev
|
||||||
|
sources:
|
||||||
|
- "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main"
|
||||||
|
source_keys:
|
||||||
|
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||||
|
cxxflags: -stdlib=libc++
|
||||||
|
linkflags: -stdlib=libc++
|
||||||
|
- name: UBSAN
|
||||||
|
toolset: clang
|
||||||
|
compiler: clang++-15
|
||||||
|
cxxstd: "11,14,17,20,2b"
|
||||||
|
cxxflags: -stdlib=libc++
|
||||||
|
linkflags: -stdlib=libc++
|
||||||
|
ubsan: 1
|
||||||
|
build_variant: debug
|
||||||
|
os: ubuntu-22.04
|
||||||
|
install:
|
||||||
|
- clang-15
|
||||||
|
- libc++-15-dev
|
||||||
|
- libc++abi-15-dev
|
||||||
|
|
||||||
|
- toolset: clang
|
||||||
|
cxxstd: "11,14,17,2a"
|
||||||
|
os: macos-11
|
||||||
|
|
||||||
|
- name: CMake tests
|
||||||
|
cmake_tests: 1
|
||||||
|
os: ubuntu-20.04
|
||||||
|
|
||||||
|
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
|
||||||
|
if [ "$(apt-cache search "^python-is-python3$" | wc -l)" -ne 0 ]
|
||||||
|
then
|
||||||
|
PYTHON_PACKAGE="python-is-python3"
|
||||||
|
else
|
||||||
|
PYTHON_PACKAGE="python"
|
||||||
|
fi
|
||||||
|
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_PACKAGE python3 perl git cmake
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
git config --global pack.threads 0
|
||||||
|
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install packages
|
||||||
|
if: matrix.install
|
||||||
|
run: |
|
||||||
|
declare -a SOURCE_KEYS SOURCES
|
||||||
|
if [ -n "${{join(matrix.source_keys, ' ')}}" ]
|
||||||
|
then
|
||||||
|
SOURCE_KEYS=("${{join(matrix.source_keys, '" "')}}")
|
||||||
|
fi
|
||||||
|
if [ -n "${{join(matrix.sources, ' ')}}" ]
|
||||||
|
then
|
||||||
|
SOURCES=("${{join(matrix.sources, '" "')}}")
|
||||||
|
fi
|
||||||
|
for key in "${SOURCE_KEYS[@]}"
|
||||||
|
do
|
||||||
|
for i in {1..$NET_RETRY_COUNT}
|
||||||
|
do
|
||||||
|
echo "Adding key: $key"
|
||||||
|
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_SUPPORTED_ARGS="$(apt-add-repository --help | perl -ne 'if (/^\s*-n/) { print "n"; } elsif (/^\s*-P/) { print "P"; } elsif (/^\s*-S/) { print "S"; } elsif (/^\s*-U/) { print "U"; }')"
|
||||||
|
if [ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*n*}" ]
|
||||||
|
then
|
||||||
|
APT_ADD_REPO_COMMON_ARGS+=("-n")
|
||||||
|
fi
|
||||||
|
APT_ADD_REPO_HAS_SOURCE_ARGS="$([ -n "$APT_ADD_REPO_SUPPORTED_ARGS" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*P*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*S*}" -a -z "${APT_ADD_REPO_SUPPORTED_ARGS##*U*}" ] && echo 1 || echo 0)"
|
||||||
|
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")
|
||||||
|
echo "apt-add-repository ${APT_ADD_REPO_ARGS[@]}"
|
||||||
|
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[@]}"
|
||||||
|
|
||||||
|
- name: Run CMake tests
|
||||||
|
if: matrix.cmake_tests
|
||||||
|
run: |
|
||||||
|
if [ -n "${{matrix.macosx_version_min}}" ]
|
||||||
|
then
|
||||||
|
export MACOSX_DEPLOYMENT_TARGET="${{matrix.macosx_version_min}}"
|
||||||
|
fi
|
||||||
|
cd ../boost-root
|
||||||
|
mkdir __build_static__ && cd __build_static__
|
||||||
|
cmake ../libs/$LIBRARY/test/test_cmake
|
||||||
|
cmake --build . --target boost_${LIBRARY}_cmake_self_test -j $BUILD_JOBS
|
||||||
|
cd ..
|
||||||
|
mkdir __build_shared__ && cd __build_shared__
|
||||||
|
cmake -DBUILD_SHARED_LIBS=On ../libs/$LIBRARY/test/test_cmake
|
||||||
|
cmake --build . --target boost_${LIBRARY}_cmake_self_test -j $BUILD_JOBS
|
||||||
-93
@@ -1,93 +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 CXXSTD=03,11
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: g++-5
|
|
||||||
env: TOOLSET=gcc-5 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- g++-5
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: g++-6
|
|
||||||
env: TOOLSET=gcc-6 CXXSTD=03,11,14,1z
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- g++-6
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: g++-7
|
|
||||||
env: TOOLSET=gcc-7 CXXSTD=03,11,14,17
|
|
||||||
addons:
|
|
||||||
apt:
|
|
||||||
packages:
|
|
||||||
- g++-7
|
|
||||||
sources:
|
|
||||||
- ubuntu-toolchain-r-test
|
|
||||||
|
|
||||||
- os: linux
|
|
||||||
compiler: clang++
|
|
||||||
env: TOOLSET=clang CXXSTD=03,11,14,1z
|
|
||||||
|
|
||||||
- os: osx
|
|
||||||
compiler: clang++
|
|
||||||
env: TOOLSET=clang CXXSTD=03,11,14,1z
|
|
||||||
|
|
||||||
install:
|
|
||||||
- GIT_FETCH_JOBS=8
|
|
||||||
- BOOST_BRANCH=develop
|
|
||||||
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
|
|
||||||
- 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/boostdep
|
|
||||||
- git submodule init tools/boost_install
|
|
||||||
- git submodule init libs/headers
|
|
||||||
- git submodule init libs/config
|
|
||||||
- git submodule update --jobs $GIT_FETCH_JOBS
|
|
||||||
- cp -r $TRAVIS_BUILD_DIR/* libs/iterator
|
|
||||||
- python tools/boostdep/depinst/depinst.py --git_args "--jobs $GIT_FETCH_JOBS" iterator
|
|
||||||
- ./bootstrap.sh
|
|
||||||
- ./b2 headers
|
|
||||||
|
|
||||||
script:
|
|
||||||
- BUILD_JOBS=`(nproc || sysctl -n hw.ncpu) 2> /dev/null`
|
|
||||||
- ./b2 -j $BUILD_JOBS libs/iterator/test toolset=$TOOLSET cxxstd=$CXXSTD
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
email:
|
|
||||||
on_success: always
|
|
||||||
+2
-6
@@ -3,12 +3,9 @@
|
|||||||
# Distributed under the Boost Software License, Version 1.0.
|
# 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
|
# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
# Partial (add_subdirectory only) and experimental CMake support
|
cmake_minimum_required(VERSION 3.5...3.20)
|
||||||
# Subject to change; please do not rely on the contents of this file yet.
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.5)
|
project(boost_iterator VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||||
|
|
||||||
project(BoostIterator LANGUAGES CXX)
|
|
||||||
|
|
||||||
add_library(boost_iterator INTERFACE)
|
add_library(boost_iterator INTERFACE)
|
||||||
add_library(Boost::iterator ALIAS boost_iterator)
|
add_library(Boost::iterator ALIAS boost_iterator)
|
||||||
@@ -20,7 +17,6 @@ target_link_libraries(boost_iterator
|
|||||||
Boost::assert
|
Boost::assert
|
||||||
Boost::concept_check
|
Boost::concept_check
|
||||||
Boost::config
|
Boost::config
|
||||||
Boost::conversion
|
|
||||||
Boost::core
|
Boost::core
|
||||||
Boost::detail
|
Boost::detail
|
||||||
Boost::function_types
|
Boost::function_types
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# Boost.Iterator
|
||||||
|
|
||||||
|
Boost.Iterator, part of collection of the [Boost C++ Libraries](https://github.com/boostorg), provides tools for building and working with iterators in C++. The library also provides a number of iterator classes that can be used out of the box.
|
||||||
|
|
||||||
|
### Directories
|
||||||
|
|
||||||
|
* **doc** - Documentation sources
|
||||||
|
* **include** - Interface headers of Boost.Iterator
|
||||||
|
* **test** - Boost.Iterator unit tests
|
||||||
|
* **example** - Boost.Iterator usage examples
|
||||||
|
|
||||||
|
### More information
|
||||||
|
|
||||||
|
* [Documentation](https://boost.org/libs/iterator)
|
||||||
|
* [Report bugs](https://github.com/boostorg/iterator/issues/new). Be sure to mention Boost version, 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](https://github.com/boostorg/iterator/compare) 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/iterator/tree/master) | [](https://github.com/boostorg/iterator/actions?query=branch%3Amaster) | [](https://ci.appveyor.com/project/Lastique/iterator/branch/master) | [](http://www.boost.org/development/tests/master/developer/iterator.html) | [](https://pdimov.github.io/boostdep-report/master/iterator.html)
|
||||||
|
[`develop`](https://github.com/boostorg/iterator/tree/develop) | [](https://github.com/boostorg/iterator/actions?query=branch%3Adevelop) | [](https://ci.appveyor.com/project/Lastique/iterator/branch/develop) | [](http://www.boost.org/development/tests/develop/developer/iterator.html) | [](https://pdimov.github.io/boostdep-report/develop/iterator.html)
|
||||||
|
|
||||||
|
### License
|
||||||
|
|
||||||
|
Distributed under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt).
|
||||||
+63
-8
@@ -1,4 +1,5 @@
|
|||||||
# Copyright 2017 Edward Diener
|
# Copyright 2017 Edward Diener
|
||||||
|
# Copyright 2019 Andrey Semashev
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# 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)
|
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
@@ -14,13 +15,51 @@ branches:
|
|||||||
|
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
- TOOLSET: msvc-12.0
|
||||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
|
ADDRMD: 32,64
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
TOOLSET: msvc-14.0
|
- TOOLSET: msvc-14.0
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
CXXSTD: 14,latest
|
||||||
TOOLSET: msvc-14.1
|
ADDRMD: 32,64
|
||||||
CXXSTD: 14,17
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
|
- TOOLSET: msvc-14.1
|
||||||
|
CXXSTD: 14,17,latest
|
||||||
|
ADDRMD: 32,64
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
|
- TOOLSET: msvc-14.2
|
||||||
|
ADDRMD: 32,64
|
||||||
|
CXXSTD: 14,17,20,latest
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||||
|
- TOOLSET: msvc-14.3
|
||||||
|
ADDRMD: 32,64
|
||||||
|
CXXSTD: 14,17,20,latest
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
|
||||||
|
- TOOLSET: clang-win
|
||||||
|
ADDRMD: 32,64
|
||||||
|
CXXSTD: 14,17,latest
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
|
- TOOLSET: gcc
|
||||||
|
CXXSTD: 11,14,1z
|
||||||
|
ADDPATH: C:\cygwin\bin;
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
|
- TOOLSET: gcc
|
||||||
|
CXXSTD: 11,14,1z
|
||||||
|
ADDPATH: C:\cygwin64\bin;
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
|
- TOOLSET: gcc
|
||||||
|
CXXSTD: 11,14,1z
|
||||||
|
ADDPATH: C:\mingw\bin;
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
|
- TOOLSET: gcc
|
||||||
|
CXXSTD: 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: 11,14,1z
|
||||||
|
ADDPATH: C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
|
- TEST_CMAKE: 1
|
||||||
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- set GIT_FETCH_JOBS=8
|
- set GIT_FETCH_JOBS=8
|
||||||
@@ -43,5 +82,21 @@ install:
|
|||||||
build: off
|
build: off
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
|
- PATH=%ADDPATH%%PATH%
|
||||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||||
- b2 -j %NUMBER_OF_PROCESSORS% libs/iterator/test toolset=%TOOLSET% %CXXSTD%
|
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||||
|
- b2 -j %NUMBER_OF_PROCESSORS% libs/iterator/test toolset=%TOOLSET% %CXXSTD% %ADDRMD%
|
||||||
|
|
||||||
|
for:
|
||||||
|
- matrix:
|
||||||
|
only: [TEST_CMAKE: 1]
|
||||||
|
test_script:
|
||||||
|
- mkdir __build_static__
|
||||||
|
- cd __build_static__
|
||||||
|
- cmake ../libs/iterator/test/test_cmake
|
||||||
|
- cmake --build . --target boost_iterator_cmake_self_test -j %NUMBER_OF_PROCESSORS%
|
||||||
|
- cd ..
|
||||||
|
- mkdir __build_shared__
|
||||||
|
- cd __build_shared__
|
||||||
|
- cmake -DBUILD_SHARED_LIBS=On ../libs/iterator/test/test_cmake
|
||||||
|
- cmake --build . --target boost_iterator_cmake_self_test -j %NUMBER_OF_PROCESSORS%
|
||||||
|
|||||||
+5
-5
@@ -4,20 +4,20 @@
|
|||||||
|
|
||||||
using quickbook ;
|
using quickbook ;
|
||||||
|
|
||||||
xml iterator
|
xml iterator
|
||||||
:
|
:
|
||||||
quickbook/iterator.qbk
|
quickbook/iterator.qbk
|
||||||
;
|
;
|
||||||
|
|
||||||
boostbook standalone
|
boostbook standalone
|
||||||
:
|
:
|
||||||
iterator
|
iterator
|
||||||
:
|
:
|
||||||
<xsl:param>boost.root=../../../..
|
<xsl:param>"boost.root=../../../.."
|
||||||
<xsl:param>toc.max.depth=3
|
<xsl:param>toc.max.depth=3
|
||||||
<xsl:param>toc.section.depth=3
|
<xsl:param>toc.section.depth=3
|
||||||
<xsl:param>chunk.section.depth=2
|
<xsl:param>chunk.section.depth=2
|
||||||
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/iterator/doc
|
<format>pdf:<xsl:param>"boost.url.prefix=http://www.boost.org/doc/libs/release/libs/iterator/doc/html"
|
||||||
;
|
;
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|||||||
+14
-15
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[section:adaptor Iterator Adaptor]
|
[section:adaptor Iterator Adaptor]
|
||||||
|
|
||||||
The `iterator_adaptor` class template adapts some `Base` [#base]_
|
The `iterator_adaptor` class template adapts some `Base` [#base]_
|
||||||
@@ -47,7 +46,7 @@ that assumption.
|
|||||||
, class Reference = use_default
|
, class Reference = use_default
|
||||||
, class Difference = use_default
|
, class Difference = use_default
|
||||||
>
|
>
|
||||||
class iterator_adaptor
|
class iterator_adaptor
|
||||||
: public iterator_facade<Derived, *V'*, *C'*, *R'*, *D'*> // see details
|
: public iterator_facade<Derived, *V'*, *C'*, *R'*, *D'*> // see details
|
||||||
{
|
{
|
||||||
friend class iterator_core_access;
|
friend class iterator_core_access;
|
||||||
@@ -60,21 +59,21 @@ that assumption.
|
|||||||
typedef iterator_adaptor iterator_adaptor\_;
|
typedef iterator_adaptor iterator_adaptor\_;
|
||||||
Base const& base_reference() const;
|
Base const& base_reference() const;
|
||||||
Base& base_reference();
|
Base& base_reference();
|
||||||
private: // Core iterator interface for iterator_facade.
|
private: // Core iterator interface for iterator_facade.
|
||||||
typename iterator_adaptor::reference dereference() const;
|
typename iterator_adaptor::reference dereference() const;
|
||||||
|
|
||||||
template <
|
template <
|
||||||
class OtherDerived, class OtherIterator, class V, class C, class R, class D
|
class OtherDerived, class OtherIterator, class V, class C, class R, class D
|
||||||
>
|
>
|
||||||
bool equal(iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& x) const;
|
bool equal(iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& x) const;
|
||||||
|
|
||||||
void advance(typename iterator_adaptor::difference_type n);
|
void advance(typename iterator_adaptor::difference_type n);
|
||||||
void increment();
|
void increment();
|
||||||
void decrement();
|
void decrement();
|
||||||
|
|
||||||
template <
|
template <
|
||||||
class OtherDerived, class OtherIterator, class V, class C, class R, class D
|
class OtherDerived, class OtherIterator, class V, class C, class R, class D
|
||||||
>
|
>
|
||||||
typename iterator_adaptor::difference_type distance_to(
|
typename iterator_adaptor::difference_type distance_to(
|
||||||
iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& y) const;
|
iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& y) const;
|
||||||
|
|
||||||
@@ -133,7 +132,7 @@ above are defined as follows:
|
|||||||
iterator_adaptor();
|
iterator_adaptor();
|
||||||
|
|
||||||
[*Requires:] The `Base` type must be Default Constructible.[br]
|
[*Requires:] The `Base` type must be Default Constructible.[br]
|
||||||
[*Returns:] An instance of `iterator_adaptor` with
|
[*Returns:] An instance of `iterator_adaptor` with
|
||||||
`m_iterator` default constructed.
|
`m_iterator` default constructed.
|
||||||
|
|
||||||
|
|
||||||
@@ -167,7 +166,7 @@ above are defined as follows:
|
|||||||
|
|
||||||
template <
|
template <
|
||||||
class OtherDerived, class OtherIterator, class V, class C, class R, class D
|
class OtherDerived, class OtherIterator, class V, class C, class R, class D
|
||||||
>
|
>
|
||||||
bool equal(iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& x) const;
|
bool equal(iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& x) const;
|
||||||
|
|
||||||
[*Returns:] `m_iterator == x.base()`
|
[*Returns:] `m_iterator == x.base()`
|
||||||
@@ -188,7 +187,7 @@ above are defined as follows:
|
|||||||
|
|
||||||
template <
|
template <
|
||||||
class OtherDerived, class OtherIterator, class V, class C, class R, class D
|
class OtherDerived, class OtherIterator, class V, class C, class R, class D
|
||||||
>
|
>
|
||||||
typename iterator_adaptor::difference_type distance_to(
|
typename iterator_adaptor::difference_type distance_to(
|
||||||
iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& y) const;
|
iterator_adaptor<OtherDerived, OtherIterator, V, C, R, D> const& y) const;
|
||||||
|
|
||||||
@@ -229,7 +228,7 @@ operations on the underlying pointer, via the `node_iterator`\ 's
|
|||||||
|dereference_and_equal|_). The only real behavioral difference
|
|dereference_and_equal|_). The only real behavioral difference
|
||||||
between `node_base*` and `node_iterator` can be observed when
|
between `node_base*` and `node_iterator` can be observed when
|
||||||
they are incremented: `node_iterator` follows the
|
they are incremented: `node_iterator` follows the
|
||||||
`m_next` pointer, while `node_base*` just applies an address offset.
|
`m_next` pointer, while `node_base*` just applies an address offset.
|
||||||
|
|
||||||
.. |dereference_and_equal| replace:: `dereference` and `equal` member functions
|
.. |dereference_and_equal| replace:: `dereference` and `equal` member functions
|
||||||
.. _dereference_and_equal: iterator_facade.html#implementing-the-core-operations
|
.. _dereference_and_equal: iterator_facade.html#implementing-the-core-operations
|
||||||
@@ -287,8 +286,8 @@ this technique is known not to work with Borland C++ 5.6.4 and
|
|||||||
Metrowerks CodeWarrior versions prior to 9.0]
|
Metrowerks CodeWarrior versions prior to 9.0]
|
||||||
|
|
||||||
You can see an example program that exercises this version of the
|
You can see an example program that exercises this version of the
|
||||||
node iterators
|
node iterators
|
||||||
[@../example/node_iterator3.cpp `here`].
|
[example_link node_iterator3.cpp..here].
|
||||||
|
|
||||||
|
|
||||||
In the case of `node_iter`, it's not very compelling to pass
|
In the case of `node_iter`, it's not very compelling to pass
|
||||||
@@ -306,7 +305,7 @@ types to its `Base` saves the implementor of
|
|||||||
|
|
||||||
std::iterator_traits<Iterator>::*some-associated-type*
|
std::iterator_traits<Iterator>::*some-associated-type*
|
||||||
|
|
||||||
at least four times.
|
at least four times.
|
||||||
|
|
||||||
We urge you to review the documentation and implementations of
|
We urge you to review the documentation and implementations of
|
||||||
|reverse_iterator|_ and the other Boost `specialized iterator
|
|reverse_iterator|_ and the other Boost `specialized iterator
|
||||||
@@ -330,4 +329,4 @@ __ index.html#specialized-adaptors
|
|||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[section:archetypes Iterator Archetypes]
|
[section:archetypes Iterator Archetypes]
|
||||||
|
|
||||||
The `iterator_archetype` class constructs a minimal implementation of
|
The `iterator_archetype` class constructs a minimal implementation of
|
||||||
@@ -41,23 +40,23 @@ The access category types provided correspond to the following
|
|||||||
standard iterator access concept combinations:
|
standard iterator access concept combinations:
|
||||||
|
|
||||||
readable_iterator_t :=
|
readable_iterator_t :=
|
||||||
|
|
||||||
Readable Iterator
|
Readable Iterator
|
||||||
|
|
||||||
writable_iterator_t :=
|
writable_iterator_t :=
|
||||||
|
|
||||||
Writeable Iterator
|
Writeable Iterator
|
||||||
|
|
||||||
readable_writable_iterator_t :=
|
readable_writable_iterator_t :=
|
||||||
|
|
||||||
Readable Iterator & Writeable Iterator & Swappable Iterator
|
Readable Iterator & Writeable Iterator & Swappable Iterator
|
||||||
|
|
||||||
readable_lvalue_iterator_t :=
|
readable_lvalue_iterator_t :=
|
||||||
|
|
||||||
Readable Iterator & Lvalue Iterator
|
Readable Iterator & Lvalue Iterator
|
||||||
|
|
||||||
writeable_lvalue_iterator_t :=
|
writeable_lvalue_iterator_t :=
|
||||||
|
|
||||||
Readable Iterator & Writeable Iterator & Swappable Iterator & Lvalue Iterator
|
Readable Iterator & Writeable Iterator & Swappable Iterator & Lvalue Iterator
|
||||||
|
|
||||||
[h3 Traits]
|
[h3 Traits]
|
||||||
@@ -66,25 +65,25 @@ The nested trait types are defined as follows:
|
|||||||
|
|
||||||
|
|
||||||
if (AccessCategory == readable_iterator_t)
|
if (AccessCategory == readable_iterator_t)
|
||||||
|
|
||||||
value_type = Value
|
value_type = Value
|
||||||
reference = Value
|
reference = Value
|
||||||
pointer = Value*
|
pointer = Value*
|
||||||
|
|
||||||
else if (AccessCategory == writable_iterator_t)
|
else if (AccessCategory == writable_iterator_t)
|
||||||
|
|
||||||
value_type = void
|
value_type = void
|
||||||
reference = void
|
reference = void
|
||||||
pointer = void
|
pointer = void
|
||||||
|
|
||||||
else if (AccessCategory == readable_writable_iterator_t)
|
else if (AccessCategory == readable_writable_iterator_t)
|
||||||
|
|
||||||
value_type = Value
|
value_type = Value
|
||||||
|
|
||||||
reference :=
|
reference :=
|
||||||
|
|
||||||
A type X that is convertible to Value for which the following
|
A type X that is convertible to Value for which the following
|
||||||
expression is valid. Given an object x of type X and v of type
|
expression is valid. Given an object x of type X and v of type
|
||||||
Value.
|
Value.
|
||||||
|
|
||||||
x = v
|
x = v
|
||||||
@@ -92,13 +91,13 @@ The nested trait types are defined as follows:
|
|||||||
pointer = Value*
|
pointer = Value*
|
||||||
|
|
||||||
else if (AccessCategory == readable_lvalue_iterator_t)
|
else if (AccessCategory == readable_lvalue_iterator_t)
|
||||||
|
|
||||||
value_type = Value
|
value_type = Value
|
||||||
reference = Value const&
|
reference = Value const&
|
||||||
pointer = Value const*
|
pointer = Value const*
|
||||||
|
|
||||||
else if (AccessCategory == writable_lvalue_iterator_t)
|
else if (AccessCategory == writable_lvalue_iterator_t)
|
||||||
|
|
||||||
value_type = Value
|
value_type = Value
|
||||||
reference = Value&
|
reference = Value&
|
||||||
pointer = Value*
|
pointer = Value*
|
||||||
@@ -108,11 +107,11 @@ The nested trait types are defined as follows:
|
|||||||
difference_type := ptrdiff_t
|
difference_type := ptrdiff_t
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
difference_type := unspecified type
|
difference_type := unspecified type
|
||||||
|
|
||||||
|
|
||||||
iterator_category :=
|
iterator_category :=
|
||||||
|
|
||||||
A type X satisfying the following two constraints:
|
A type X satisfying the following two constraints:
|
||||||
|
|
||||||
@@ -156,5 +155,4 @@ the iterator concept specified by `AccessCategory` and
|
|||||||
arguments. `iterator_archetype` does not model any other access
|
arguments. `iterator_archetype` does not model any other access
|
||||||
concepts or any more derived traversal concepts.
|
concepts or any more derived traversal concepts.
|
||||||
|
|
||||||
|
[endsect]
|
||||||
[endsect]
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[section:concepts Iterator Concepts]
|
[section:concepts Iterator Concepts]
|
||||||
|
|
||||||
[section:access Access]
|
[section:access Access]
|
||||||
@@ -326,13 +325,13 @@ constant object of type `Distance`.
|
|||||||
[pre: there exists a value `n` of `Distance` such that `a + n == b`. `b == a + (b - a)`.]
|
[pre: there exists a value `n` of `Distance` such that `a + n == b`. `b == a + (b - a)`.]
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
[`a\[n\]`]
|
[`a[n]`]
|
||||||
[convertible to T]
|
[convertible to T]
|
||||||
[`*(a + n)`]
|
[`*(a + n)`]
|
||||||
[pre: a is a *Readable Iterator*]
|
[pre: a is a *Readable Iterator*]
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
[`a\[n\] = v`]
|
[`a[n] = v`]
|
||||||
[convertible to T]
|
[convertible to T]
|
||||||
[`*(a + n) = v`]
|
[`*(a + n) = v`]
|
||||||
[pre: a is a *Writable iterator*]
|
[pre: a is a *Writable iterator*]
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[section:counting Counting Iterator]
|
[section:counting Counting Iterator]
|
||||||
|
|
||||||
A `counting_iterator` adapts an object by adding an `operator*` that
|
A `counting_iterator` adapts an object by adding an `operator*` that
|
||||||
@@ -18,28 +17,30 @@ into the first array via indirection through the second array.
|
|||||||
std::vector<int> numbers;
|
std::vector<int> numbers;
|
||||||
typedef std::vector<int>::iterator n_iter;
|
typedef std::vector<int>::iterator n_iter;
|
||||||
std::copy(boost::counting_iterator<int>(0),
|
std::copy(boost::counting_iterator<int>(0),
|
||||||
boost::counting_iterator<int>(N),
|
boost::counting_iterator<int>(N),
|
||||||
std::back_inserter(numbers));
|
std::back_inserter(numbers));
|
||||||
|
|
||||||
std::vector<std::vector<int>::iterator> pointers;
|
std::vector<std::vector<int>::iterator> pointers;
|
||||||
std::copy(boost::make_counting_iterator(numbers.begin()),
|
std::copy(boost::make_counting_iterator(numbers.begin()),
|
||||||
boost::make_counting_iterator(numbers.end()),
|
boost::make_counting_iterator(numbers.end()),
|
||||||
std::back_inserter(pointers));
|
std::back_inserter(pointers));
|
||||||
|
|
||||||
std::cout << "indirectly printing out the numbers from 0 to "
|
std::cout << "indirectly printing out the numbers from 0 to "
|
||||||
<< N << std::endl;
|
<< N << std::endl;
|
||||||
std::copy(boost::make_indirect_iterator(pointers.begin()),
|
std::copy(boost::make_indirect_iterator(pointers.begin()),
|
||||||
boost::make_indirect_iterator(pointers.end()),
|
boost::make_indirect_iterator(pointers.end()),
|
||||||
std::ostream_iterator<int>(std::cout, " "));
|
std::ostream_iterator<int>(std::cout, " "));
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
|
||||||
The output is:
|
The output is:
|
||||||
|
|
||||||
indirectly printing out the numbers from 0 to 7
|
[pre
|
||||||
0 1 2 3 4 5 6
|
indirectly printing out the numbers from 0 to 7
|
||||||
|
0 1 2 3 4 5 6
|
||||||
|
]
|
||||||
|
|
||||||
The source code for this example can be found [@../example/counting_iterator_example.cpp here].
|
The source code for this example can be found [example_link counting_iterator_example.cpp..here].
|
||||||
|
|
||||||
[h2 Reference]
|
[h2 Reference]
|
||||||
|
|
||||||
@@ -86,9 +87,9 @@ algorithm:
|
|||||||
random_access_traversal_tag, Incrementable, const Incrementable&)
|
random_access_traversal_tag, Incrementable, const Incrementable&)
|
||||||
else
|
else
|
||||||
return |iterator-category|_\ (
|
return |iterator-category|_\ (
|
||||||
iterator_traversal<Incrementable>::type,
|
iterator_traversal<Incrementable>::type,
|
||||||
Incrementable, const Incrementable&)
|
Incrementable, const Incrementable&)
|
||||||
|
|
||||||
[blurb *Note:* implementers are encouraged to provide an implementation of
|
[blurb *Note:* implementers are encouraged to provide an implementation of
|
||||||
`operator-` and a `difference_type` that avoids overflows in
|
`operator-` and a `difference_type` that avoids overflows in
|
||||||
the cases where `std::numeric_limits<Incrementable>::is_specialized`
|
the cases where `std::numeric_limits<Incrementable>::is_specialized`
|
||||||
@@ -181,7 +182,7 @@ operations.
|
|||||||
counting_iterator& operator--();
|
counting_iterator& operator--();
|
||||||
|
|
||||||
[*Effects: ] `--m_inc`[br]
|
[*Effects: ] `--m_inc`[br]
|
||||||
[*Returns: ] `*this`
|
[*Returns: ] `*this`
|
||||||
|
|
||||||
|
|
||||||
Incrementable const& base() const;
|
Incrementable const& base() const;
|
||||||
@@ -189,4 +190,4 @@ operations.
|
|||||||
[*Returns: ] `m_inc`
|
[*Returns: ] `m_inc`
|
||||||
|
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[section:facade Iterator Facade]
|
[section:facade Iterator Facade]
|
||||||
|
|
||||||
While the iterator interface is rich, there is a core subset of the
|
While the iterator interface is rich, there is a core subset of the
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
|
|
||||||
[section:facade_tutorial Tutorial]
|
[section:facade_tutorial Tutorial]
|
||||||
|
|
||||||
In this section we'll walk through the implementation of a few
|
In this section we'll walk through the implementation of a few
|
||||||
iterators using `iterator_facade`, based around the simple
|
iterators using `iterator_facade`, based around the simple
|
||||||
example of a linked list of polymorphic objects. This example was
|
example of a linked list of polymorphic objects. This example was
|
||||||
inspired by a
|
inspired by a
|
||||||
[@http://thread.gmane.org/gmane.comp.lib.boost.user/5100 `posting`]
|
[@http://thread.gmane.org/gmane.comp.lib.boost.user/5100 `posting`]
|
||||||
by Keith Macdonald on the
|
by Keith Macdonald on the
|
||||||
[@http://www.boost.org/more/mailing_lists.htm#users `Boost-Users`]
|
[@http://www.boost.org/more/mailing_lists.htm#users `Boost-Users`]
|
||||||
mailing list.
|
mailing list.
|
||||||
|
|
||||||
@@ -30,16 +29,16 @@ Say we've written a polymorphic linked list node base class:
|
|||||||
|
|
||||||
// print to the stream
|
// print to the stream
|
||||||
virtual void print(std::ostream& s) const = 0;
|
virtual void print(std::ostream& s) const = 0;
|
||||||
|
|
||||||
// double the value
|
// double the value
|
||||||
virtual void double_me() = 0;
|
virtual void double_me() = 0;
|
||||||
|
|
||||||
void append(node_base* p)
|
void append(node_base* p)
|
||||||
{
|
{
|
||||||
if (m_next)
|
if (m_next)
|
||||||
m_next->append(p);
|
m_next->append(p);
|
||||||
else
|
else
|
||||||
m_next = p;
|
m_next = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -210,7 +209,7 @@ the concepts we want our iterator to model. Referring to the
|
|||||||
table__, we can see that the first three rows are applicable
|
table__, we can see that the first three rows are applicable
|
||||||
because `node_iterator` needs to satisfy the requirements for
|
because `node_iterator` needs to satisfy the requirements for
|
||||||
`readable iterator`_, `single pass iterator`_, and `incrementable
|
`readable iterator`_, `single pass iterator`_, and `incrementable
|
||||||
iterator`_.
|
iterator`_.
|
||||||
|
|
||||||
__ `core operations`_
|
__ `core operations`_
|
||||||
|
|
||||||
@@ -254,10 +253,10 @@ make them private and grant friendship to
|
|||||||
};
|
};
|
||||||
|
|
||||||
Voila; a complete and conforming readable, forward-traversal
|
Voila; a complete and conforming readable, forward-traversal
|
||||||
iterator! For a working example of its use, see
|
iterator! For a working example of its use, see
|
||||||
[@../example/node_iterator1.cpp `this program`].
|
[example_link node_iterator1.cpp..this program].
|
||||||
|
|
||||||
__ ../example/node_iterator1.cpp
|
__ ../../example/node_iterator1.cpp
|
||||||
|
|
||||||
[h2 A constant `node_iterator`]
|
[h2 A constant `node_iterator`]
|
||||||
|
|
||||||
@@ -265,7 +264,7 @@ __ ../example/node_iterator1.cpp
|
|||||||
The term **mutable iterator** means an iterator through which
|
The term **mutable iterator** means an iterator through which
|
||||||
the object it references (its "referent") can be modified. A
|
the object it references (its "referent") can be modified. A
|
||||||
**constant iterator** is one which doesn't allow modification of
|
**constant iterator** is one which doesn't allow modification of
|
||||||
its referent.[br][br]
|
its referent.[br][br]
|
||||||
The words *constant* and *mutable* don't refer to the ability to
|
The words *constant* and *mutable* don't refer to the ability to
|
||||||
modify the iterator itself. For example, an `int const*` is a
|
modify the iterator itself. For example, an `int const*` is a
|
||||||
non-\ `const` *constant iterator*, which can be incremented
|
non-\ `const` *constant iterator*, which can be incremented
|
||||||
@@ -402,7 +401,7 @@ adding a templatized converting constructor [#broken]_ [#random]_:
|
|||||||
|
|
||||||
template <class OtherValue>
|
template <class OtherValue>
|
||||||
bool equal(node_iter<OtherValue> const& other) const
|
bool equal(node_iter<OtherValue> const& other) const
|
||||||
{
|
{
|
||||||
return this->m_node == other.m_node;
|
return this->m_node == other.m_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,11 +427,11 @@ adding a templatized converting constructor [#broken]_ [#random]_:
|
|||||||
`distance_to` function as well.
|
`distance_to` function as well.
|
||||||
|
|
||||||
|
|
||||||
__ ../example/node_iterator2.hpp
|
__ ../../example/node_iterator2.hpp
|
||||||
|
|
||||||
You can see an example program which exercises our interoperable
|
You can see an example program which exercises our interoperable
|
||||||
iterators
|
iterators
|
||||||
[@../example/node_iterator2.cpp `here`].
|
[example_link node_iterator2.cpp..here].
|
||||||
|
|
||||||
|
|
||||||
[h2 Telling the Truth]
|
[h2 Telling the Truth]
|
||||||
@@ -467,7 +466,7 @@ appropriate:
|
|||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct enabler {};
|
struct enabler {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[section:filter Filter Iterator]
|
[section:filter Filter Iterator]
|
||||||
|
|
||||||
The filter iterator adaptor creates a view of an iterator range in
|
The filter iterator adaptor creates a view of an iterator range in
|
||||||
@@ -19,7 +18,6 @@ This example uses `filter_iterator` and then
|
|||||||
array of integers. Then `make_filter_iterator` is is used to output
|
array of integers. Then `make_filter_iterator` is is used to output
|
||||||
the integers greater than `-2`.
|
the integers greater than `-2`.
|
||||||
|
|
||||||
|
|
||||||
struct is_positive_number {
|
struct is_positive_number {
|
||||||
bool operator()(int x) { return 0 < x; }
|
bool operator()(int x) { return 0 < x; }
|
||||||
};
|
};
|
||||||
@@ -33,7 +31,7 @@ the integers greater than `-2`.
|
|||||||
base_iterator numbers(numbers_);
|
base_iterator numbers(numbers_);
|
||||||
|
|
||||||
// Example using filter_iterator
|
// Example using filter_iterator
|
||||||
typedef boost::filter_iterator<is_positive_number, base_iterator>
|
typedef boost::filter_iterator<is_positive_number, base_iterator>
|
||||||
FilterIter;
|
FilterIter;
|
||||||
|
|
||||||
is_positive_number predicate;
|
is_positive_number predicate;
|
||||||
@@ -52,11 +50,11 @@ the integers greater than `-2`.
|
|||||||
// Another example using make_filter_iterator()
|
// Another example using make_filter_iterator()
|
||||||
std::copy(
|
std::copy(
|
||||||
boost::make_filter_iterator(
|
boost::make_filter_iterator(
|
||||||
std::bind2nd(std::greater<int>(), -2)
|
std::bind(std::greater<int>(), std::placeholders::_1, -2)
|
||||||
, numbers, numbers + N)
|
, numbers, numbers + N)
|
||||||
|
|
||||||
, boost::make_filter_iterator(
|
, boost::make_filter_iterator(
|
||||||
std::bind2nd(std::greater<int>(), -2)
|
std::bind(std::greater<int>(), std::placeholders::_1, -2)
|
||||||
, numbers + N, numbers + N)
|
, numbers + N, numbers + N)
|
||||||
|
|
||||||
, std::ostream_iterator<int>(std::cout, " ")
|
, std::ostream_iterator<int>(std::cout, " ")
|
||||||
@@ -70,12 +68,13 @@ the integers greater than `-2`.
|
|||||||
|
|
||||||
The output is:
|
The output is:
|
||||||
|
|
||||||
4 5 8
|
[pre
|
||||||
4 5 8
|
4 5 8
|
||||||
0 -1 4 5 8
|
4 5 8
|
||||||
|
0 -1 4 5 8
|
||||||
|
]
|
||||||
|
|
||||||
|
The source code for this example can be found [example_link filter_iterator_example.cpp..here].
|
||||||
The source code for this example can be found [@../example/filter_iterator_example.cpp here].
|
|
||||||
|
|
||||||
[h2 Reference]
|
[h2 Reference]
|
||||||
|
|
||||||
@@ -114,10 +113,10 @@ The source code for this example can be found [@../example/filter_iterator_examp
|
|||||||
|
|
||||||
If `Iterator` models Readable Lvalue Iterator and Bidirectional Traversal
|
If `Iterator` models Readable Lvalue Iterator and Bidirectional Traversal
|
||||||
Iterator then `iterator_category` is convertible to
|
Iterator then `iterator_category` is convertible to
|
||||||
`std::bidirectional_iterator_tag`.
|
`std::bidirectional_iterator_tag`.
|
||||||
Otherwise, if `Iterator` models Readable Lvalue Iterator and Forward Traversal
|
Otherwise, if `Iterator` models Readable Lvalue Iterator and Forward Traversal
|
||||||
Iterator then `iterator_category` is convertible to
|
Iterator then `iterator_category` is convertible to
|
||||||
`std::forward_iterator_tag`.
|
`std::forward_iterator_tag`.
|
||||||
Otherwise `iterator_category` is
|
Otherwise `iterator_category` is
|
||||||
convertible to `std::input_iterator_tag`.
|
convertible to `std::input_iterator_tag`.
|
||||||
|
|
||||||
@@ -164,7 +163,7 @@ following tables.
|
|||||||
[[Writable Lvalue Iterator, Bidirectional Iterator ][Mutable Bidirectional Iterator]]
|
[[Writable Lvalue Iterator, Bidirectional Iterator ][Mutable Bidirectional Iterator]]
|
||||||
]
|
]
|
||||||
|
|
||||||
`filter_iterator<P1, X>` is interoperable with `filter_iterator<P2, Y>`
|
`filter_iterator<P1, X>` is interoperable with `filter_iterator<P2, Y>`
|
||||||
if and only if `X` is interoperable with `Y`.
|
if and only if `X` is interoperable with `Y`.
|
||||||
|
|
||||||
|
|
||||||
@@ -179,14 +178,14 @@ operations.
|
|||||||
filter_iterator();
|
filter_iterator();
|
||||||
|
|
||||||
[*Requires: ]`Predicate` and `Iterator` must be Default Constructible.[br]
|
[*Requires: ]`Predicate` and `Iterator` must be Default Constructible.[br]
|
||||||
[*Effects: ] Constructs a `filter_iterator` whose`m_pred`, `m_iter`, and `m_end`
|
[*Effects: ] Constructs a `filter_iterator` whose`m_pred`, `m_iter`, and `m_end`
|
||||||
members are a default constructed.
|
members are a default constructed.
|
||||||
|
|
||||||
|
|
||||||
filter_iterator(Predicate f, Iterator x, Iterator end = Iterator());
|
filter_iterator(Predicate f, Iterator x, Iterator end = Iterator());
|
||||||
|
|
||||||
[*Effects: ] Constructs a `filter_iterator` where `m_iter` is either
|
[*Effects: ] Constructs a `filter_iterator` where `m_iter` is either
|
||||||
the first position in the range `[x,end)` such that `f(*m_iter) == true`
|
the first position in the range `[x,end)` such that `f(*m_iter) == true`
|
||||||
or else`m_iter == end`. The member `m_pred` is constructed from
|
or else`m_iter == end`. The member `m_pred` is constructed from
|
||||||
`f` and `m_end` from `end`.
|
`f` and `m_end` from `end`.
|
||||||
|
|
||||||
@@ -197,7 +196,7 @@ operations.
|
|||||||
[*Requires: ] `Predicate` must be Default Constructible and
|
[*Requires: ] `Predicate` must be Default Constructible and
|
||||||
`Predicate` is a class type (not a function pointer).[br]
|
`Predicate` is a class type (not a function pointer).[br]
|
||||||
[*Effects: ] Constructs a `filter_iterator` where `m_iter` is either
|
[*Effects: ] Constructs a `filter_iterator` where `m_iter` is either
|
||||||
the first position in the range `[x,end)` such that `m_pred(*m_iter) == true`
|
the first position in the range `[x,end)` such that `m_pred(*m_iter) == true`
|
||||||
or else`m_iter == end`. The member `m_pred` is default constructed.
|
or else`m_iter == end`. The member `m_pred` is default constructed.
|
||||||
|
|
||||||
|
|
||||||
@@ -236,7 +235,6 @@ operations.
|
|||||||
[*Effects: ] Increments `m_iter` and then continues to
|
[*Effects: ] Increments `m_iter` and then continues to
|
||||||
increment `m_iter` until either `m_iter == m_end`
|
increment `m_iter` until either `m_iter == m_end`
|
||||||
or `m_pred(*m_iter) == true`.[br]
|
or `m_pred(*m_iter) == true`.[br]
|
||||||
[*Returns: ] `*this`
|
[*Returns: ] `*this`
|
||||||
|
|
||||||
|
[endsect]
|
||||||
[endsect]
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[section:function_output Function Output Iterator]
|
[section:function_output Function Output Iterator]
|
||||||
|
|
||||||
The function output iterator adaptor makes it easier to create custom
|
The function output iterator adaptor makes it easier to create custom
|
||||||
@@ -34,7 +33,7 @@ proxy object.
|
|||||||
x.push_back("!");
|
x.push_back("!");
|
||||||
|
|
||||||
std::string s = "";
|
std::string s = "";
|
||||||
std::copy(x.begin(), x.end(),
|
std::copy(x.begin(), x.end(),
|
||||||
boost::make_function_output_iterator(string_appender(s)));
|
boost::make_function_output_iterator(string_appender(s)));
|
||||||
|
|
||||||
std::cout << s << std::endl;
|
std::cout << s << std::endl;
|
||||||
@@ -68,7 +67,7 @@ proxy object.
|
|||||||
|
|
||||||
[h3 Requirements]
|
[h3 Requirements]
|
||||||
|
|
||||||
`UnaryFunction` must be Assignable and Copy Constructible.
|
`UnaryFunction` must be Assignable and Copy Constructible.
|
||||||
|
|
||||||
[h3 Concepts]
|
[h3 Concepts]
|
||||||
|
|
||||||
@@ -79,14 +78,14 @@ Incrementable Iterator concepts.
|
|||||||
|
|
||||||
explicit function_output_iterator(const UnaryFunction& f = UnaryFunction());
|
explicit function_output_iterator(const UnaryFunction& f = UnaryFunction());
|
||||||
|
|
||||||
[*Effects: ] Constructs an instance of `function_output_iterator`
|
[*Effects: ] Constructs an instance of `function_output_iterator`
|
||||||
with `m_f` constructed from `f`.
|
with `m_f` constructed from `f`.
|
||||||
|
|
||||||
unspecified_type operator*();
|
unspecified_type operator*();
|
||||||
|
|
||||||
[*Returns: ] An object `r` of unspecified type such that `r = t`
|
[*Returns: ] An object `r` of unspecified type such that `r = t`
|
||||||
is equivalent to `m_f(t)` for all `t`.
|
is equivalent to `m_f(t)` for all `t`.
|
||||||
|
|
||||||
|
|
||||||
function_output_iterator& operator++();
|
function_output_iterator& operator++();
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[section:indirect Indirect Iterator]
|
[section:indirect Indirect Iterator]
|
||||||
|
|
||||||
`indirect_iterator` adapts an iterator by applying an
|
`indirect_iterator` adapts an iterator by applying an
|
||||||
@@ -50,30 +49,31 @@ using the `make_indirect_iterator` helper function.
|
|||||||
const_indirect_last(pointers_to_chars + N);
|
const_indirect_last(pointers_to_chars + N);
|
||||||
|
|
||||||
std::transform(const_indirect_first, const_indirect_last,
|
std::transform(const_indirect_first, const_indirect_last,
|
||||||
mutable_indirect_first, std::bind1st(std::plus<char>(), 1));
|
mutable_indirect_first, std::bind(std::plus<char>(), 1, std::placeholders::_1));
|
||||||
|
|
||||||
std::copy(mutable_indirect_first, mutable_indirect_last,
|
std::copy(mutable_indirect_first, mutable_indirect_last,
|
||||||
std::ostream_iterator<char>(std::cout, ","));
|
std::ostream_iterator<char>(std::cout, ","));
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
|
||||||
// Example of using make_indirect_iterator()
|
// Example of using make_indirect_iterator()
|
||||||
|
|
||||||
std::copy(boost::make_indirect_iterator(pointers_to_chars),
|
std::copy(boost::make_indirect_iterator(pointers_to_chars),
|
||||||
boost::make_indirect_iterator(pointers_to_chars + N),
|
boost::make_indirect_iterator(pointers_to_chars + N),
|
||||||
std::ostream_iterator<char>(std::cout, ","));
|
std::ostream_iterator<char>(std::cout, ","));
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
|
||||||
The output is:
|
The output is:
|
||||||
|
|
||||||
a,b,c,d,e,f,g,
|
[pre
|
||||||
b,c,d,e,f,g,h,
|
a,b,c,d,e,f,g,
|
||||||
a,b,c,d,e,f,g,
|
b,c,d,e,f,g,h,
|
||||||
|
a,b,c,d,e,f,g,
|
||||||
|
]
|
||||||
|
|
||||||
|
The source code for this example can be found
|
||||||
The source code for this example can be found
|
[example_link indirect_iterator_example.cpp..here].
|
||||||
[@../example/indirect_iterator_example.cpp here].
|
|
||||||
|
|
||||||
|
|
||||||
[h2 Reference]
|
[h2 Reference]
|
||||||
@@ -137,9 +137,9 @@ the following pseudo-code, where `V` is
|
|||||||
else
|
else
|
||||||
typedef Reference reference;
|
typedef Reference reference;
|
||||||
|
|
||||||
if (Value is use_default) then
|
if (Value is use_default) then
|
||||||
typedef pointee<V>::type\* pointer;
|
typedef pointee<V>::type\* pointer;
|
||||||
else
|
else
|
||||||
typedef Value\* pointer;
|
typedef Value\* pointer;
|
||||||
|
|
||||||
if (Difference is use_default)
|
if (Difference is use_default)
|
||||||
@@ -204,7 +204,7 @@ following operations:
|
|||||||
indirect_iterator();
|
indirect_iterator();
|
||||||
|
|
||||||
[*Requires: ] `Iterator` must be Default Constructible.[br]
|
[*Requires: ] `Iterator` must be Default Constructible.[br]
|
||||||
[*Effects: ] Constructs an instance of `indirect_iterator` with
|
[*Effects: ] Constructs an instance of `indirect_iterator` with
|
||||||
a default-constructed `m_iterator`.
|
a default-constructed `m_iterator`.
|
||||||
|
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ following operations:
|
|||||||
);
|
);
|
||||||
|
|
||||||
[*Requires: ] `Iterator2` is implicitly convertible to `Iterator`.[br]
|
[*Requires: ] `Iterator2` is implicitly convertible to `Iterator`.[br]
|
||||||
[*Effects: ] Constructs an instance of `indirect_iterator` whose
|
[*Effects: ] Constructs an instance of `indirect_iterator` whose
|
||||||
`m_iterator` subobject is constructed from `y.base()`.
|
`m_iterator` subobject is constructed from `y.base()`.
|
||||||
|
|
||||||
|
|
||||||
@@ -251,4 +251,4 @@ following operations:
|
|||||||
[*Effects: ] `--m_iterator`[br]
|
[*Effects: ] `--m_iterator`[br]
|
||||||
[*Returns: ] `*this`
|
[*Returns: ] `*this`
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[library Boost.Iterator
|
[library Boost.Iterator
|
||||||
[/ version 1.0.1]
|
[/ version 1.0.1]
|
||||||
[quickbook 1.6]
|
[quickbook 1.6]
|
||||||
@@ -31,6 +30,7 @@
|
|||||||
|
|
||||||
[def _iterator_ [@../../../iterator/doc/index.html Boost.Iterator]]
|
[def _iterator_ [@../../../iterator/doc/index.html Boost.Iterator]]
|
||||||
[def _concept_check_ [@../../../concept_check/index.html Boost.ConceptCheck]]
|
[def _concept_check_ [@../../../concept_check/index.html Boost.ConceptCheck]]
|
||||||
|
[template example_link[name descr]'''<ulink url="../../example/'''[name]'''">'''[descr]'''</ulink>''']
|
||||||
|
|
||||||
[template sub[x]'''<subscript>'''[x]'''</subscript>''']
|
[template sub[x]'''<subscript>'''[x]'''</subscript>''']
|
||||||
|
|
||||||
@@ -305,4 +305,3 @@ library you see today.
|
|||||||
Patterns, C++ Report, February 1995, pp. 24-27.]
|
Patterns, C++ Report, February 1995, pp. 24-27.]
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[section:iterator_traits Iterator Traits]
|
[section:iterator_traits Iterator Traits]
|
||||||
|
|
||||||
`std::iterator_traits` provides access to five associated types
|
`std::iterator_traits` provides access to five associated types
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[section:permutation Permutation Iterator]
|
[section:permutation Permutation Iterator]
|
||||||
|
|
||||||
The permutation iterator adaptor provides a permuted view of a given
|
The permutation iterator adaptor provides a permuted view of a given
|
||||||
@@ -35,7 +34,7 @@ past-the-end iterator to the indices.
|
|||||||
*el_it = std::distance(elements.begin(), el_it);
|
*el_it = std::distance(elements.begin(), el_it);
|
||||||
|
|
||||||
index_type indices( index_size );
|
index_type indices( index_size );
|
||||||
for(index_type::iterator i_it = indices.begin() ; i_it != indices.end() ; ++i_it )
|
for(index_type::iterator i_it = indices.begin() ; i_it != indices.end() ; ++i_it )
|
||||||
*i_it = element_range_size - index_size + std::distance(indices.begin(), i_it);
|
*i_it = element_range_size - index_size + std::distance(indices.begin(), i_it);
|
||||||
std::reverse( indices.begin(), indices.end() );
|
std::reverse( indices.begin(), indices.end() );
|
||||||
|
|
||||||
@@ -75,27 +74,28 @@ past-the-end iterator to the indices.
|
|||||||
|
|
||||||
The output is:
|
The output is:
|
||||||
|
|
||||||
The original range is : 0 1 2 3 4 5 6 7 8 9
|
[pre
|
||||||
The reindexing scheme is : 9 8 7 6
|
The original range is : 0 1 2 3 4 5 6 7 8 9
|
||||||
The permutated range is : 9 8 7 6
|
The reindexing scheme is : 9 8 7 6
|
||||||
Elements at even indices in the permutation : 9 7
|
The permutated range is : 9 8 7 6
|
||||||
Permutation backwards : 6 7 8 9
|
Elements at even indices in the permutation : 9 7
|
||||||
Iterate backward with stride 2 : 6 8
|
Permutation backwards : 6 7 8 9
|
||||||
|
Iterate backward with stride 2 : 6 8
|
||||||
|
]
|
||||||
|
|
||||||
The source code for this example can be found
|
The source code for this example can be found
|
||||||
[@../example/permutation_iter_example.cpp here].
|
[example_link permutation_iter_example.cpp..here].
|
||||||
|
|
||||||
[h2 Reference]
|
[h2 Reference]
|
||||||
|
|
||||||
[h3 Synopsis]
|
[h3 Synopsis]
|
||||||
|
|
||||||
template< class ElementIterator
|
template< class ElementIterator
|
||||||
, class IndexIterator
|
, class IndexIterator
|
||||||
, class ValueT = use_default
|
, class ValueT = use_default
|
||||||
, class CategoryT = use_default
|
, class CategoryT = use_default
|
||||||
, class ReferenceT = use_default
|
, class ReferenceT = use_default
|
||||||
, class DifferenceT = use_default >
|
, class DifferenceT = use_default >
|
||||||
class permutation_iterator
|
class permutation_iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -104,10 +104,10 @@ The source code for this example can be found
|
|||||||
|
|
||||||
template< class OEIter, class OIIter, class V, class C, class R, class D >
|
template< class OEIter, class OIIter, class V, class C, class R, class D >
|
||||||
permutation_iterator(
|
permutation_iterator(
|
||||||
permutation_iterator<OEIter, OIIter, V, C, R, D> const& r
|
permutation_iterator<OEIter, OIIter, V, C, R, D> const& r
|
||||||
, typename enable_if_convertible<OEIter, ElementIterator>::type* = 0
|
, typename enable_if_convertible<OEIter, ElementIterator>::type* = 0
|
||||||
, typename enable_if_convertible<OIIter, IndexIterator>::type* = 0
|
, typename enable_if_convertible<OIIter, IndexIterator>::type* = 0
|
||||||
);
|
);
|
||||||
reference operator*() const;
|
reference operator*() const;
|
||||||
permutation_iterator& operator++();
|
permutation_iterator& operator++();
|
||||||
ElementIterator const& base() const;
|
ElementIterator const& base() const;
|
||||||
@@ -117,7 +117,7 @@ The source code for this example can be found
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <class ElementIterator, class IndexIterator>
|
template <class ElementIterator, class IndexIterator>
|
||||||
permutation_iterator<ElementIterator, IndexIterator>
|
permutation_iterator<ElementIterator, IndexIterator>
|
||||||
make_permutation_iterator( ElementIterator e, IndexIterator i);
|
make_permutation_iterator( ElementIterator e, IndexIterator i);
|
||||||
|
|
||||||
|
|
||||||
@@ -134,15 +134,15 @@ the `IndexIterator` must be convertible to the difference type of
|
|||||||
as `IndexIterator` and the same iterator access concepts as
|
as `IndexIterator` and the same iterator access concepts as
|
||||||
`ElementIterator`.
|
`ElementIterator`.
|
||||||
|
|
||||||
If `IndexIterator` models Single Pass Iterator and
|
If `IndexIterator` models Single Pass Iterator and
|
||||||
`ElementIterator` models Readable Iterator then
|
`ElementIterator` models Readable Iterator then
|
||||||
`permutation_iterator` models Input Iterator.
|
`permutation_iterator` models Input Iterator.
|
||||||
|
|
||||||
If `IndexIterator` models Forward Traversal Iterator and
|
If `IndexIterator` models Forward Traversal Iterator and
|
||||||
`ElementIterator` models Readable Lvalue Iterator then
|
`ElementIterator` models Readable Lvalue Iterator then
|
||||||
`permutation_iterator` models Forward Iterator.
|
`permutation_iterator` models Forward Iterator.
|
||||||
|
|
||||||
If `IndexIterator` models Bidirectional Traversal Iterator and
|
If `IndexIterator` models Bidirectional Traversal Iterator and
|
||||||
`ElementIterator` models Readable Lvalue Iterator then
|
`ElementIterator` models Readable Lvalue Iterator then
|
||||||
`permutation_iterator` models Bidirectional Iterator.
|
`permutation_iterator` models Bidirectional Iterator.
|
||||||
|
|
||||||
@@ -173,10 +173,10 @@ following operations.
|
|||||||
|
|
||||||
template< class OEIter, class OIIter, class V, class C, class R, class D >
|
template< class OEIter, class OIIter, class V, class C, class R, class D >
|
||||||
permutation_iterator(
|
permutation_iterator(
|
||||||
permutation_iterator<OEIter, OIIter, V, C, R, D> const& r
|
permutation_iterator<OEIter, OIIter, V, C, R, D> const& r
|
||||||
, typename enable_if_convertible<OEIter, ElementIterator>::type* = 0
|
, typename enable_if_convertible<OEIter, ElementIterator>::type* = 0
|
||||||
, typename enable_if_convertible<OIIter, IndexIterator>::type* = 0
|
, typename enable_if_convertible<OIIter, IndexIterator>::type* = 0
|
||||||
);
|
);
|
||||||
|
|
||||||
[*Effects: ] Constructs `m_elt` from `r.m_elt` and
|
[*Effects: ] Constructs `m_elt` from `r.m_elt` and
|
||||||
`m_order` from `y.m_order`.
|
`m_order` from `y.m_order`.
|
||||||
@@ -199,9 +199,9 @@ following operations.
|
|||||||
|
|
||||||
|
|
||||||
template <class ElementIterator, class IndexIterator>
|
template <class ElementIterator, class IndexIterator>
|
||||||
permutation_iterator<ElementIterator, IndexIterator>
|
permutation_iterator<ElementIterator, IndexIterator>
|
||||||
make_permutation_iterator(ElementIterator e, IndexIterator i);
|
make_permutation_iterator(ElementIterator e, IndexIterator i);
|
||||||
|
|
||||||
[*Returns: ] `permutation_iterator<ElementIterator, IndexIterator>(e, i)`
|
[*Returns: ] `permutation_iterator<ElementIterator, IndexIterator>(e, i)`
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[section:reverse Reverse Iterator]
|
[section:reverse Reverse Iterator]
|
||||||
|
|
||||||
The reverse iterator adaptor iterates through the adapted iterator
|
The reverse iterator adaptor iterates through the adapted iterator
|
||||||
@@ -9,7 +8,6 @@ range in the opposite direction.
|
|||||||
The following example prints an array of characters in reverse order
|
The following example prints an array of characters in reverse order
|
||||||
using `reverse_iterator`.
|
using `reverse_iterator`.
|
||||||
|
|
||||||
|
|
||||||
char letters_[] = "hello world!";
|
char letters_[] = "hello world!";
|
||||||
const int N = sizeof(letters_)/sizeof(char) - 1;
|
const int N = sizeof(letters_)/sizeof(char) - 1;
|
||||||
typedef char* base_iterator;
|
typedef char* base_iterator;
|
||||||
@@ -35,13 +33,14 @@ using `reverse_iterator`.
|
|||||||
|
|
||||||
The output is:
|
The output is:
|
||||||
|
|
||||||
original sequence of letters: hello world!
|
[pre
|
||||||
sequence in reverse order: !dlrow olleh
|
original sequence of letters: hello world!
|
||||||
sequence in double-reversed (normal) order: hello world!
|
sequence in reverse order: !dlrow olleh
|
||||||
|
sequence in double-reversed (normal) order: hello world!
|
||||||
|
]
|
||||||
|
|
||||||
The source code for this example can be found
|
The source code for this example can be found
|
||||||
[@../example/reverse_iterator_example.cpp here].
|
[example_link reverse_iterator_example.cpp..here].
|
||||||
|
|
||||||
[h2 Reference]
|
[h2 Reference]
|
||||||
|
|
||||||
@@ -116,7 +115,7 @@ operations.
|
|||||||
reverse_iterator();
|
reverse_iterator();
|
||||||
|
|
||||||
[*Requires: ] `Iterator` must be Default Constructible.[br]
|
[*Requires: ] `Iterator` must be Default Constructible.[br]
|
||||||
[*Effects: ] Constructs an instance of `reverse_iterator` with `m_iterator`
|
[*Effects: ] Constructs an instance of `reverse_iterator` with `m_iterator`
|
||||||
default constructed.
|
default constructed.
|
||||||
|
|
||||||
explicit reverse_iterator(Iterator x);
|
explicit reverse_iterator(Iterator x);
|
||||||
@@ -132,7 +131,7 @@ operations.
|
|||||||
);
|
);
|
||||||
|
|
||||||
[*Requires: ] `OtherIterator` is implicitly convertible to `Iterator`.[br]
|
[*Requires: ] `OtherIterator` is implicitly convertible to `Iterator`.[br]
|
||||||
[*Effects: ] Constructs instance of `reverse_iterator` whose
|
[*Effects: ] Constructs instance of `reverse_iterator` whose
|
||||||
`m_iterator` subobject is constructed from `y.base()`.
|
`m_iterator` subobject is constructed from `y.base()`.
|
||||||
|
|
||||||
|
|
||||||
@@ -157,4 +156,4 @@ operations.
|
|||||||
[*Effects: ] `++m_iterator`[br]
|
[*Effects: ] `++m_iterator`[br]
|
||||||
[*Returns: ] `*this`
|
[*Returns: ] `*this`
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[section:shared_container Shared Container Iterator]
|
[section:shared_container Shared Container Iterator]
|
||||||
|
|
||||||
Defined in header [@../../../boost/shared_container_iterator.hpp `boost/shared_container_iterator.hpp`].
|
Defined in header [@../../../boost/shared_container_iterator.hpp `boost/shared_container_iterator.hpp`].
|
||||||
@@ -27,12 +26,12 @@ iterator.
|
|||||||
namespace boost {
|
namespace boost {
|
||||||
template <typename Container>
|
template <typename Container>
|
||||||
class shared_container_iterator;
|
class shared_container_iterator;
|
||||||
|
|
||||||
template <typename Container>
|
template <typename Container>
|
||||||
shared_container_iterator<Container>
|
shared_container_iterator<Container>
|
||||||
make_shared_container_iterator(typename Container::iterator base,
|
make_shared_container_iterator(typename Container::iterator base,
|
||||||
boost::shared_ptr<Container> const& container);
|
boost::shared_ptr<Container> const& container);
|
||||||
|
|
||||||
std::pair<
|
std::pair<
|
||||||
typename shared_container_iterator<Container>,
|
typename shared_container_iterator<Container>,
|
||||||
typename shared_container_iterator<Container>
|
typename shared_container_iterator<Container>
|
||||||
@@ -46,7 +45,7 @@ iterator.
|
|||||||
|
|
||||||
The class template `shared_container_iterator` is the shared container
|
The class template `shared_container_iterator` is the shared container
|
||||||
iterator type. The `Container` template type argument must model the
|
iterator type. The `Container` template type argument must model the
|
||||||
[@http://www.sgi.com/tech/stl/Container.html Container] concept.
|
[@http://www.sgi.com/tech/stl/Container.html Container] concept.
|
||||||
|
|
||||||
[h2 Example]
|
[h2 Example]
|
||||||
|
|
||||||
@@ -56,48 +55,50 @@ original shared pointer `ints` ceases to exist after `set_range()`
|
|||||||
returns, the `shared_counter_iterator` objects maintain references to
|
returns, the `shared_counter_iterator` objects maintain references to
|
||||||
the underlying vector and thereby extend the container's lifetime.
|
the underlying vector and thereby extend the container's lifetime.
|
||||||
|
|
||||||
[@../../example/shared_iterator_example1.cpp `shared_iterator_example1.cpp`]:
|
[example_link shared_iterator_example1.cpp..`shared_iterator_example1.cpp`]:
|
||||||
|
|
||||||
#include "shared_container_iterator.hpp"
|
#include "shared_container_iterator.hpp"
|
||||||
#include "boost/shared_ptr.hpp"
|
#include "boost/shared_ptr.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
typedef boost::shared_container_iterator< std::vector<int> > iterator;
|
typedef boost::shared_container_iterator< std::vector<int> > iterator;
|
||||||
|
|
||||||
|
|
||||||
void set_range(iterator& i, iterator& end) {
|
void set_range(iterator& i, iterator& end) {
|
||||||
|
|
||||||
boost::shared_ptr< std::vector<int> > ints(new std::vector<int>());
|
boost::shared_ptr< std::vector<int> > ints(new std::vector<int>());
|
||||||
|
|
||||||
ints->push_back(0);
|
ints->push_back(0);
|
||||||
ints->push_back(1);
|
ints->push_back(1);
|
||||||
ints->push_back(2);
|
ints->push_back(2);
|
||||||
ints->push_back(3);
|
ints->push_back(3);
|
||||||
ints->push_back(4);
|
ints->push_back(4);
|
||||||
ints->push_back(5);
|
ints->push_back(5);
|
||||||
|
|
||||||
i = iterator(ints->begin(),ints);
|
i = iterator(ints->begin(),ints);
|
||||||
end = iterator(ints->end(),ints);
|
end = iterator(ints->end(),ints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
iterator i,end;
|
iterator i,end;
|
||||||
|
|
||||||
set_range(i,end);
|
set_range(i,end);
|
||||||
|
|
||||||
std::copy(i,end,std::ostream_iterator<int>(std::cout,","));
|
std::copy(i,end,std::ostream_iterator<int>(std::cout,","));
|
||||||
std::cout.put('\n');
|
std::cout.put('\n');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
The output from this part is:
|
The output from this part is:
|
||||||
|
|
||||||
0,1,2,3,4,5,
|
[pre
|
||||||
|
0,1,2,3,4,5,
|
||||||
|
]
|
||||||
|
|
||||||
[table Template Parameters
|
[table Template Parameters
|
||||||
[[Parameter][Description]]
|
[[Parameter][Description]]
|
||||||
@@ -130,16 +131,16 @@ iterator will be valid. In addition it has the following constructor:
|
|||||||
boost::shared_ptr<Container> const& container)
|
boost::shared_ptr<Container> const& container)
|
||||||
|
|
||||||
This function provides an alternative to directly constructing a
|
This function provides an alternative to directly constructing a
|
||||||
`shared_container_iterator`. Using the object generator, a
|
`shared_container_iterator`. Using the object generator, a
|
||||||
`shared_container_iterator` can be created and passed to a function without
|
`shared_container_iterator` can be created and passed to a function without
|
||||||
explicitly specifying its type.
|
explicitly specifying its type.
|
||||||
|
|
||||||
[h2 Example]
|
[h2 Example]
|
||||||
|
|
||||||
This example, similar to the previous,
|
This example, similar to the previous,
|
||||||
uses `make_shared_container_iterator()` to create the iterators.
|
uses `make_shared_container_iterator()` to create the iterators.
|
||||||
|
|
||||||
[@../../example/shared_iterator_example2.cpp `shared_iterator_example2.cpp`]:
|
[example_link shared_iterator_example2.cpp..`shared_iterator_example2.cpp`]:
|
||||||
|
|
||||||
#include "shared_container_iterator.hpp"
|
#include "shared_container_iterator.hpp"
|
||||||
#include "boost/shared_ptr.hpp"
|
#include "boost/shared_ptr.hpp"
|
||||||
@@ -147,35 +148,35 @@ uses `make_shared_container_iterator()` to create the iterators.
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
template <typename Iterator>
|
template <typename Iterator>
|
||||||
void print_range_nl (Iterator begin, Iterator end) {
|
void print_range_nl (Iterator begin, Iterator end) {
|
||||||
typedef typename std::iterator_traits<Iterator>::value_type val;
|
typedef typename std::iterator_traits<Iterator>::value_type val;
|
||||||
std::copy(begin,end,std::ostream_iterator<val>(std::cout,","));
|
std::copy(begin,end,std::ostream_iterator<val>(std::cout,","));
|
||||||
std::cout.put('\n');
|
std::cout.put('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
typedef boost::shared_ptr< std::vector<int> > ints_t;
|
typedef boost::shared_ptr< std::vector<int> > ints_t;
|
||||||
{
|
{
|
||||||
ints_t ints(new std::vector<int>());
|
ints_t ints(new std::vector<int>());
|
||||||
|
|
||||||
ints->push_back(0);
|
ints->push_back(0);
|
||||||
ints->push_back(1);
|
ints->push_back(1);
|
||||||
ints->push_back(2);
|
ints->push_back(2);
|
||||||
ints->push_back(3);
|
ints->push_back(3);
|
||||||
ints->push_back(4);
|
ints->push_back(4);
|
||||||
ints->push_back(5);
|
ints->push_back(5);
|
||||||
|
|
||||||
print_range_nl(boost::make_shared_container_iterator(ints->begin(),ints),
|
print_range_nl(boost::make_shared_container_iterator(ints->begin(),ints),
|
||||||
boost::make_shared_container_iterator(ints->end(),ints));
|
boost::make_shared_container_iterator(ints->end(),ints));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,18 +201,18 @@ named. The output from this example is the same as the previous.
|
|||||||
|
|
||||||
In the following example, a range of values is returned as a pair of shared_container_iterator objects.
|
In the following example, a range of values is returned as a pair of shared_container_iterator objects.
|
||||||
|
|
||||||
[@../../example/shared_iterator_example3.cpp `shared_iterator_example3.cpp`]:
|
[example_link shared_iterator_example3.cpp..`shared_iterator_example3.cpp`]:
|
||||||
|
|
||||||
#include "shared_container_iterator.hpp"
|
#include "shared_container_iterator.hpp"
|
||||||
#include "boost/shared_ptr.hpp"
|
#include "boost/shared_ptr.hpp"
|
||||||
#include "boost/tuple/tuple.hpp" // for boost::tie
|
#include "boost/tuple/tuple.hpp" // for boost::tie
|
||||||
#include <algorithm> // for std::copy
|
#include <algorithm> // for std::copy
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
typedef boost::shared_container_iterator< std::vector<int> > iterator;
|
typedef boost::shared_container_iterator< std::vector<int> > iterator;
|
||||||
|
|
||||||
std::pair<iterator,iterator>
|
std::pair<iterator,iterator>
|
||||||
return_range() {
|
return_range() {
|
||||||
boost::shared_ptr< std::vector<int> > range(new std::vector<int>());
|
boost::shared_ptr< std::vector<int> > range(new std::vector<int>());
|
||||||
@@ -223,18 +224,18 @@ In the following example, a range of values is returned as a pair of shared_cont
|
|||||||
range->push_back(5);
|
range->push_back(5);
|
||||||
return boost::make_shared_container_range(range);
|
return boost::make_shared_container_range(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
|
|
||||||
iterator i,end;
|
iterator i,end;
|
||||||
|
|
||||||
boost::tie(i,end) = return_range();
|
boost::tie(i,end) = return_range();
|
||||||
|
|
||||||
std::copy(i,end,std::ostream_iterator<int>(std::cout,","));
|
std::copy(i,end,std::ostream_iterator<int>(std::cout,","));
|
||||||
std::cout.put('\n');
|
std::cout.put('\n');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,4 +246,4 @@ the same as the previous two.
|
|||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[section:specialized Specialized Adaptors]
|
[section:specialized Specialized Adaptors]
|
||||||
|
|
||||||
[include ./counting_iterator.qbk]
|
[include ./counting_iterator.qbk]
|
||||||
@@ -19,4 +18,4 @@
|
|||||||
|
|
||||||
[include ./zip_iterator.qbk]
|
[include ./zip_iterator.qbk]
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
[section:transform Transform Iterator]
|
[section:transform Transform Iterator]
|
||||||
|
|
||||||
The transform iterator adapts an iterator by modifying the
|
The transform iterator adapts an iterator by modifying the
|
||||||
@@ -14,37 +13,38 @@ generate iterators that multiply (or add to) the value returned by
|
|||||||
dereferencing the iterator. It would be cooler to use lambda library
|
dereferencing the iterator. It would be cooler to use lambda library
|
||||||
in this example.
|
in this example.
|
||||||
|
|
||||||
int x[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
|
int x[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||||
const int N = sizeof(x)/sizeof(int);
|
const int N = sizeof(x)/sizeof(int);
|
||||||
|
|
||||||
typedef boost::binder1st< std::multiplies<int> > Function;
|
typedef boost::binder1st< std::multiplies<int> > Function;
|
||||||
typedef boost::transform_iterator<Function, int*> doubling_iterator;
|
typedef boost::transform_iterator<Function, int*> doubling_iterator;
|
||||||
|
|
||||||
doubling_iterator i(x, boost::bind1st(std::multiplies<int>(), 2)),
|
doubling_iterator i(x, boost::bind1st(std::multiplies<int>(), 2)),
|
||||||
i_end(x + N, boost::bind1st(std::multiplies<int>(), 2));
|
i_end(x + N, boost::bind1st(std::multiplies<int>(), 2));
|
||||||
|
|
||||||
std::cout << "multiplying the array by 2:" << std::endl;
|
std::cout << "multiplying the array by 2:" << std::endl;
|
||||||
while (i != i_end)
|
while (i != i_end)
|
||||||
std::cout << *i++ << " ";
|
std::cout << *i++ << " ";
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
std::cout << "adding 4 to each element in the array:" << std::endl;
|
std::cout << "adding 4 to each element in the array:" << std::endl;
|
||||||
std::copy(boost::make_transform_iterator(x, boost::bind1st(std::plus<int>(), 4)),
|
std::copy(boost::make_transform_iterator(x, boost::bind1st(std::plus<int>(), 4)),
|
||||||
boost::make_transform_iterator(x + N, boost::bind1st(std::plus<int>(), 4)),
|
boost::make_transform_iterator(x + N, boost::bind1st(std::plus<int>(), 4)),
|
||||||
std::ostream_iterator<int>(std::cout, " "));
|
std::ostream_iterator<int>(std::cout, " "));
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
|
||||||
The output is:
|
The output is:
|
||||||
|
|
||||||
multiplying the array by 2:
|
[pre
|
||||||
2 4 6 8 10 12 14 16
|
multiplying the array by 2:
|
||||||
adding 4 to each element in the array:
|
2 4 6 8 10 12 14 16
|
||||||
5 6 7 8 9 10 11 12
|
adding 4 to each element in the array:
|
||||||
|
5 6 7 8 9 10 11 12
|
||||||
|
]
|
||||||
|
|
||||||
|
The source code for this example can be found
|
||||||
The source code for this example can be found
|
[example_link transform_iterator_example.cpp..here].
|
||||||
[@../example/transform_iterator_example.cpp here].
|
|
||||||
|
|
||||||
[h2 Reference]
|
[h2 Reference]
|
||||||
|
|
||||||
@@ -52,8 +52,8 @@ The source code for this example can be found
|
|||||||
[h3 Synopsis]
|
[h3 Synopsis]
|
||||||
|
|
||||||
template <class UnaryFunction,
|
template <class UnaryFunction,
|
||||||
class Iterator,
|
class Iterator,
|
||||||
class Reference = use_default,
|
class Reference = use_default,
|
||||||
class Value = use_default>
|
class Value = use_default>
|
||||||
class transform_iterator
|
class transform_iterator
|
||||||
{
|
{
|
||||||
@@ -116,7 +116,7 @@ where the type of `f(*i)` must be
|
|||||||
`result_of<const UnaryFunction(iterator_traits<Iterator>::reference)>::type`.
|
`result_of<const UnaryFunction(iterator_traits<Iterator>::reference)>::type`.
|
||||||
|
|
||||||
|
|
||||||
The argument `Iterator` shall model Readable Iterator.
|
The argument `Iterator` shall model Readable Iterator.
|
||||||
|
|
||||||
|
|
||||||
[h3 Concepts]
|
[h3 Concepts]
|
||||||
@@ -126,11 +126,11 @@ The resulting `transform_iterator` models the most refined of the
|
|||||||
following that is also modeled by `Iterator`.
|
following that is also modeled by `Iterator`.
|
||||||
|
|
||||||
|
|
||||||
* Writable Lvalue Iterator if `transform_iterator::reference` is a non-const reference.
|
* Writable Lvalue Iterator if `transform_iterator::reference` is a non-const reference.
|
||||||
|
|
||||||
* Readable Lvalue Iterator if `transform_iterator::reference` is a const reference.
|
* Readable Lvalue Iterator if `transform_iterator::reference` is a const reference.
|
||||||
|
|
||||||
* Readable Iterator otherwise.
|
* Readable Iterator otherwise.
|
||||||
|
|
||||||
|
|
||||||
The `transform_iterator` models the most refined standard traversal
|
The `transform_iterator` models the most refined standard traversal
|
||||||
@@ -143,11 +143,11 @@ the `Iterator` argument models.
|
|||||||
|
|
||||||
|
|
||||||
[table Category
|
[table Category
|
||||||
[[If `Iterator` models][then `transform_iterator` models]]
|
[[If `Iterator` models][then `transform_iterator` models]]
|
||||||
[[Single Pass Iterator][Input Iterator]]
|
[[Single Pass Iterator][Input Iterator]]
|
||||||
[[Forward Traversal Iterator][Forward Iterator]]
|
[[Forward Traversal Iterator][Forward Iterator]]
|
||||||
[[Bidirectional Traversal Iterator][Bidirectional Iterator]]
|
[[Bidirectional Traversal Iterator][Bidirectional Iterator]]
|
||||||
[[Random Access Traversal Iterator][Random Access Iterator]]
|
[[Random Access Traversal Iterator][Random Access Iterator]]
|
||||||
]
|
]
|
||||||
|
|
||||||
If `transform_iterator` models Writable Lvalue Iterator then it is a
|
If `transform_iterator` models Writable Lvalue Iterator then it is a
|
||||||
@@ -177,7 +177,7 @@ operations:
|
|||||||
template<class F2, class I2, class R2, class V2>
|
template<class F2, class I2, class R2, class V2>
|
||||||
transform_iterator(
|
transform_iterator(
|
||||||
transform_iterator<F2, I2, R2, V2> const& t
|
transform_iterator<F2, I2, R2, V2> const& t
|
||||||
, typename enable_if_convertible<I2, Iterator>::type* = 0 // exposition only
|
, typename enable_if_convertible<I2, Iterator>::type* = 0 // exposition only
|
||||||
, typename enable_if_convertible<F2, UnaryFunction>::type* = 0 // exposition only
|
, typename enable_if_convertible<F2, UnaryFunction>::type* = 0 // exposition only
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
|
|
||||||
[section:zip Zip Iterator]
|
[section:zip Zip Iterator]
|
||||||
|
|
||||||
The zip iterator provides the ability to parallel-iterate
|
The zip iterator provides the ability to parallel-iterate
|
||||||
over several controlled sequences simultaneously. A zip
|
over several controlled sequences simultaneously. A zip
|
||||||
iterator is constructed from a tuple of iterators. Moving
|
iterator is constructed from a tuple of iterators. Moving
|
||||||
the zip iterator moves all the iterators in parallel.
|
the zip iterator moves all the iterators in parallel.
|
||||||
Dereferencing the zip iterator returns a tuple that contains
|
Dereferencing the zip iterator returns a tuple that contains
|
||||||
the results of dereferencing the individual iterators.
|
the results of dereferencing the individual iterators.
|
||||||
|
|
||||||
The tuple of iterators is now implemented in terms of a Boost fusion sequence.
|
The tuple of iterators is now implemented in terms of a Boost fusion sequence.
|
||||||
Because of this the 'tuple' may be any Boost fusion sequence and, for backwards
|
Because of this the 'tuple' may be any Boost fusion sequence and, for backwards
|
||||||
compatibility through a Boost fusion sequence adapter, a Boost tuple. Because the
|
compatibility through a Boost fusion sequence adapter, a Boost tuple. Because the
|
||||||
'tuple' may be any boost::fusion sequence the 'tuple' may also be any type for which a
|
'tuple' may be any boost::fusion sequence the 'tuple' may also be any type for which a
|
||||||
Boost fusion adapter exists. This includes, among others, a std::tuple and a std::pair.
|
Boost fusion adapter exists. This includes, among others, a std::tuple and a std::pair.
|
||||||
Just remember to include the appropriate Boost fusion adapter header files for these
|
Just remember to include the appropriate Boost fusion adapter header files for these
|
||||||
other Boost fusion adapters. The zip_iterator header file already includes the
|
other Boost fusion adapters. The zip_iterator header file already includes the
|
||||||
@@ -22,9 +21,9 @@ to use a Boost tuple as your 'tuple'.
|
|||||||
|
|
||||||
There are two main types of applications of the `zip_iterator`. The first
|
There are two main types of applications of the `zip_iterator`. The first
|
||||||
one concerns runtime efficiency: If one has several controlled sequences
|
one concerns runtime efficiency: If one has several controlled sequences
|
||||||
of the same length that must be somehow processed, e.g., with the
|
of the same length that must be somehow processed, e.g., with the
|
||||||
`for_each` algorithm, then it is more efficient to perform just
|
`for_each` algorithm, then it is more efficient to perform just
|
||||||
one parallel-iteration rather than several individual iterations. For an
|
one parallel-iteration rather than several individual iterations. For an
|
||||||
example, assume that `vect_of_doubles` and `vect_of_ints`
|
example, assume that `vect_of_doubles` and `vect_of_ints`
|
||||||
are two vectors of equal length containing doubles and ints, respectively,
|
are two vectors of equal length containing doubles and ints, respectively,
|
||||||
and consider the following two iterations:
|
and consider the following two iterations:
|
||||||
@@ -53,7 +52,7 @@ These two iterations can now be replaced with a single one as follows:
|
|||||||
A non-generic implementation of `zip_func` could look as follows:
|
A non-generic implementation of `zip_func` could look as follows:
|
||||||
|
|
||||||
|
|
||||||
struct zip_func :
|
struct zip_func :
|
||||||
public std::unary_function<const boost::tuple<const double&, const int&>&, void>
|
public std::unary_function<const boost::tuple<const double&, const int&>&, void>
|
||||||
{
|
{
|
||||||
void operator()(const boost::tuple<const double&, const int&>& t) const
|
void operator()(const boost::tuple<const double&, const int&>& t) const
|
||||||
@@ -72,16 +71,16 @@ to make combining iterators. A combining iterator is an iterator
|
|||||||
that parallel-iterates over several controlled sequences and, upon
|
that parallel-iterates over several controlled sequences and, upon
|
||||||
dereferencing, returns the result of applying a functor to the values of the
|
dereferencing, returns the result of applying a functor to the values of the
|
||||||
sequences at the respective positions. This can now be achieved by using the
|
sequences at the respective positions. This can now be achieved by using the
|
||||||
`zip_iterator` in conjunction with the `transform_iterator`.
|
`zip_iterator` in conjunction with the `transform_iterator`.
|
||||||
|
|
||||||
Suppose, for example, that you have two vectors of doubles, say
|
Suppose, for example, that you have two vectors of doubles, say
|
||||||
`vect_1` and `vect_2`, and you need to expose to a client
|
`vect_1` and `vect_2`, and you need to expose to a client
|
||||||
a controlled sequence containing the products of the elements of
|
a controlled sequence containing the products of the elements of
|
||||||
`vect_1` and `vect_2`. Rather than placing these products
|
`vect_1` and `vect_2`. Rather than placing these products
|
||||||
in a third vector, you can use a combining iterator that calculates the
|
in a third vector, you can use a combining iterator that calculates the
|
||||||
products on the fly. Let us assume that `tuple_multiplies` is a
|
products on the fly. Let us assume that `tuple_multiplies` is a
|
||||||
functor that works like `std::multiplies`, except that it takes
|
functor that works like `std::multiplies`, except that it takes
|
||||||
its two arguments packaged in a tuple. Then the two iterators
|
its two arguments packaged in a tuple. Then the two iterators
|
||||||
`it_begin` and `it_end` defined below delimit a controlled
|
`it_begin` and `it_end` defined below delimit a controlled
|
||||||
sequence containing the products of the elements of `vect_1` and
|
sequence containing the products of the elements of `vect_1` and
|
||||||
`vect_2`:
|
`vect_2`:
|
||||||
@@ -128,7 +127,7 @@ sequence containing the products of the elements of `vect_1` and
|
|||||||
|
|
||||||
template<typename IteratorTuple>
|
template<typename IteratorTuple>
|
||||||
class zip_iterator
|
class zip_iterator
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef /* see below */ reference;
|
typedef /* see below */ reference;
|
||||||
@@ -154,8 +153,8 @@ sequence containing the products of the elements of `vect_1` and
|
|||||||
IteratorTuple m_iterator_tuple; // exposition only
|
IteratorTuple m_iterator_tuple; // exposition only
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename IteratorTuple>
|
template<typename IteratorTuple>
|
||||||
zip_iterator<IteratorTuple>
|
zip_iterator<IteratorTuple>
|
||||||
make_zip_iterator(IteratorTuple t);
|
make_zip_iterator(IteratorTuple t);
|
||||||
|
|
||||||
The `reference` member of `zip_iterator` is the type of the tuple
|
The `reference` member of `zip_iterator` is the type of the tuple
|
||||||
@@ -168,23 +167,23 @@ of the first of the iterator types in the `IteratorTuple` argument.
|
|||||||
The `iterator_category` member of `zip_iterator` is convertible to the
|
The `iterator_category` member of `zip_iterator` is convertible to the
|
||||||
minimum of the traversal categories of the iterator types in the `IteratorTuple`
|
minimum of the traversal categories of the iterator types in the `IteratorTuple`
|
||||||
argument. For example, if the `zip_iterator` holds only vector
|
argument. For example, if the `zip_iterator` holds only vector
|
||||||
iterators, then `iterator_category` is convertible to
|
iterators, then `iterator_category` is convertible to
|
||||||
`boost::random_access_traversal_tag`. If you add a list iterator, then
|
`boost::random_access_traversal_tag`. If you add a list iterator, then
|
||||||
`iterator_category` will be convertible to `boost::bidirectional_traversal_tag`,
|
`iterator_category` will be convertible to `boost::bidirectional_traversal_tag`,
|
||||||
but no longer to `boost::random_access_traversal_tag`.
|
but no longer to `boost::random_access_traversal_tag`.
|
||||||
|
|
||||||
[h2 Requirements]
|
[h2 Requirements]
|
||||||
|
|
||||||
All iterator types in the argument `IteratorTuple` shall model Readable Iterator.
|
All iterator types in the argument `IteratorTuple` shall model Readable Iterator.
|
||||||
|
|
||||||
[h2 Concepts]
|
[h2 Concepts]
|
||||||
|
|
||||||
The resulting `zip_iterator` models Readable Iterator.
|
The resulting `zip_iterator` models Readable Iterator.
|
||||||
|
|
||||||
The fact that the `zip_iterator` models only Readable Iterator does not
|
The fact that the `zip_iterator` models only Readable Iterator does not
|
||||||
prevent you from modifying the values that the individual iterators point
|
prevent you from modifying the values that the individual iterators point
|
||||||
to. The tuple returned by the `zip_iterator`'s `operator*` is a tuple
|
to. The tuple returned by the `zip_iterator`'s `operator*` is a tuple
|
||||||
constructed from the reference types of the individual iterators, not
|
constructed from the reference types of the individual iterators, not
|
||||||
their value types. For example, if `zip_it` is a `zip_iterator` whose
|
their value types. For example, if `zip_it` is a `zip_iterator` whose
|
||||||
first member iterator is an `std::vector<double>::iterator`, then the
|
first member iterator is an `std::vector<double>::iterator`, then the
|
||||||
following line will modify the value which the first member iterator of
|
following line will modify the value which the first member iterator of
|
||||||
@@ -195,7 +194,7 @@ following line will modify the value which the first member iterator of
|
|||||||
|
|
||||||
Consider the set of standard traversal concepts obtained by taking
|
Consider the set of standard traversal concepts obtained by taking
|
||||||
the most refined standard traversal concept modeled by each individual
|
the most refined standard traversal concept modeled by each individual
|
||||||
iterator type in the `IteratorTuple` argument.The `zip_iterator`
|
iterator type in the `IteratorTuple` argument.The `zip_iterator`
|
||||||
models the least refined standard traversal concept in this set.
|
models the least refined standard traversal concept in this set.
|
||||||
|
|
||||||
`zip_iterator<IteratorTuple1>` is interoperable with
|
`zip_iterator<IteratorTuple1>` is interoperable with
|
||||||
@@ -254,8 +253,8 @@ operations.
|
|||||||
[*Effects:] Decrements each iterator in `m_iterator_tuple`.[br]
|
[*Effects:] Decrements each iterator in `m_iterator_tuple`.[br]
|
||||||
[*Returns:] `*this`
|
[*Returns:] `*this`
|
||||||
|
|
||||||
template<typename IteratorTuple>
|
template<typename IteratorTuple>
|
||||||
zip_iterator<IteratorTuple>
|
zip_iterator<IteratorTuple>
|
||||||
make_zip_iterator(IteratorTuple t);
|
make_zip_iterator(IteratorTuple t);
|
||||||
|
|
||||||
[*Returns:] An instance of `zip_iterator<IteratorTuple>` with `m_iterator_tuple`
|
[*Returns:] An instance of `zip_iterator<IteratorTuple>` with `m_iterator_tuple`
|
||||||
@@ -263,4 +262,4 @@ operations.
|
|||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|||||||
@@ -41,12 +41,12 @@ int main(int, char*[])
|
|||||||
|
|
||||||
// Use indirect iterator to print out numbers by accessing
|
// Use indirect iterator to print out numbers by accessing
|
||||||
// them through the array of pointers.
|
// them through the array of pointers.
|
||||||
std::cout << "indirectly printing out the numbers from 0 to "
|
std::cout << "indirectly printing out the numbers from 0 to "
|
||||||
<< N << std::endl;
|
<< N << std::endl;
|
||||||
std::copy(boost::make_indirect_iterator(pointers.begin()),
|
std::copy(boost::make_indirect_iterator(pointers.begin()),
|
||||||
boost::make_indirect_iterator(pointers.end()),
|
boost::make_indirect_iterator(pointers.end()),
|
||||||
std::ostream_iterator<int>(std::cout, " "));
|
std::ostream_iterator<int>(std::cout, " "));
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
return boost::exit_success;
|
return boost::exit_success;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/iterator/filter_iterator.hpp>
|
#include <boost/iterator/filter_iterator.hpp>
|
||||||
|
#include <boost/bind/bind.hpp>
|
||||||
#include <boost/cstdlib.hpp> // for exit_success
|
#include <boost/cstdlib.hpp> // for exit_success
|
||||||
|
|
||||||
struct is_positive_number {
|
struct is_positive_number {
|
||||||
@@ -18,10 +19,10 @@ int main()
|
|||||||
{
|
{
|
||||||
int numbers_[] = { 0, -1, 4, -3, 5, 8, -2 };
|
int numbers_[] = { 0, -1, 4, -3, 5, 8, -2 };
|
||||||
const int N = sizeof(numbers_)/sizeof(int);
|
const int N = sizeof(numbers_)/sizeof(int);
|
||||||
|
|
||||||
typedef int* base_iterator;
|
typedef int* base_iterator;
|
||||||
base_iterator numbers(numbers_);
|
base_iterator numbers(numbers_);
|
||||||
|
|
||||||
// Example using make_filter_iterator()
|
// Example using make_filter_iterator()
|
||||||
std::copy(boost::make_filter_iterator<is_positive_number>(numbers, numbers + N),
|
std::copy(boost::make_filter_iterator<is_positive_number>(numbers, numbers + N),
|
||||||
boost::make_filter_iterator<is_positive_number>(numbers + N, numbers + N),
|
boost::make_filter_iterator<is_positive_number>(numbers + N, numbers + N),
|
||||||
@@ -31,7 +32,7 @@ int main()
|
|||||||
// Example using filter_iterator
|
// Example using filter_iterator
|
||||||
typedef boost::filter_iterator<is_positive_number, base_iterator>
|
typedef boost::filter_iterator<is_positive_number, base_iterator>
|
||||||
FilterIter;
|
FilterIter;
|
||||||
|
|
||||||
is_positive_number predicate;
|
is_positive_number predicate;
|
||||||
FilterIter filter_iter_first(predicate, numbers, numbers + N);
|
FilterIter filter_iter_first(predicate, numbers, numbers + N);
|
||||||
FilterIter filter_iter_last(predicate, numbers + N, numbers + N);
|
FilterIter filter_iter_last(predicate, numbers + N, numbers + N);
|
||||||
@@ -42,17 +43,17 @@ int main()
|
|||||||
// Another example using make_filter_iterator()
|
// Another example using make_filter_iterator()
|
||||||
std::copy(
|
std::copy(
|
||||||
boost::make_filter_iterator(
|
boost::make_filter_iterator(
|
||||||
std::bind2nd(std::greater<int>(), -2)
|
boost::bind(std::greater<int>(), boost::placeholders::_1, -2)
|
||||||
, numbers, numbers + N)
|
, numbers, numbers + N)
|
||||||
|
|
||||||
, boost::make_filter_iterator(
|
, boost::make_filter_iterator(
|
||||||
std::bind2nd(std::greater<int>(), -2)
|
boost::bind(std::greater<int>(), boost::placeholders::_1, -2)
|
||||||
, numbers + N, numbers + N)
|
, numbers + N, numbers + N)
|
||||||
|
|
||||||
, std::ostream_iterator<int>(std::cout, " ")
|
, std::ostream_iterator<int>(std::cout, " ")
|
||||||
);
|
);
|
||||||
|
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
return boost::exit_success;
|
return boost::exit_success;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,14 +12,14 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <boost/function_output_iterator.hpp>
|
#include <boost/iterator/function_output_iterator.hpp>
|
||||||
|
|
||||||
struct string_appender
|
struct string_appender
|
||||||
{
|
{
|
||||||
string_appender(std::string& s)
|
string_appender(std::string& s)
|
||||||
: m_str(&s)
|
: m_str(&s)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void operator()(const std::string& x) const
|
void operator()(const std::string& x) const
|
||||||
{
|
{
|
||||||
*m_str += x;
|
*m_str += x;
|
||||||
@@ -37,9 +37,9 @@ int main(int, char*[])
|
|||||||
x.push_back("!");
|
x.push_back("!");
|
||||||
|
|
||||||
std::string s = "";
|
std::string s = "";
|
||||||
std::copy(x.begin(), x.end(),
|
std::copy(x.begin(), x.end(),
|
||||||
boost::make_function_output_iterator(string_appender(s)));
|
boost::make_function_output_iterator(string_appender(s)));
|
||||||
|
|
||||||
std::cout << s << std::endl;
|
std::cout << s << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <boost/bind/bind.hpp>
|
||||||
#include <boost/iterator/indirect_iterator.hpp>
|
#include <boost/iterator/indirect_iterator.hpp>
|
||||||
|
|
||||||
int main(int, char*[])
|
int main(int, char*[])
|
||||||
@@ -20,13 +21,13 @@ int main(int, char*[])
|
|||||||
pointers_to_chars[i] = &characters[i];
|
pointers_to_chars[i] = &characters[i];
|
||||||
|
|
||||||
// Example of using indirect_iterator
|
// Example of using indirect_iterator
|
||||||
|
|
||||||
boost::indirect_iterator<char**, char>
|
boost::indirect_iterator<char**, char>
|
||||||
indirect_first(pointers_to_chars), indirect_last(pointers_to_chars + N);
|
indirect_first(pointers_to_chars), indirect_last(pointers_to_chars + N);
|
||||||
|
|
||||||
std::copy(indirect_first, indirect_last, std::ostream_iterator<char>(std::cout, ","));
|
std::copy(indirect_first, indirect_last, std::ostream_iterator<char>(std::cout, ","));
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
|
||||||
// Example of making mutable and constant indirect iterators
|
// Example of making mutable and constant indirect iterators
|
||||||
|
|
||||||
@@ -41,19 +42,19 @@ int main(int, char*[])
|
|||||||
const_indirect_last(pointers_to_chars + N);
|
const_indirect_last(pointers_to_chars + N);
|
||||||
|
|
||||||
std::transform(const_indirect_first, const_indirect_last,
|
std::transform(const_indirect_first, const_indirect_last,
|
||||||
mutable_indirect_first, std::bind1st(std::plus<char>(), 1));
|
mutable_indirect_first, boost::bind(std::plus<char>(), 1, boost::placeholders::_1));
|
||||||
|
|
||||||
std::copy(mutable_indirect_first, mutable_indirect_last,
|
std::copy(mutable_indirect_first, mutable_indirect_last,
|
||||||
std::ostream_iterator<char>(std::cout, ","));
|
std::ostream_iterator<char>(std::cout, ","));
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
|
||||||
// Example of using make_indirect_iterator()
|
// Example of using make_indirect_iterator()
|
||||||
|
|
||||||
std::copy(boost::make_indirect_iterator(pointers_to_chars),
|
std::copy(boost::make_indirect_iterator(pointers_to_chars),
|
||||||
boost::make_indirect_iterator(pointers_to_chars + N),
|
boost::make_indirect_iterator(pointers_to_chars + N),
|
||||||
std::ostream_iterator<char>(std::cout, ","));
|
std::ostream_iterator<char>(std::cout, ","));
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -24,7 +24,7 @@ struct node_base
|
|||||||
|
|
||||||
virtual void print(std::ostream& s) const = 0;
|
virtual void print(std::ostream& s) const = 0;
|
||||||
virtual void double_me() = 0;
|
virtual void double_me() = 0;
|
||||||
|
|
||||||
void append(node_base* p)
|
void append(node_base* p)
|
||||||
{
|
{
|
||||||
if (m_next)
|
if (m_next)
|
||||||
@@ -32,7 +32,7 @@ struct node_base
|
|||||||
else
|
else
|
||||||
m_next = p;
|
m_next = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
node_base* m_next;
|
node_base* m_next;
|
||||||
};
|
};
|
||||||
@@ -52,9 +52,9 @@ struct node : node_base
|
|||||||
|
|
||||||
void print(std::ostream& s) const { s << this->m_value; }
|
void print(std::ostream& s) const { s << this->m_value; }
|
||||||
void double_me() { m_value += m_value; }
|
void double_me() { m_value += m_value; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T m_value;
|
T m_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NODE_DWA2004110_HPP
|
#endif // NODE_DWA2004110_HPP
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ int main()
|
|||||||
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||||
|
|
||||||
std::auto_ptr<node<int> > nodes(new node<int>(42));
|
std::auto_ptr<node<int> > nodes(new node<int>(42));
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
std::unique_ptr<node<int> > nodes(new node<int>(42));
|
std::unique_ptr<node<int> > nodes(new node<int>(42));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nodes->append(new node<std::string>(" is greater than "));
|
nodes->append(new node<std::string>(" is greater than "));
|
||||||
@@ -30,7 +30,7 @@ int main()
|
|||||||
, std::ostream_iterator<node_base>(std::cout, " ")
|
, std::ostream_iterator<node_base>(std::cout, " ")
|
||||||
);
|
);
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
std::for_each(
|
std::for_each(
|
||||||
node_iterator(nodes.get()), node_iterator()
|
node_iterator(nodes.get()), node_iterator()
|
||||||
, std::mem_fun_ref(&node_base::double_me)
|
, std::mem_fun_ref(&node_base::double_me)
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ class node_iterator
|
|||||||
|
|
||||||
void increment()
|
void increment()
|
||||||
{ m_node = m_node->next(); }
|
{ m_node = m_node->next(); }
|
||||||
|
|
||||||
bool equal(node_iterator const& other) const
|
bool equal(node_iterator const& other) const
|
||||||
{ return this->m_node == other.m_node; }
|
{ return this->m_node == other.m_node; }
|
||||||
|
|
||||||
node_base& dereference() const
|
node_base& dereference() const
|
||||||
{ return *m_node; }
|
{ return *m_node; }
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ int main()
|
|||||||
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||||
|
|
||||||
std::auto_ptr<node<int> > nodes(new node<int>(42));
|
std::auto_ptr<node<int> > nodes(new node<int>(42));
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
std::unique_ptr<node<int> > nodes(new node<int>(42));
|
std::unique_ptr<node<int> > nodes(new node<int>(42));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nodes->append(new node<std::string>(" is greater than "));
|
nodes->append(new node<std::string>(" is greater than "));
|
||||||
@@ -29,16 +29,16 @@ int main()
|
|||||||
// Check interoperability
|
// Check interoperability
|
||||||
assert(node_iterator(nodes.get()) == node_const_iterator(nodes.get()));
|
assert(node_iterator(nodes.get()) == node_const_iterator(nodes.get()));
|
||||||
assert(node_const_iterator(nodes.get()) == node_iterator(nodes.get()));
|
assert(node_const_iterator(nodes.get()) == node_iterator(nodes.get()));
|
||||||
|
|
||||||
assert(node_iterator(nodes.get()) != node_const_iterator());
|
assert(node_iterator(nodes.get()) != node_const_iterator());
|
||||||
assert(node_const_iterator(nodes.get()) != node_iterator());
|
assert(node_const_iterator(nodes.get()) != node_iterator());
|
||||||
|
|
||||||
std::copy(
|
std::copy(
|
||||||
node_iterator(nodes.get()), node_iterator()
|
node_iterator(nodes.get()), node_iterator()
|
||||||
, std::ostream_iterator<node_base>(std::cout, " ")
|
, std::ostream_iterator<node_base>(std::cout, " ")
|
||||||
);
|
);
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
std::for_each(
|
std::for_each(
|
||||||
node_iterator(nodes.get()), node_iterator()
|
node_iterator(nodes.get()), node_iterator()
|
||||||
, boost::mem_fn(&node_base::double_me)
|
, boost::mem_fn(&node_base::double_me)
|
||||||
|
|||||||
@@ -38,15 +38,15 @@ class node_iter
|
|||||||
boost::is_convertible<OtherValue*,Value*>
|
boost::is_convertible<OtherValue*,Value*>
|
||||||
, enabler
|
, enabler
|
||||||
>::type = enabler()
|
>::type = enabler()
|
||||||
# endif
|
# endif
|
||||||
)
|
)
|
||||||
: m_node(other.m_node) {}
|
: m_node(other.m_node) {}
|
||||||
|
|
||||||
|
|
||||||
# if !BOOST_WORKAROUND(__GNUC__, == 2)
|
# if !BOOST_WORKAROUND(__GNUC__, == 2)
|
||||||
private: // GCC2 can't grant friendship to template member functions
|
private: // GCC2 can't grant friendship to template member functions
|
||||||
friend class boost::iterator_core_access;
|
friend class boost::iterator_core_access;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
template <class OtherValue>
|
template <class OtherValue>
|
||||||
bool equal(node_iter<OtherValue> const& other) const
|
bool equal(node_iter<OtherValue> const& other) const
|
||||||
@@ -63,7 +63,7 @@ class node_iter
|
|||||||
# else
|
# else
|
||||||
private:
|
private:
|
||||||
template <class> friend class node_iter;
|
template <class> friend class node_iter;
|
||||||
# endif
|
# endif
|
||||||
Value* m_node;
|
Value* m_node;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ int main()
|
|||||||
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||||
|
|
||||||
std::auto_ptr<node<int> > nodes(new node<int>(42));
|
std::auto_ptr<node<int> > nodes(new node<int>(42));
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
std::unique_ptr<node<int> > nodes(new node<int>(42));
|
std::unique_ptr<node<int> > nodes(new node<int>(42));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nodes->append(new node<std::string>(" is greater than "));
|
nodes->append(new node<std::string>(" is greater than "));
|
||||||
@@ -29,16 +29,16 @@ int main()
|
|||||||
// Check interoperability
|
// Check interoperability
|
||||||
assert(node_iterator(nodes.get()) == node_const_iterator(nodes.get()));
|
assert(node_iterator(nodes.get()) == node_const_iterator(nodes.get()));
|
||||||
assert(node_const_iterator(nodes.get()) == node_iterator(nodes.get()));
|
assert(node_const_iterator(nodes.get()) == node_iterator(nodes.get()));
|
||||||
|
|
||||||
assert(node_iterator(nodes.get()) != node_const_iterator());
|
assert(node_iterator(nodes.get()) != node_const_iterator());
|
||||||
assert(node_const_iterator(nodes.get()) != node_iterator());
|
assert(node_const_iterator(nodes.get()) != node_iterator());
|
||||||
|
|
||||||
std::copy(
|
std::copy(
|
||||||
node_iterator(nodes.get()), node_iterator()
|
node_iterator(nodes.get()), node_iterator()
|
||||||
, std::ostream_iterator<node_base>(std::cout, " ")
|
, std::ostream_iterator<node_base>(std::cout, " ")
|
||||||
);
|
);
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
std::for_each(
|
std::for_each(
|
||||||
node_iterator(nodes.get()), node_iterator()
|
node_iterator(nodes.get()), node_iterator()
|
||||||
, boost::mem_fn(&node_base::double_me)
|
, boost::mem_fn(&node_base::double_me)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class node_iter
|
|||||||
typedef boost::iterator_adaptor<
|
typedef boost::iterator_adaptor<
|
||||||
node_iter<Value>, Value*, boost::use_default, boost::forward_traversal_tag
|
node_iter<Value>, Value*, boost::use_default, boost::forward_traversal_tag
|
||||||
> super_t;
|
> super_t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
node_iter()
|
node_iter()
|
||||||
: super_t(0) {}
|
: super_t(0) {}
|
||||||
@@ -43,14 +43,14 @@ class node_iter
|
|||||||
boost::is_convertible<OtherValue*,Value*>
|
boost::is_convertible<OtherValue*,Value*>
|
||||||
, enabler
|
, enabler
|
||||||
>::type = enabler()
|
>::type = enabler()
|
||||||
# endif
|
# endif
|
||||||
)
|
)
|
||||||
: super_t(other.base()) {}
|
: super_t(other.base()) {}
|
||||||
|
|
||||||
# if !BOOST_WORKAROUND(__GNUC__, == 2)
|
# if !BOOST_WORKAROUND(__GNUC__, == 2)
|
||||||
private: // GCC2 can't grant friendship to template member functions
|
private: // GCC2 can't grant friendship to template member functions
|
||||||
friend class boost::iterator_core_access;
|
friend class boost::iterator_core_access;
|
||||||
# endif
|
# endif
|
||||||
void increment() { this->base_reference() = this->base()->next(); }
|
void increment() { this->base_reference() = this->base()->next(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ int main() {
|
|||||||
*el_it = std::distance(elements.begin(), el_it);
|
*el_it = std::distance(elements.begin(), el_it);
|
||||||
|
|
||||||
index_type indices( index_size );
|
index_type indices( index_size );
|
||||||
for(index_type::iterator i_it = indices.begin() ; i_it != indices.end() ; ++i_it )
|
for(index_type::iterator i_it = indices.begin() ; i_it != indices.end() ; ++i_it )
|
||||||
*i_it = element_range_size - index_size + std::distance(indices.begin(), i_it);
|
*i_it = element_range_size - index_size + std::distance(indices.begin(), i_it);
|
||||||
std::reverse( indices.begin(), indices.end() );
|
std::reverse( indices.begin(), indices.end() );
|
||||||
|
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ int main(int, char*[])
|
|||||||
const int N = sizeof(letters_)/sizeof(char) - 1;
|
const int N = sizeof(letters_)/sizeof(char) - 1;
|
||||||
typedef char* base_iterator;
|
typedef char* base_iterator;
|
||||||
base_iterator letters(letters_);
|
base_iterator letters(letters_);
|
||||||
|
|
||||||
std::cout << "original sequence of letters:\t\t\t"
|
std::cout << "original sequence of letters:\t\t\t"
|
||||||
<< letters_ << std::endl;
|
<< letters_ << std::endl;
|
||||||
|
|
||||||
// Use reverse_iterator to print a sequence of letters in reverse
|
// Use reverse_iterator to print a sequence of letters in reverse
|
||||||
// order.
|
// order.
|
||||||
|
|
||||||
boost::reverse_iterator<base_iterator>
|
boost::reverse_iterator<base_iterator>
|
||||||
reverse_letters_first(letters + N),
|
reverse_letters_first(letters + N),
|
||||||
reverse_letters_last(letters);
|
reverse_letters_last(letters);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Copyright 2003 The Trustees of Indiana University.
|
// Copyright 2003 The Trustees of Indiana University.
|
||||||
|
|
||||||
// Use, modification and distribution is subject to the Boost Software
|
// Use, modification and distribution is subject to the Boost Software
|
||||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
@@ -16,14 +16,14 @@ typedef boost::shared_container_iterator< std::vector<int> > iterator;
|
|||||||
void set_range(iterator& i, iterator& end) {
|
void set_range(iterator& i, iterator& end) {
|
||||||
|
|
||||||
boost::shared_ptr< std::vector<int> > ints(new std::vector<int>());
|
boost::shared_ptr< std::vector<int> > ints(new std::vector<int>());
|
||||||
|
|
||||||
ints->push_back(0);
|
ints->push_back(0);
|
||||||
ints->push_back(1);
|
ints->push_back(1);
|
||||||
ints->push_back(2);
|
ints->push_back(2);
|
||||||
ints->push_back(3);
|
ints->push_back(3);
|
||||||
ints->push_back(4);
|
ints->push_back(4);
|
||||||
ints->push_back(5);
|
ints->push_back(5);
|
||||||
|
|
||||||
i = iterator(ints->begin(),ints);
|
i = iterator(ints->begin(),ints);
|
||||||
end = iterator(ints->end(),ints);
|
end = iterator(ints->end(),ints);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Copyright 2003 The Trustees of Indiana University.
|
// Copyright 2003 The Trustees of Indiana University.
|
||||||
|
|
||||||
// Use, modification and distribution is subject to the Boost Software
|
// Use, modification and distribution is subject to the Boost Software
|
||||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ int main() {
|
|||||||
print_range_nl(boost::make_shared_container_iterator(ints->begin(),ints),
|
print_range_nl(boost::make_shared_container_iterator(ints->begin(),ints),
|
||||||
boost::make_shared_container_iterator(ints->end(),ints));
|
boost::make_shared_container_iterator(ints->end(),ints));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Copyright 2003 The Trustees of Indiana University.
|
// Copyright 2003 The Trustees of Indiana University.
|
||||||
|
|
||||||
// Use, modification and distribution is subject to the Boost Software
|
// Use, modification and distribution is subject to the Boost Software
|
||||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
#include "boost/shared_ptr.hpp"
|
#include "boost/shared_ptr.hpp"
|
||||||
#include "boost/tuple/tuple.hpp" // for boost::tie
|
#include "boost/tuple/tuple.hpp" // for boost::tie
|
||||||
#include <algorithm> // for std::copy
|
#include <algorithm> // for std::copy
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ int main() {
|
|||||||
|
|
||||||
|
|
||||||
iterator i,end;
|
iterator i,end;
|
||||||
|
|
||||||
boost::tie(i,end) = return_range();
|
boost::tie(i,end) = return_range();
|
||||||
|
|
||||||
std::copy(i,end,std::ostream_iterator<int>(std::cout,","));
|
std::copy(i,end,std::ostream_iterator<int>(std::cout,","));
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// (C) Copyright Jeremy Siek 2000-2004.
|
// (C) Copyright Jeremy Siek 2000-2004.
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
template <class Operation>
|
template <class Operation>
|
||||||
class binder1st {
|
class binder1st {
|
||||||
public:
|
public:
|
||||||
typedef typename Operation::result_type result_type;
|
typedef typename Operation::result_type result_type;
|
||||||
@@ -70,6 +70,6 @@ main(int, char*[])
|
|||||||
boost::make_transform_iterator(x + N, boost::bind1st(std::plus<int>(), 4)),
|
boost::make_transform_iterator(x + N, boost::bind1st(std::plus<int>(), 4)),
|
||||||
std::ostream_iterator<int>(std::cout, " "));
|
std::ostream_iterator<int>(std::cout, " "));
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
// This is a deprecated header left for backward compatibility.
|
// This is a deprecated header left for backward compatibility.
|
||||||
// Use boost/iterator/function_output_iterator.hpp instead.
|
// Use boost/iterator/function_output_iterator.hpp instead.
|
||||||
|
|
||||||
|
#include <boost/config/header_deprecated.hpp>
|
||||||
|
|
||||||
|
BOOST_HEADER_DEPRECATED("<boost/iterator/function_output_iterator.hpp>")
|
||||||
|
|
||||||
#include <boost/iterator/function_output_iterator.hpp>
|
#include <boost/iterator/function_output_iterator.hpp>
|
||||||
|
|
||||||
#endif // BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
|
#endif // BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#define BOOST_ITERATOR_ADVANCE_HPP
|
#define BOOST_ITERATOR_ADVANCE_HPP
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/detail/workaround.hpp>
|
||||||
#include <boost/iterator/iterator_categories.hpp>
|
#include <boost/iterator/iterator_categories.hpp>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
@@ -28,6 +29,12 @@ namespace iterators {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BOOST_WORKAROUND(BOOST_GCC_VERSION, >= 40600)
|
||||||
|
// type-limits warning issued below when n is an unsigned integral
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wtype-limits"
|
||||||
|
#endif
|
||||||
|
|
||||||
template <typename BidirectionalIterator, typename Distance>
|
template <typename BidirectionalIterator, typename Distance>
|
||||||
inline BOOST_CXX14_CONSTEXPR void
|
inline BOOST_CXX14_CONSTEXPR void
|
||||||
advance_impl(
|
advance_impl(
|
||||||
@@ -50,6 +57,10 @@ namespace iterators {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BOOST_WORKAROUND(BOOST_GCC_VERSION, >= 40600)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
template <typename RandomAccessIterator, typename Distance>
|
template <typename RandomAccessIterator, typename Distance>
|
||||||
inline BOOST_CXX14_CONSTEXPR void
|
inline BOOST_CXX14_CONSTEXPR void
|
||||||
advance_impl(
|
advance_impl(
|
||||||
|
|||||||
@@ -5,12 +5,21 @@
|
|||||||
#ifndef COUNTING_ITERATOR_DWA200348_HPP
|
#ifndef COUNTING_ITERATOR_DWA200348_HPP
|
||||||
# define COUNTING_ITERATOR_DWA200348_HPP
|
# define COUNTING_ITERATOR_DWA200348_HPP
|
||||||
|
|
||||||
# include <boost/iterator/iterator_adaptor.hpp>
|
# include <boost/config.hpp>
|
||||||
|
# include <boost/static_assert.hpp>
|
||||||
|
# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||||
|
# include <limits>
|
||||||
|
# elif !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
|
||||||
|
# include <boost/type_traits/is_convertible.hpp>
|
||||||
|
# else
|
||||||
|
# include <boost/type_traits/is_arithmetic.hpp>
|
||||||
|
# endif
|
||||||
|
# include <boost/type_traits/is_integral.hpp>
|
||||||
|
# include <boost/type_traits/type_identity.hpp>
|
||||||
|
# include <boost/type_traits/conditional.hpp>
|
||||||
|
# include <boost/type_traits/integral_constant.hpp>
|
||||||
# include <boost/detail/numeric_traits.hpp>
|
# include <boost/detail/numeric_traits.hpp>
|
||||||
# include <boost/mpl/bool.hpp>
|
# include <boost/iterator/iterator_adaptor.hpp>
|
||||||
# include <boost/mpl/if.hpp>
|
|
||||||
# include <boost/mpl/identity.hpp>
|
|
||||||
# include <boost/mpl/eval_if.hpp>
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace iterators {
|
namespace iterators {
|
||||||
@@ -38,14 +47,14 @@ namespace detail
|
|||||||
|
|
||||||
# else
|
# else
|
||||||
|
|
||||||
# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
# if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
|
||||||
BOOST_STATIC_CONSTANT(
|
BOOST_STATIC_CONSTANT(
|
||||||
bool, value = (
|
bool, value = (
|
||||||
boost::is_convertible<int,T>::value
|
boost::is_convertible<int,T>::value
|
||||||
&& boost::is_convertible<T,int>::value
|
&& boost::is_convertible<T,int>::value
|
||||||
));
|
));
|
||||||
# else
|
# else
|
||||||
BOOST_STATIC_CONSTANT(bool, value = ::boost::is_arithmetic<T>::value);
|
BOOST_STATIC_CONSTANT(bool, value = ::boost::is_arithmetic<T>::value);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
@@ -53,23 +62,33 @@ namespace detail
|
|||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct is_numeric
|
struct is_numeric
|
||||||
: mpl::bool_<(::boost::iterators::detail::is_numeric_impl<T>::value)>
|
: boost::integral_constant<bool, ::boost::iterators::detail::is_numeric_impl<T>::value>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
# if defined(BOOST_HAS_LONG_LONG)
|
# if defined(BOOST_HAS_LONG_LONG)
|
||||||
template <>
|
template <>
|
||||||
struct is_numeric< ::boost::long_long_type>
|
struct is_numeric<boost::long_long_type>
|
||||||
: mpl::true_ {};
|
: boost::true_type {};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct is_numeric< ::boost::ulong_long_type>
|
struct is_numeric<boost::ulong_long_type>
|
||||||
: mpl::true_ {};
|
: boost::true_type {};
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(BOOST_HAS_INT128)
|
||||||
|
template <>
|
||||||
|
struct is_numeric<boost::int128_type>
|
||||||
|
: boost::true_type {};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct is_numeric<boost::uint128_type>
|
||||||
|
: boost::true_type {};
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// Some compilers fail to have a numeric_limits specialization
|
// Some compilers fail to have a numeric_limits specialization
|
||||||
template <>
|
template <>
|
||||||
struct is_numeric<wchar_t>
|
struct is_numeric<wchar_t>
|
||||||
: mpl::true_ {};
|
: true_type {};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct numeric_difference
|
struct numeric_difference
|
||||||
@@ -77,27 +96,40 @@ namespace detail
|
|||||||
typedef typename boost::detail::numeric_traits<T>::difference_type type;
|
typedef typename boost::detail::numeric_traits<T>::difference_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT(is_numeric<int>::value);
|
# if defined(BOOST_HAS_INT128)
|
||||||
|
// std::numeric_limits, which is used by numeric_traits, is not specialized for __int128 in some standard libraries
|
||||||
|
template <>
|
||||||
|
struct numeric_difference<boost::int128_type>
|
||||||
|
{
|
||||||
|
typedef boost::int128_type type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct numeric_difference<boost::uint128_type>
|
||||||
|
{
|
||||||
|
typedef boost::int128_type type;
|
||||||
|
};
|
||||||
|
# endif
|
||||||
|
|
||||||
template <class Incrementable, class CategoryOrTraversal, class Difference>
|
template <class Incrementable, class CategoryOrTraversal, class Difference>
|
||||||
struct counting_iterator_base
|
struct counting_iterator_base
|
||||||
{
|
{
|
||||||
typedef typename detail::ia_dflt_help<
|
typedef typename detail::ia_dflt_help<
|
||||||
CategoryOrTraversal
|
CategoryOrTraversal
|
||||||
, mpl::eval_if<
|
, typename boost::conditional<
|
||||||
is_numeric<Incrementable>
|
is_numeric<Incrementable>::value
|
||||||
, mpl::identity<random_access_traversal_tag>
|
, boost::type_identity<random_access_traversal_tag>
|
||||||
, iterator_traversal<Incrementable>
|
, iterator_traversal<Incrementable>
|
||||||
>
|
>::type
|
||||||
>::type traversal;
|
>::type traversal;
|
||||||
|
|
||||||
typedef typename detail::ia_dflt_help<
|
typedef typename detail::ia_dflt_help<
|
||||||
Difference
|
Difference
|
||||||
, mpl::eval_if<
|
, typename boost::conditional<
|
||||||
is_numeric<Incrementable>
|
is_numeric<Incrementable>::value
|
||||||
, numeric_difference<Incrementable>
|
, numeric_difference<Incrementable>
|
||||||
, iterator_difference<Incrementable>
|
, iterator_difference<Incrementable>
|
||||||
>
|
>::type
|
||||||
>::type difference;
|
>::type difference;
|
||||||
|
|
||||||
typedef iterator_adaptor<
|
typedef iterator_adaptor<
|
||||||
@@ -161,9 +193,9 @@ class counting_iterator
|
|||||||
public:
|
public:
|
||||||
typedef typename super_t::difference_type difference_type;
|
typedef typename super_t::difference_type difference_type;
|
||||||
|
|
||||||
counting_iterator() { }
|
BOOST_DEFAULTED_FUNCTION(counting_iterator(), {})
|
||||||
|
|
||||||
counting_iterator(counting_iterator const& rhs) : super_t(rhs.base()) {}
|
BOOST_DEFAULTED_FUNCTION(counting_iterator(counting_iterator const& rhs), : super_t(rhs.base()) {})
|
||||||
|
|
||||||
counting_iterator(Incrementable x)
|
counting_iterator(Incrementable x)
|
||||||
: super_t(x)
|
: super_t(x)
|
||||||
@@ -180,6 +212,8 @@ class counting_iterator
|
|||||||
{}
|
{}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
BOOST_DEFAULTED_FUNCTION(counting_iterator& operator=(counting_iterator const& rhs), { *static_cast< super_t* >(this) = static_cast< super_t const& >(rhs); return *this; })
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typename super_t::reference dereference() const
|
typename super_t::reference dereference() const
|
||||||
@@ -191,13 +225,13 @@ class counting_iterator
|
|||||||
difference_type
|
difference_type
|
||||||
distance_to(counting_iterator<OtherIncrementable, CategoryOrTraversal, Difference> const& y) const
|
distance_to(counting_iterator<OtherIncrementable, CategoryOrTraversal, Difference> const& y) const
|
||||||
{
|
{
|
||||||
typedef typename mpl::if_<
|
typedef typename boost::conditional<
|
||||||
detail::is_numeric<Incrementable>
|
detail::is_numeric<Incrementable>::value
|
||||||
, detail::number_distance<difference_type, Incrementable, OtherIncrementable>
|
, detail::number_distance<difference_type, Incrementable, OtherIncrementable>
|
||||||
, detail::iterator_distance<difference_type, Incrementable, OtherIncrementable>
|
, detail::iterator_distance<difference_type, Incrementable, OtherIncrementable>
|
||||||
>::type d;
|
>::type d;
|
||||||
|
|
||||||
return d::distance(this->base(), y.base());
|
return d::distance(this->base(), y.base());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -206,8 +240,8 @@ template <class Incrementable>
|
|||||||
inline counting_iterator<Incrementable>
|
inline counting_iterator<Incrementable>
|
||||||
make_counting_iterator(Incrementable x)
|
make_counting_iterator(Incrementable x)
|
||||||
{
|
{
|
||||||
typedef counting_iterator<Incrementable> result_t;
|
typedef counting_iterator<Incrementable> result_t;
|
||||||
return result_t(x);
|
return result_t(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace iterators
|
} // namespace iterators
|
||||||
|
|||||||
@@ -18,16 +18,16 @@
|
|||||||
|
|
||||||
#ifdef BOOST_ITERATOR_CONFIG_DEF
|
#ifdef BOOST_ITERATOR_CONFIG_DEF
|
||||||
# error you have nested config_def #inclusion.
|
# error you have nested config_def #inclusion.
|
||||||
#else
|
#else
|
||||||
# define BOOST_ITERATOR_CONFIG_DEF
|
# define BOOST_ITERATOR_CONFIG_DEF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// We enable this always now. Otherwise, the simple case in
|
// We enable this always now. Otherwise, the simple case in
|
||||||
// libs/iterator/test/constant_iterator_arrow.cpp fails to compile
|
// libs/iterator/test/constant_iterator_arrow.cpp fails to compile
|
||||||
// because the operator-> return is improperly deduced as a non-const
|
// because the operator-> return is improperly deduced as a non-const
|
||||||
// pointer.
|
// pointer.
|
||||||
#if 1 || defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
#if 1 || defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
||||||
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x531))
|
|| BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x531))
|
||||||
|
|
||||||
// Recall that in general, compilers without partial specialization
|
// Recall that in general, compilers without partial specialization
|
||||||
// can't strip constness. Consider counting_iterator, which normally
|
// can't strip constness. Consider counting_iterator, which normally
|
||||||
@@ -46,11 +46,11 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x5A0)) \
|
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x5A0)) \
|
||||||
|| (BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 700) && defined(_MSC_VER)) \
|
|| (BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 700) && defined(_MSC_VER)) \
|
||||||
|| BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) \
|
|| BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) \
|
||||||
|| BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
|
|| BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
|
||||||
|
|
||||||
# define BOOST_NO_LVALUE_RETURN_DETECTION
|
# define BOOST_NO_LVALUE_RETURN_DETECTION
|
||||||
|
|
||||||
# if 0 // test code
|
# if 0 // test code
|
||||||
@@ -79,7 +79,7 @@
|
|||||||
|
|
||||||
int z2[(lvalue_deref_helper<v*>::value == 1) ? 1 : -1];
|
int z2[(lvalue_deref_helper<v*>::value == 1) ? 1 : -1];
|
||||||
int z[(lvalue_deref_helper<value_iterator>::value) == 1 ? -1 : 1 ];
|
int z[(lvalue_deref_helper<value_iterator>::value) == 1 ? -1 : 1 ];
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(__GNUC__, == 3) && BOOST_WORKAROUND(__GNUC_MINOR__, < 4) && !defined(__EDG_VERSION__) \
|
#if BOOST_WORKAROUND(__GNUC__, == 3) && BOOST_WORKAROUND(__GNUC_MINOR__, < 4) && !defined(__EDG_VERSION__) \
|
||||||
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
|| BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
|
||||||
# define BOOST_NO_IS_CONVERTIBLE_TEMPLATE // The following program fails to compile:
|
# define BOOST_NO_IS_CONVERTIBLE_TEMPLATE // The following program fails to compile:
|
||||||
|
|
||||||
# if 0 // test code
|
# if 0 // test code
|
||||||
@@ -112,9 +112,9 @@
|
|||||||
|
|
||||||
#if !defined(BOOST_MSVC) && (defined(BOOST_NO_SFINAE) || defined(BOOST_NO_IS_CONVERTIBLE) || defined(BOOST_NO_IS_CONVERTIBLE_TEMPLATE))
|
#if !defined(BOOST_MSVC) && (defined(BOOST_NO_SFINAE) || defined(BOOST_NO_IS_CONVERTIBLE) || defined(BOOST_NO_IS_CONVERTIBLE_TEMPLATE))
|
||||||
# define BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY
|
# define BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
# if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
|
||||||
|
|
||||||
// GCC-2.95 (obsolete) eagerly instantiates templated constructors and conversion
|
// GCC-2.95 (obsolete) eagerly instantiates templated constructors and conversion
|
||||||
// operators in convertibility checks, causing premature errors.
|
// operators in convertibility checks, causing premature errors.
|
||||||
@@ -123,6 +123,6 @@
|
|||||||
// instantiation stack backtrace. They may be due in part to the fact
|
// instantiation stack backtrace. They may be due in part to the fact
|
||||||
// that it drops cv-qualification willy-nilly in templates.
|
// that it drops cv-qualification willy-nilly in templates.
|
||||||
# define BOOST_NO_ONE_WAY_ITERATOR_INTEROP
|
# define BOOST_NO_ONE_WAY_ITERATOR_INTEROP
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// no include guard; multiple inclusion intended
|
// no include guard; multiple inclusion intended
|
||||||
|
|||||||
@@ -21,4 +21,4 @@
|
|||||||
# undef BOOST_ITERATOR_CONFIG_DEF
|
# undef BOOST_ITERATOR_CONFIG_DEF
|
||||||
#else
|
#else
|
||||||
# error missing or nested #include config_def
|
# error missing or nested #include config_def
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,10 +7,11 @@
|
|||||||
#ifndef BOOST_ENABLE_IF_23022003THW_HPP
|
#ifndef BOOST_ENABLE_IF_23022003THW_HPP
|
||||||
#define BOOST_ENABLE_IF_23022003THW_HPP
|
#define BOOST_ENABLE_IF_23022003THW_HPP
|
||||||
|
|
||||||
#include <boost/detail/workaround.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/mpl/identity.hpp>
|
|
||||||
|
|
||||||
#include <boost/iterator/detail/config_def.hpp>
|
#include <boost/iterator/detail/config_def.hpp>
|
||||||
|
#if defined(BOOST_NO_SFINAE) || defined(BOOST_NO_IS_CONVERTIBLE)
|
||||||
|
#include <boost/type_traits/type_identity.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// Boost iterators uses its own enable_if cause we need
|
// Boost iterators uses its own enable_if cause we need
|
||||||
@@ -48,7 +49,6 @@ namespace boost
|
|||||||
struct base
|
struct base
|
||||||
{
|
{
|
||||||
#ifdef BOOST_NO_SFINAE
|
#ifdef BOOST_NO_SFINAE
|
||||||
|
|
||||||
typedef T type;
|
typedef T type;
|
||||||
|
|
||||||
// This way to do it would give a nice error message containing
|
// This way to do it would give a nice error message containing
|
||||||
@@ -69,7 +69,7 @@ namespace boost
|
|||||||
# if !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_IS_CONVERTIBLE)
|
# if !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_IS_CONVERTIBLE)
|
||||||
: enabled<(Cond::value)>::template base<Return>
|
: enabled<(Cond::value)>::template base<Return>
|
||||||
# else
|
# else
|
||||||
: mpl::identity<Return>
|
: boost::type_identity<Return>
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,15 +13,14 @@
|
|||||||
# include <boost/mpl/if.hpp>
|
# include <boost/mpl/if.hpp>
|
||||||
# include <boost/mpl/eval_if.hpp>
|
# include <boost/mpl/eval_if.hpp>
|
||||||
# include <boost/mpl/identity.hpp>
|
# include <boost/mpl/identity.hpp>
|
||||||
# include <boost/mpl/assert.hpp>
|
|
||||||
|
# include <boost/static_assert.hpp>
|
||||||
|
|
||||||
# include <boost/type_traits/is_same.hpp>
|
# include <boost/type_traits/is_same.hpp>
|
||||||
# include <boost/type_traits/is_const.hpp>
|
# include <boost/type_traits/is_const.hpp>
|
||||||
# include <boost/type_traits/is_reference.hpp>
|
# include <boost/type_traits/is_reference.hpp>
|
||||||
# include <boost/type_traits/is_convertible.hpp>
|
# include <boost/type_traits/is_convertible.hpp>
|
||||||
|
|
||||||
# include <boost/type_traits/is_same.hpp>
|
|
||||||
|
|
||||||
# include <boost/iterator/detail/config_def.hpp> // try to keep this last
|
# include <boost/iterator/detail/config_def.hpp> // try to keep this last
|
||||||
|
|
||||||
# ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY
|
# ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY
|
||||||
@@ -139,17 +138,17 @@ struct iterator_category_with_traversal
|
|||||||
// Make sure this isn't used to build any categories where
|
// Make sure this isn't used to build any categories where
|
||||||
// convertibility to Traversal is redundant. Should just use the
|
// convertibility to Traversal is redundant. Should just use the
|
||||||
// Category element in that case.
|
// Category element in that case.
|
||||||
BOOST_MPL_ASSERT_NOT((
|
BOOST_STATIC_ASSERT((
|
||||||
is_convertible<
|
!is_convertible<
|
||||||
typename iterator_category_to_traversal<Category>::type
|
typename iterator_category_to_traversal<Category>::type
|
||||||
, Traversal
|
, Traversal
|
||||||
>));
|
>::value));
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((is_iterator_category<Category>));
|
BOOST_STATIC_ASSERT(is_iterator_category<Category>::value);
|
||||||
BOOST_MPL_ASSERT_NOT((is_iterator_category<Traversal>));
|
BOOST_STATIC_ASSERT(!is_iterator_category<Traversal>::value);
|
||||||
BOOST_MPL_ASSERT_NOT((is_iterator_traversal<Category>));
|
BOOST_STATIC_ASSERT(!is_iterator_traversal<Category>::value);
|
||||||
# if !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
|
# if !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
|
||||||
BOOST_MPL_ASSERT((is_iterator_traversal<Traversal>));
|
BOOST_STATIC_ASSERT(is_iterator_traversal<Traversal>::value);
|
||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -158,7 +157,7 @@ struct iterator_category_with_traversal
|
|||||||
template <class Traversal, class ValueParam, class Reference>
|
template <class Traversal, class ValueParam, class Reference>
|
||||||
struct facade_iterator_category_impl
|
struct facade_iterator_category_impl
|
||||||
{
|
{
|
||||||
BOOST_MPL_ASSERT_NOT((is_iterator_category<Traversal>));
|
BOOST_STATIC_ASSERT(!is_iterator_category<Traversal>::value);
|
||||||
|
|
||||||
typedef typename iterator_facade_default_category<
|
typedef typename iterator_facade_default_category<
|
||||||
Traversal,ValueParam,Reference
|
Traversal,ValueParam,Reference
|
||||||
|
|||||||
@@ -12,6 +12,14 @@
|
|||||||
|
|
||||||
#include <boost/type_traits/is_class.hpp>
|
#include <boost/type_traits/is_class.hpp>
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
|
|
||||||
|
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
|
#define BOOST_ITERATOR_DETAIL_MOVE(_type, _value) static_cast< _type&& >(_value)
|
||||||
|
#else
|
||||||
|
#define BOOST_ITERATOR_DETAIL_MOVE(_type, _value) _value
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace iterators {
|
namespace iterators {
|
||||||
@@ -54,13 +62,13 @@ namespace iterators {
|
|||||||
filter_iterator() { }
|
filter_iterator() { }
|
||||||
|
|
||||||
filter_iterator(Predicate f, Iterator x, Iterator end_ = Iterator())
|
filter_iterator(Predicate f, Iterator x, Iterator end_ = Iterator())
|
||||||
: super_t(x), m_predicate(f), m_end(end_)
|
: super_t(BOOST_ITERATOR_DETAIL_MOVE(Iterator, x)), m_predicate(BOOST_ITERATOR_DETAIL_MOVE(Predicate, f)), m_end(BOOST_ITERATOR_DETAIL_MOVE(Iterator, end_))
|
||||||
{
|
{
|
||||||
satisfy_predicate();
|
satisfy_predicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
filter_iterator(Iterator x, Iterator end_ = Iterator())
|
filter_iterator(Iterator x, Iterator end_ = Iterator())
|
||||||
: super_t(x), m_predicate(), m_end(end_)
|
: super_t(BOOST_ITERATOR_DETAIL_MOVE(Iterator, x)), m_predicate(), m_end(BOOST_ITERATOR_DETAIL_MOVE(Iterator, end_))
|
||||||
{
|
{
|
||||||
// Pro8 is a little too aggressive about instantiating the
|
// Pro8 is a little too aggressive about instantiating the
|
||||||
// body of this function.
|
// body of this function.
|
||||||
@@ -111,7 +119,7 @@ namespace iterators {
|
|||||||
inline filter_iterator<Predicate,Iterator>
|
inline filter_iterator<Predicate,Iterator>
|
||||||
make_filter_iterator(Predicate f, Iterator x, Iterator end = Iterator())
|
make_filter_iterator(Predicate f, Iterator x, Iterator end = Iterator())
|
||||||
{
|
{
|
||||||
return filter_iterator<Predicate,Iterator>(f,x,end);
|
return filter_iterator<Predicate,Iterator>(BOOST_ITERATOR_DETAIL_MOVE(Predicate, f), BOOST_ITERATOR_DETAIL_MOVE(Iterator, x), BOOST_ITERATOR_DETAIL_MOVE(Iterator, end));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Predicate, class Iterator>
|
template <class Predicate, class Iterator>
|
||||||
@@ -123,7 +131,7 @@ namespace iterators {
|
|||||||
>::type x
|
>::type x
|
||||||
, Iterator end = Iterator())
|
, Iterator end = Iterator())
|
||||||
{
|
{
|
||||||
return filter_iterator<Predicate,Iterator>(x,end);
|
return filter_iterator<Predicate,Iterator>(BOOST_ITERATOR_DETAIL_MOVE(Iterator, x), BOOST_ITERATOR_DETAIL_MOVE(Iterator, end));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace iterators
|
} // namespace iterators
|
||||||
@@ -133,4 +141,6 @@ using iterators::make_filter_iterator;
|
|||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
#undef BOOST_ITERATOR_DETAIL_MOVE
|
||||||
|
|
||||||
#endif // BOOST_FILTER_ITERATOR_23022003THW_HPP
|
#endif // BOOST_FILTER_ITERATOR_23022003THW_HPP
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/core/addressof.hpp>
|
#include <boost/core/addressof.hpp>
|
||||||
#include <boost/mpl/if.hpp>
|
#include <boost/type_traits/conditional.hpp>
|
||||||
#include <boost/function_types/is_function_pointer.hpp>
|
#include <boost/function_types/is_function_pointer.hpp>
|
||||||
#include <boost/function_types/result_type.hpp>
|
#include <boost/function_types/result_type.hpp>
|
||||||
#include <boost/iterator/iterator_facade.hpp>
|
#include <boost/iterator/iterator_facade.hpp>
|
||||||
@@ -28,6 +28,9 @@ namespace boost {
|
|||||||
|
|
||||||
namespace iterators {
|
namespace iterators {
|
||||||
|
|
||||||
|
template <class Function, class Input>
|
||||||
|
class function_input_iterator;
|
||||||
|
|
||||||
namespace impl {
|
namespace impl {
|
||||||
|
|
||||||
// Computes the return type of an lvalue-call with an empty argument,
|
// Computes the return type of an lvalue-call with an empty argument,
|
||||||
@@ -38,7 +41,7 @@ namespace iterators {
|
|||||||
{
|
{
|
||||||
typedef typename result_of<
|
typedef typename result_of<
|
||||||
#ifdef BOOST_RESULT_OF_USE_TR1
|
#ifdef BOOST_RESULT_OF_USE_TR1
|
||||||
typename mpl::if_<is_function<F>, F&, F>::type()
|
typename boost::conditional<is_function<F>::value, F&, F>::type()
|
||||||
#else
|
#else
|
||||||
F&()
|
F&()
|
||||||
#endif
|
#endif
|
||||||
@@ -46,21 +49,21 @@ namespace iterators {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <class Function, class Input>
|
template <class Function, class Input>
|
||||||
class function_input_iterator
|
class function_object_input_iterator :
|
||||||
: public iterator_facade<
|
public iterator_facade<
|
||||||
function_input_iterator<Function, Input>,
|
iterators::function_input_iterator<Function, Input>,
|
||||||
typename result_of_nullary_lvalue_call<Function>::type,
|
typename result_of_nullary_lvalue_call<Function>::type,
|
||||||
single_pass_traversal_tag,
|
single_pass_traversal_tag,
|
||||||
typename result_of_nullary_lvalue_call<Function>::type const &
|
typename result_of_nullary_lvalue_call<Function>::type const &
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
function_input_iterator() {}
|
function_object_input_iterator() {}
|
||||||
function_input_iterator(Function & f_, Input state_ = Input())
|
function_object_input_iterator(Function & f_, Input state_ = Input())
|
||||||
: f(boost::addressof(f_)), state(state_) {}
|
: f(boost::addressof(f_)), state(state_) {}
|
||||||
|
|
||||||
void increment() {
|
void increment() {
|
||||||
if(value)
|
if (value)
|
||||||
value = none;
|
value = none;
|
||||||
else
|
else
|
||||||
(*f)();
|
(*f)();
|
||||||
@@ -69,10 +72,12 @@ namespace iterators {
|
|||||||
|
|
||||||
typename result_of_nullary_lvalue_call<Function>::type const &
|
typename result_of_nullary_lvalue_call<Function>::type const &
|
||||||
dereference() const {
|
dereference() const {
|
||||||
return (value ? value : value = (*f)()).get();
|
if (!value)
|
||||||
|
value = (*f)();
|
||||||
|
return value.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool equal(function_input_iterator const & other) const {
|
bool equal(function_object_input_iterator const & other) const {
|
||||||
return f == other.f && state == other.state;
|
return f == other.f && state == other.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,12 +88,12 @@ namespace iterators {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <class Function, class Input>
|
template <class Function, class Input>
|
||||||
class function_pointer_input_iterator
|
class function_pointer_input_iterator :
|
||||||
: public iterator_facade<
|
public iterator_facade<
|
||||||
function_pointer_input_iterator<Function, Input>,
|
iterators::function_input_iterator<Function, Input>,
|
||||||
typename function_types::result_type<Function>::type,
|
typename function_types::result_type<Function>::type,
|
||||||
single_pass_traversal_tag,
|
single_pass_traversal_tag,
|
||||||
typename function_types::result_type<Function>::type const &
|
typename function_types::result_type<Function>::type const &
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -97,7 +102,7 @@ namespace iterators {
|
|||||||
: f(f_), state(state_) {}
|
: f(f_), state(state_) {}
|
||||||
|
|
||||||
void increment() {
|
void increment() {
|
||||||
if(value)
|
if (value)
|
||||||
value = none;
|
value = none;
|
||||||
else
|
else
|
||||||
(*f)();
|
(*f)();
|
||||||
@@ -106,7 +111,9 @@ namespace iterators {
|
|||||||
|
|
||||||
typename function_types::result_type<Function>::type const &
|
typename function_types::result_type<Function>::type const &
|
||||||
dereference() const {
|
dereference() const {
|
||||||
return (value ? value : value = (*f)()).get();
|
if (!value)
|
||||||
|
value = (*f)();
|
||||||
|
return value.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool equal(function_pointer_input_iterator const & other) const {
|
bool equal(function_pointer_input_iterator const & other) const {
|
||||||
@@ -122,17 +129,17 @@ namespace iterators {
|
|||||||
} // namespace impl
|
} // namespace impl
|
||||||
|
|
||||||
template <class Function, class Input>
|
template <class Function, class Input>
|
||||||
class function_input_iterator
|
class function_input_iterator :
|
||||||
: public mpl::if_<
|
public boost::conditional<
|
||||||
function_types::is_function_pointer<Function>,
|
function_types::is_function_pointer<Function>::value,
|
||||||
impl::function_pointer_input_iterator<Function,Input>,
|
impl::function_pointer_input_iterator<Function,Input>,
|
||||||
impl::function_input_iterator<Function,Input>
|
impl::function_object_input_iterator<Function,Input>
|
||||||
>::type
|
>::type
|
||||||
{
|
{
|
||||||
typedef typename mpl::if_<
|
typedef typename boost::conditional<
|
||||||
function_types::is_function_pointer<Function>,
|
function_types::is_function_pointer<Function>::value,
|
||||||
impl::function_pointer_input_iterator<Function,Input>,
|
impl::function_pointer_input_iterator<Function,Input>,
|
||||||
impl::function_input_iterator<Function,Input>
|
impl::function_object_input_iterator<Function,Input>
|
||||||
>::type base_type;
|
>::type base_type;
|
||||||
public:
|
public:
|
||||||
function_input_iterator(Function & f, Input i)
|
function_input_iterator(Function & f, Input i)
|
||||||
@@ -153,7 +160,8 @@ namespace iterators {
|
|||||||
return result_t(f, state);
|
return result_t(f, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct infinite {
|
struct infinite
|
||||||
|
{
|
||||||
infinite & operator++() { return *this; }
|
infinite & operator++() { return *this; }
|
||||||
infinite & operator++(int) { return *this; }
|
infinite & operator++(int) { return *this; }
|
||||||
bool operator==(infinite &) const { return false; };
|
bool operator==(infinite &) const { return false; };
|
||||||
|
|||||||
@@ -12,13 +12,53 @@
|
|||||||
#define BOOST_ITERATOR_FUNCTION_OUTPUT_ITERATOR_HPP
|
#define BOOST_ITERATOR_FUNCTION_OUTPUT_ITERATOR_HPP
|
||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/core/enable_if.hpp>
|
||||||
|
#include <boost/type_traits/is_same.hpp>
|
||||||
|
#include <boost/type_traits/remove_cv.hpp>
|
||||||
|
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
|
#include <boost/type_traits/remove_reference.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace iterators {
|
namespace iterators {
|
||||||
|
|
||||||
template <class UnaryFunction>
|
template <class UnaryFunction>
|
||||||
class function_output_iterator {
|
class function_output_iterator {
|
||||||
|
private:
|
||||||
typedef function_output_iterator self;
|
typedef function_output_iterator self;
|
||||||
|
|
||||||
|
class output_proxy {
|
||||||
|
public:
|
||||||
|
explicit output_proxy(UnaryFunction& f) BOOST_NOEXCEPT : m_f(f) { }
|
||||||
|
|
||||||
|
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||||
|
template <class T>
|
||||||
|
typename boost::disable_if_c<
|
||||||
|
boost::is_same< typename boost::remove_cv< T >::type, output_proxy >::value,
|
||||||
|
output_proxy&
|
||||||
|
>::type operator=(const T& value) {
|
||||||
|
m_f(value);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
template <class T>
|
||||||
|
typename boost::disable_if_c<
|
||||||
|
boost::is_same< typename boost::remove_cv< typename boost::remove_reference< T >::type >::type, output_proxy >::value,
|
||||||
|
output_proxy&
|
||||||
|
>::type operator=(T&& value) {
|
||||||
|
m_f(static_cast< T&& >(value));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
BOOST_DEFAULTED_FUNCTION(output_proxy(output_proxy const& that), BOOST_NOEXCEPT : m_f(that.m_f) {})
|
||||||
|
BOOST_DELETED_FUNCTION(output_proxy& operator=(output_proxy const&))
|
||||||
|
|
||||||
|
private:
|
||||||
|
UnaryFunction& m_f;
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef std::output_iterator_tag iterator_category;
|
typedef std::output_iterator_tag iterator_category;
|
||||||
typedef void value_type;
|
typedef void value_type;
|
||||||
@@ -31,17 +71,10 @@ namespace iterators {
|
|||||||
explicit function_output_iterator(const UnaryFunction& f)
|
explicit function_output_iterator(const UnaryFunction& f)
|
||||||
: m_f(f) {}
|
: m_f(f) {}
|
||||||
|
|
||||||
struct output_proxy {
|
|
||||||
output_proxy(UnaryFunction& f) : m_f(f) { }
|
|
||||||
template <class T> output_proxy& operator=(const T& value) {
|
|
||||||
m_f(value);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
UnaryFunction& m_f;
|
|
||||||
};
|
|
||||||
output_proxy operator*() { return output_proxy(m_f); }
|
output_proxy operator*() { return output_proxy(m_f); }
|
||||||
self& operator++() { return *this; }
|
self& operator++() { return *this; }
|
||||||
self& operator++(int) { return *this; }
|
self& operator++(int) { return *this; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UnaryFunction m_f;
|
UnaryFunction m_f;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ namespace iterators {
|
|||||||
private:
|
private:
|
||||||
typename super_t::reference dereference() const
|
typename super_t::reference dereference() const
|
||||||
{
|
{
|
||||||
# if BOOST_WORKAROUND(__BORLANDC__, < 0x5A0 )
|
# if BOOST_WORKAROUND(BOOST_BORLANDC, < 0x5A0 )
|
||||||
return const_cast<super_t::reference>(**this->base());
|
return const_cast<super_t::reference>(**this->base());
|
||||||
# else
|
# else
|
||||||
return **this->base();
|
return **this->base();
|
||||||
|
|||||||
@@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
* 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)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Andrey Semashev
|
||||||
|
*/
|
||||||
|
/*!
|
||||||
|
* \file iterator/is_iterator.hpp
|
||||||
|
*
|
||||||
|
* This header contains definition of the \c is_iterator type trait.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BOOST_ITERATOR_IS_ITERATOR_HPP_INCLUDED_
|
||||||
|
#define BOOST_ITERATOR_IS_ITERATOR_HPP_INCLUDED_
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/type_traits/integral_constant.hpp>
|
||||||
|
#include <boost/type_traits/negation.hpp>
|
||||||
|
#include <boost/type_traits/conjunction.hpp>
|
||||||
|
#include <boost/type_traits/is_complete.hpp>
|
||||||
|
#include <boost/type_traits/is_function.hpp>
|
||||||
|
#if !defined(BOOST_NO_CXX17_ITERATOR_TRAITS)
|
||||||
|
#include <iterator>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||||
|
#pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
namespace iterators {
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
// The trait attempts to detect if the T type is an iterator class. Class-type iterators are assumed
|
||||||
|
// to have the nested type iterator_category. Strictly speaking, this is not required to be the
|
||||||
|
// case (e.g. a user can specialize iterator_traits for T without defining T::iterator_category).
|
||||||
|
// Still, this is a good heuristic in practice, and we can't do anything better anyway.
|
||||||
|
// Since C++17 we can test for iterator_traits<T>::iterator_category presence instead as it is
|
||||||
|
// required to be only present for iterators.
|
||||||
|
namespace has_iterator_category_detail {
|
||||||
|
|
||||||
|
typedef char yes_type;
|
||||||
|
struct no_type { char padding[2]; };
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
yes_type check(
|
||||||
|
#if !defined(BOOST_NO_CXX17_ITERATOR_TRAITS)
|
||||||
|
typename std::iterator_traits< T >::iterator_category*
|
||||||
|
#else
|
||||||
|
typename T::iterator_category*
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
template< typename >
|
||||||
|
no_type check(...);
|
||||||
|
|
||||||
|
} // namespace has_iterator_category_detail
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
struct is_iterator_impl :
|
||||||
|
public boost::integral_constant<
|
||||||
|
bool,
|
||||||
|
sizeof(has_iterator_category_detail::check< T >(0)) == sizeof(has_iterator_category_detail::yes_type)
|
||||||
|
>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
struct is_iterator_impl< T* > :
|
||||||
|
public boost::conjunction<
|
||||||
|
boost::is_complete< T >,
|
||||||
|
boost::negation< boost::is_function< T > >
|
||||||
|
>::type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template< typename T, typename U >
|
||||||
|
struct is_iterator_impl< T U::* > :
|
||||||
|
public boost::false_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
struct is_iterator_impl< T& > :
|
||||||
|
public boost::false_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template< typename T, std::size_t N >
|
||||||
|
struct is_iterator_impl< T[N] > :
|
||||||
|
public boost::false_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
#if !defined(BOOST_TT_HAS_WORKING_IS_COMPLETE)
|
||||||
|
template< typename T >
|
||||||
|
struct is_iterator_impl< T[] > :
|
||||||
|
public boost::false_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template< >
|
||||||
|
struct is_iterator_impl< void > :
|
||||||
|
public boost::false_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template< >
|
||||||
|
struct is_iterator_impl< void* > :
|
||||||
|
public boost::false_type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
#endif // !defined(BOOST_TT_HAS_WORKING_IS_COMPLETE)
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief The type trait detects whether the type \c T is an iterator type.
|
||||||
|
*
|
||||||
|
* The type trait yields \c true if its argument type \c T, after stripping top level
|
||||||
|
* cv qualifiers, is one of the following:
|
||||||
|
*
|
||||||
|
* - A pointer type, other than a pointer to function, a pointer to a class member,
|
||||||
|
* or a pointer to an incomplete type, including `void`.
|
||||||
|
* - A class type for which an iterator category is obtainable. Prior to C++17,
|
||||||
|
* the iterator category must be defined as a public `T::iterator_category` type.
|
||||||
|
* Since C++17, the expression `std::iterator_traits< T >::iterator_category` must
|
||||||
|
* be valid and produce the iterator category type.
|
||||||
|
*
|
||||||
|
* Otherwise, the type trait yields \c false.
|
||||||
|
*/
|
||||||
|
template< typename T >
|
||||||
|
struct is_iterator : public detail::is_iterator_impl< T >::type {};
|
||||||
|
template< typename T >
|
||||||
|
struct is_iterator< const T > : public detail::is_iterator_impl< T >::type {};
|
||||||
|
template< typename T >
|
||||||
|
struct is_iterator< volatile T > : public detail::is_iterator_impl< T >::type {};
|
||||||
|
template< typename T >
|
||||||
|
struct is_iterator< const volatile T > : public detail::is_iterator_impl< T >::type {};
|
||||||
|
|
||||||
|
} // namespace iterators
|
||||||
|
|
||||||
|
using iterators::is_iterator;
|
||||||
|
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // BOOST_ITERATOR_IS_ITERATOR_HPP_INCLUDED_
|
||||||
@@ -144,8 +144,8 @@ namespace boost_concepts
|
|||||||
{
|
{
|
||||||
typedef typename std::iterator_traits<Iterator>::difference_type difference_type;
|
typedef typename std::iterator_traits<Iterator>::difference_type difference_type;
|
||||||
|
|
||||||
BOOST_MPL_ASSERT((boost::is_integral<difference_type>));
|
BOOST_STATIC_ASSERT(boost::is_integral<difference_type>::value);
|
||||||
BOOST_MPL_ASSERT_RELATION(std::numeric_limits<difference_type>::is_signed, ==, true);
|
BOOST_STATIC_ASSERT(std::numeric_limits<difference_type>::is_signed);
|
||||||
|
|
||||||
BOOST_CONCEPT_ASSERT((
|
BOOST_CONCEPT_ASSERT((
|
||||||
boost::Convertible<
|
boost::Convertible<
|
||||||
|
|||||||
@@ -154,79 +154,160 @@ namespace iterators {
|
|||||||
class postfix_increment_proxy
|
class postfix_increment_proxy
|
||||||
{
|
{
|
||||||
typedef typename iterator_value<Iterator>::type value_type;
|
typedef typename iterator_value<Iterator>::type value_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit postfix_increment_proxy(Iterator const& x)
|
explicit postfix_increment_proxy(Iterator const& x)
|
||||||
: stored_value(*x)
|
: stored_iterator(x)
|
||||||
|
, stored_value(*x)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// Returning a mutable reference allows nonsense like
|
// Returning a mutable reference allows nonsense like
|
||||||
// (*r++).mutate(), but it imposes fewer assumptions about the
|
// (*r++).mutate(), but it imposes fewer assumptions about the
|
||||||
// behavior of the value_type. In particular, recall that
|
// behavior of the value_type. In particular, recall that
|
||||||
// (*r).mutate() is legal if operator* returns by value.
|
// (*r).mutate() is legal if operator* returns by value.
|
||||||
value_type&
|
|
||||||
operator*() const
|
|
||||||
{
|
|
||||||
return this->stored_value;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
mutable value_type stored_value;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// In general, we can't determine that such an iterator isn't
|
|
||||||
// writable -- we also need to store a copy of the old iterator so
|
|
||||||
// that it can be written into.
|
|
||||||
template <class Iterator>
|
|
||||||
class writable_postfix_increment_proxy
|
|
||||||
{
|
|
||||||
typedef typename iterator_value<Iterator>::type value_type;
|
|
||||||
public:
|
|
||||||
explicit writable_postfix_increment_proxy(Iterator const& x)
|
|
||||||
: stored_value(*x)
|
|
||||||
, stored_iterator(x)
|
|
||||||
{}
|
|
||||||
|
|
||||||
// Dereferencing must return a proxy so that both *r++ = o and
|
|
||||||
// value_type(*r++) can work. In this case, *r is the same as
|
|
||||||
// *r++, and the conversion operator below is used to ensure
|
|
||||||
// readability.
|
|
||||||
writable_postfix_increment_proxy const&
|
|
||||||
operator*() const
|
|
||||||
{
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Provides readability of *r++
|
// Provides readability of *r++
|
||||||
operator value_type&() const
|
value_type& operator*() const
|
||||||
{
|
{
|
||||||
return stored_value;
|
return stored_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provides writability of *r++
|
|
||||||
template <class T>
|
|
||||||
T const& operator=(T const& x) const
|
|
||||||
{
|
|
||||||
*this->stored_iterator = x;
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This overload just in case only non-const objects are writable
|
|
||||||
template <class T>
|
|
||||||
T& operator=(T& x) const
|
|
||||||
{
|
|
||||||
*this->stored_iterator = x;
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Provides X(r++)
|
// Provides X(r++)
|
||||||
operator Iterator const&() const
|
operator Iterator const&() const
|
||||||
{
|
{
|
||||||
return stored_iterator;
|
return stored_iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Provides (r++)->foo()
|
||||||
|
value_type* operator->() const
|
||||||
|
{
|
||||||
|
return boost::addressof(stored_value);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable value_type stored_value;
|
|
||||||
Iterator stored_iterator;
|
Iterator stored_iterator;
|
||||||
|
mutable value_type stored_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <class Iterator>
|
||||||
|
class writable_postfix_increment_dereference_proxy;
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
struct is_not_writable_postfix_increment_dereference_proxy :
|
||||||
|
public boost::true_type
|
||||||
|
{};
|
||||||
|
|
||||||
|
template <class Iterator>
|
||||||
|
struct is_not_writable_postfix_increment_dereference_proxy<
|
||||||
|
writable_postfix_increment_dereference_proxy<Iterator>
|
||||||
|
> :
|
||||||
|
public boost::false_type
|
||||||
|
{};
|
||||||
|
|
||||||
|
template <class Iterator>
|
||||||
|
class writable_postfix_increment_proxy;
|
||||||
|
|
||||||
|
//
|
||||||
|
// In general, we can't determine that such an iterator isn't
|
||||||
|
// writable -- we also need to store a copy of the old iterator so
|
||||||
|
// that it can be written into.
|
||||||
|
template <class Iterator>
|
||||||
|
class writable_postfix_increment_dereference_proxy
|
||||||
|
{
|
||||||
|
friend class writable_postfix_increment_proxy<Iterator>;
|
||||||
|
|
||||||
|
typedef typename iterator_value<Iterator>::type value_type;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit writable_postfix_increment_dereference_proxy(Iterator const& x)
|
||||||
|
: stored_iterator(x)
|
||||||
|
, stored_value(*x)
|
||||||
|
{}
|
||||||
|
|
||||||
|
// Provides readability of *r++
|
||||||
|
operator value_type&() const
|
||||||
|
{
|
||||||
|
return this->stored_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class OtherIterator>
|
||||||
|
writable_postfix_increment_dereference_proxy const&
|
||||||
|
operator=(writable_postfix_increment_dereference_proxy<OtherIterator> const& x) const
|
||||||
|
{
|
||||||
|
typedef typename iterator_value<OtherIterator>::type other_value_type;
|
||||||
|
*this->stored_iterator = static_cast<other_value_type&>(x);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Provides writability of *r++
|
||||||
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||||
|
template <class T>
|
||||||
|
typename iterators::enable_if<
|
||||||
|
is_not_writable_postfix_increment_dereference_proxy< T >,
|
||||||
|
writable_postfix_increment_dereference_proxy const&
|
||||||
|
>::type operator=(T&& x) const
|
||||||
|
{
|
||||||
|
*this->stored_iterator = static_cast< T&& >(x);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
template <class T>
|
||||||
|
typename iterators::enable_if<
|
||||||
|
is_not_writable_postfix_increment_dereference_proxy< T >,
|
||||||
|
writable_postfix_increment_dereference_proxy const&
|
||||||
|
>::type operator=(T const& x) const
|
||||||
|
{
|
||||||
|
*this->stored_iterator = x;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This overload just in case only non-const objects are writable
|
||||||
|
template <class T>
|
||||||
|
typename iterators::enable_if<
|
||||||
|
is_not_writable_postfix_increment_dereference_proxy< T >,
|
||||||
|
writable_postfix_increment_dereference_proxy const&
|
||||||
|
>::type operator=(T& x) const
|
||||||
|
{
|
||||||
|
*this->stored_iterator = x;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
Iterator stored_iterator;
|
||||||
|
mutable value_type stored_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class Iterator>
|
||||||
|
class writable_postfix_increment_proxy
|
||||||
|
{
|
||||||
|
typedef typename iterator_value<Iterator>::type value_type;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit writable_postfix_increment_proxy(Iterator const& x)
|
||||||
|
: dereference_proxy(x)
|
||||||
|
{}
|
||||||
|
|
||||||
|
writable_postfix_increment_dereference_proxy<Iterator> const&
|
||||||
|
operator*() const
|
||||||
|
{
|
||||||
|
return dereference_proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Provides X(r++)
|
||||||
|
operator Iterator const&() const
|
||||||
|
{
|
||||||
|
return dereference_proxy.stored_iterator;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Provides (r++)->foo()
|
||||||
|
value_type* operator->() const
|
||||||
|
{
|
||||||
|
return boost::addressof(dereference_proxy.stored_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
writable_postfix_increment_dereference_proxy<Iterator> dereference_proxy;
|
||||||
};
|
};
|
||||||
|
|
||||||
# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||||
|
|||||||
@@ -87,11 +87,11 @@ void readable_iterator_test(const Iterator i1, T v)
|
|||||||
|
|
||||||
# if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
# if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||||
readable_iterator_traversal_test(i1, v, detail::is_postfix_incrementable<Iterator>());
|
readable_iterator_traversal_test(i1, v, detail::is_postfix_incrementable<Iterator>());
|
||||||
|
|
||||||
// I think we don't really need this as it checks the same things as
|
// I think we don't really need this as it checks the same things as
|
||||||
// the above code.
|
// the above code.
|
||||||
BOOST_STATIC_ASSERT(is_readable_iterator<Iterator>::value);
|
BOOST_STATIC_ASSERT(is_readable_iterator<Iterator>::value);
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Iterator, class T>
|
template <class Iterator, class T>
|
||||||
@@ -106,7 +106,7 @@ void writable_iterator_test(Iterator i, T v, T v2)
|
|||||||
detail::is_incrementable<Iterator>
|
detail::is_incrementable<Iterator>
|
||||||
, detail::is_postfix_incrementable<Iterator>
|
, detail::is_postfix_incrementable<Iterator>
|
||||||
>());
|
>());
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Iterator>
|
template <class Iterator>
|
||||||
@@ -131,7 +131,7 @@ void constant_lvalue_iterator_test(Iterator i, T v1)
|
|||||||
# ifndef BOOST_NO_LVALUE_RETURN_DETECTION
|
# ifndef BOOST_NO_LVALUE_RETURN_DETECTION
|
||||||
BOOST_STATIC_ASSERT(is_lvalue_iterator<Iterator>::value);
|
BOOST_STATIC_ASSERT(is_lvalue_iterator<Iterator>::value);
|
||||||
BOOST_STATIC_ASSERT(!is_non_const_lvalue_iterator<Iterator>::value);
|
BOOST_STATIC_ASSERT(!is_non_const_lvalue_iterator<Iterator>::value);
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Iterator, class T>
|
template <class Iterator, class T>
|
||||||
@@ -143,17 +143,17 @@ void non_const_lvalue_iterator_test(Iterator i, T v1, T v2)
|
|||||||
BOOST_STATIC_ASSERT((is_same<value_type&, reference>::value));
|
BOOST_STATIC_ASSERT((is_same<value_type&, reference>::value));
|
||||||
T& v3 = *i2;
|
T& v3 = *i2;
|
||||||
BOOST_TEST(v1 == v3);
|
BOOST_TEST(v1 == v3);
|
||||||
|
|
||||||
// A non-const lvalue iterator is not neccessarily writable, but we
|
// A non-const lvalue iterator is not neccessarily writable, but we
|
||||||
// are assuming the value_type is assignable here
|
// are assuming the value_type is assignable here
|
||||||
*i = v2;
|
*i = v2;
|
||||||
|
|
||||||
T& v4 = *i2;
|
T& v4 = *i2;
|
||||||
BOOST_TEST(v2 == v4);
|
BOOST_TEST(v2 == v4);
|
||||||
# ifndef BOOST_NO_LVALUE_RETURN_DETECTION
|
# ifndef BOOST_NO_LVALUE_RETURN_DETECTION
|
||||||
BOOST_STATIC_ASSERT(is_lvalue_iterator<Iterator>::value);
|
BOOST_STATIC_ASSERT(is_lvalue_iterator<Iterator>::value);
|
||||||
BOOST_STATIC_ASSERT(is_non_const_lvalue_iterator<Iterator>::value);
|
BOOST_STATIC_ASSERT(is_non_const_lvalue_iterator<Iterator>::value);
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Iterator, class T>
|
template <class Iterator, class T>
|
||||||
@@ -248,7 +248,7 @@ void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals)
|
|||||||
BOOST_TEST(*i == vals[N - 1 - c]);
|
BOOST_TEST(*i == vals[N - 1 - c]);
|
||||||
typename std::iterator_traits<Iterator>::value_type x = j[N - 1 - c];
|
typename std::iterator_traits<Iterator>::value_type x = j[N - 1 - c];
|
||||||
BOOST_TEST(*i == x);
|
BOOST_TEST(*i == x);
|
||||||
Iterator q = k - c;
|
Iterator q = k - c;
|
||||||
BOOST_TEST(*i == *q);
|
BOOST_TEST(*i == *q);
|
||||||
BOOST_TEST(i > j);
|
BOOST_TEST(i > j);
|
||||||
BOOST_TEST(i >= j);
|
BOOST_TEST(i >= j);
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
#ifndef BOOST_TRANSFORM_ITERATOR_23022003THW_HPP
|
#ifndef BOOST_TRANSFORM_ITERATOR_23022003THW_HPP
|
||||||
#define BOOST_TRANSFORM_ITERATOR_23022003THW_HPP
|
#define BOOST_TRANSFORM_ITERATOR_23022003THW_HPP
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
#include <boost/iterator/detail/enable_if.hpp>
|
#include <boost/iterator/detail/enable_if.hpp>
|
||||||
#include <boost/iterator/iterator_adaptor.hpp>
|
#include <boost/iterator/iterator_adaptor.hpp>
|
||||||
#include <boost/iterator/iterator_categories.hpp>
|
#include <boost/iterator/iterator_categories.hpp>
|
||||||
#include <boost/mpl/not.hpp>
|
|
||||||
#include <boost/mpl/bool.hpp>
|
|
||||||
#include <boost/type_traits/function_traits.hpp>
|
#include <boost/type_traits/function_traits.hpp>
|
||||||
#include <boost/type_traits/is_const.hpp>
|
#include <boost/type_traits/is_const.hpp>
|
||||||
#include <boost/type_traits/is_class.hpp>
|
#include <boost/type_traits/is_class.hpp>
|
||||||
@@ -24,7 +24,11 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
|
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
|
||||||
# include <boost/type_traits/is_base_and_derived.hpp>
|
#include <boost/type_traits/is_base_and_derived.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
|
||||||
|
#include <boost/static_assert.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/iterator/detail/config_def.hpp>
|
#include <boost/iterator/detail/config_def.hpp>
|
||||||
@@ -154,7 +158,7 @@ namespace iterators {
|
|||||||
return transform_iterator<UnaryFunc, Iterator>(it, UnaryFunc());
|
return transform_iterator<UnaryFunc, Iterator>(it, UnaryFunc());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
|
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
|
||||||
template <class Return, class Argument, class Iterator>
|
template <class Return, class Argument, class Iterator>
|
||||||
inline transform_iterator< Return (*)(Argument), Iterator, Return>
|
inline transform_iterator< Return (*)(Argument), Iterator, Return>
|
||||||
make_transform_iterator(Iterator it, Return (*fun)(Argument))
|
make_transform_iterator(Iterator it, Return (*fun)(Argument))
|
||||||
|
|||||||
@@ -15,13 +15,12 @@
|
|||||||
#ifndef BOOST_NEXT_PRIOR_HPP_INCLUDED
|
#ifndef BOOST_NEXT_PRIOR_HPP_INCLUDED
|
||||||
#define BOOST_NEXT_PRIOR_HPP_INCLUDED
|
#define BOOST_NEXT_PRIOR_HPP_INCLUDED
|
||||||
|
|
||||||
#include <iterator>
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/core/enable_if.hpp>
|
|
||||||
#include <boost/type_traits/has_plus.hpp>
|
#include <boost/type_traits/has_plus.hpp>
|
||||||
#include <boost/type_traits/has_plus_assign.hpp>
|
#include <boost/type_traits/has_plus_assign.hpp>
|
||||||
#include <boost/type_traits/has_minus.hpp>
|
#include <boost/type_traits/has_minus.hpp>
|
||||||
#include <boost/type_traits/has_minus_assign.hpp>
|
#include <boost/type_traits/has_minus_assign.hpp>
|
||||||
|
#include <boost/iterator/is_iterator.hpp>
|
||||||
#include <boost/iterator/advance.hpp>
|
#include <boost/iterator/advance.hpp>
|
||||||
#include <boost/iterator/reverse_iterator.hpp>
|
#include <boost/iterator/reverse_iterator.hpp>
|
||||||
|
|
||||||
@@ -39,46 +38,6 @@ namespace boost {
|
|||||||
|
|
||||||
namespace next_prior_detail {
|
namespace next_prior_detail {
|
||||||
|
|
||||||
// The trait attempts to detect if the T type is an iterator. Class-type iterators are assumed
|
|
||||||
// to have the nested type iterator_category. Strictly speaking, this is not required to be the
|
|
||||||
// case (e.g. a user can specialize iterator_traits for T without defining T::iterator_category).
|
|
||||||
// Still, this is a good heuristic in practice, and we can't do anything better anyway.
|
|
||||||
// Since C++17 we can test for iterator_traits<T>::iterator_category presence instead as it is
|
|
||||||
// required to be only present for iterators.
|
|
||||||
template< typename T, typename Void = void >
|
|
||||||
struct is_iterator_class
|
|
||||||
{
|
|
||||||
static BOOST_CONSTEXPR_OR_CONST bool value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
template< typename T >
|
|
||||||
struct is_iterator_class<
|
|
||||||
T,
|
|
||||||
typename enable_if_has_type<
|
|
||||||
#if !defined(BOOST_NO_CXX17_ITERATOR_TRAITS)
|
|
||||||
typename std::iterator_traits< T >::iterator_category
|
|
||||||
#else
|
|
||||||
typename T::iterator_category
|
|
||||||
#endif
|
|
||||||
>::type
|
|
||||||
>
|
|
||||||
{
|
|
||||||
static BOOST_CONSTEXPR_OR_CONST bool value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
template< typename T >
|
|
||||||
struct is_iterator :
|
|
||||||
public is_iterator_class< T >
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
template< typename T >
|
|
||||||
struct is_iterator< T* >
|
|
||||||
{
|
|
||||||
static BOOST_CONSTEXPR_OR_CONST bool value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template< typename T, typename Distance, bool HasPlus = has_plus< T, Distance >::value >
|
template< typename T, typename Distance, bool HasPlus = has_plus< T, Distance >::value >
|
||||||
struct next_plus_impl;
|
struct next_plus_impl;
|
||||||
|
|
||||||
@@ -107,7 +66,7 @@ struct next_plus_assign_impl< T, Distance, true >
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename T, typename Distance, bool IsIterator = is_iterator< T >::value >
|
template< typename T, typename Distance, bool IsIterator = boost::iterators::is_iterator< T >::value >
|
||||||
struct next_advance_impl :
|
struct next_advance_impl :
|
||||||
public next_plus_assign_impl< T, Distance >
|
public next_plus_assign_impl< T, Distance >
|
||||||
{
|
{
|
||||||
@@ -152,7 +111,7 @@ struct prior_minus_assign_impl< T, Distance, true >
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename T, typename Distance, bool IsIterator = is_iterator< T >::value >
|
template< typename T, typename Distance, bool IsIterator = boost::iterators::is_iterator< T >::value >
|
||||||
struct prior_advance_impl :
|
struct prior_advance_impl :
|
||||||
public prior_minus_assign_impl< T, Distance >
|
public prior_minus_assign_impl< T, Distance >
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
# include <iterator>
|
# include <iterator>
|
||||||
# include <boost/static_assert.hpp>
|
# include <boost/static_assert.hpp>
|
||||||
# include <boost/concept_archetype.hpp> // for detail::dummy_constructor
|
# include <boost/concept_archetype.hpp> // for detail::dummy_constructor
|
||||||
# include <boost/implicit_cast.hpp>
|
|
||||||
# include <boost/core/ignore_unused.hpp>
|
# include <boost/core/ignore_unused.hpp>
|
||||||
# include <boost/core/lightweight_test.hpp>
|
# include <boost/core/lightweight_test.hpp>
|
||||||
# include <boost/type_traits/is_same.hpp>
|
# include <boost/type_traits/is_same.hpp>
|
||||||
@@ -180,7 +179,7 @@ void forward_iterator_test(Iterator i, T v1, T v2)
|
|||||||
trivial_iterator_test(i, i2, v2);
|
trivial_iterator_test(i, i2, v2);
|
||||||
|
|
||||||
// borland doesn't allow non-type template parameters
|
// borland doesn't allow non-type template parameters
|
||||||
# if !defined(__BORLANDC__) || (__BORLANDC__ > 0x551)
|
# if !defined(BOOST_BORLANDC) || (BOOST_BORLANDC > 0x551)
|
||||||
lvalue_test<(boost::is_pointer<Iterator>::value)>::check(i);
|
lvalue_test<(boost::is_pointer<Iterator>::value)>::check(i);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -223,12 +222,15 @@ void random_access_iterator_test(Iterator i, int N, TrueVals vals)
|
|||||||
int c;
|
int c;
|
||||||
|
|
||||||
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
typedef typename std::iterator_traits<Iterator>::value_type value_type;
|
||||||
boost::ignore_unused<value_type>();
|
struct local
|
||||||
|
{
|
||||||
|
static value_type to_value_type(value_type v) { return v; }
|
||||||
|
};
|
||||||
|
|
||||||
for (c = 0; c < N-1; ++c) {
|
for (c = 0; c < N-1; ++c) {
|
||||||
BOOST_TEST(i == j + c);
|
BOOST_TEST(i == j + c);
|
||||||
BOOST_TEST(*i == vals[c]);
|
BOOST_TEST(*i == vals[c]);
|
||||||
BOOST_TEST(*i == boost::implicit_cast<value_type>(j[c]));
|
BOOST_TEST(*i == local::to_value_type(j[c]));
|
||||||
BOOST_TEST(*i == *(j + c));
|
BOOST_TEST(*i == *(j + c));
|
||||||
BOOST_TEST(*i == *(c + j));
|
BOOST_TEST(*i == *(c + j));
|
||||||
++i;
|
++i;
|
||||||
@@ -242,7 +244,7 @@ void random_access_iterator_test(Iterator i, int N, TrueVals vals)
|
|||||||
for (c = 0; c < N-1; ++c) {
|
for (c = 0; c < N-1; ++c) {
|
||||||
BOOST_TEST(i == k - c);
|
BOOST_TEST(i == k - c);
|
||||||
BOOST_TEST(*i == vals[N - 1 - c]);
|
BOOST_TEST(*i == vals[N - 1 - c]);
|
||||||
BOOST_TEST(*i == boost::implicit_cast<value_type>(j[N - 1 - c]));
|
BOOST_TEST(*i == local::to_value_type(j[N - 1 - c]));
|
||||||
Iterator q = k - c;
|
Iterator q = k - c;
|
||||||
boost::ignore_unused(q);
|
boost::ignore_unused(q);
|
||||||
BOOST_TEST(*i == *q);
|
BOOST_TEST(*i == *q);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace detail
|
|||||||
BOOST_STATIC_CONSTANT(bool, is_constant = sizeof(impl::test(*impl::x)) == 1);
|
BOOST_STATIC_CONSTANT(bool, is_constant = sizeof(impl::test(*impl::x)) == 1);
|
||||||
|
|
||||||
typedef typename mpl::if_c<
|
typedef typename mpl::if_c<
|
||||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
# if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
|
||||||
::boost::detail::iterator_pointee<Iterator>::is_constant
|
::boost::detail::iterator_pointee<Iterator>::is_constant
|
||||||
# else
|
# else
|
||||||
is_constant
|
is_constant
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
// See http://www.boost.org/libs/utility/shared_container_iterator.html for documentation.
|
// See http://www.boost.org/libs/utility/shared_container_iterator.html for documentation.
|
||||||
|
|
||||||
#ifndef SHARED_CONTAINER_ITERATOR_RG08102002_HPP
|
#ifndef BOOST_SHARED_CONTAINER_ITERATOR_HPP
|
||||||
#define SHARED_CONTAINER_ITERATOR_RG08102002_HPP
|
#define BOOST_SHARED_CONTAINER_ITERATOR_HPP
|
||||||
|
|
||||||
#include "boost/iterator_adaptors.hpp"
|
#include "boost/iterator_adaptors.hpp"
|
||||||
#include "boost/shared_ptr.hpp"
|
#include "boost/shared_ptr.hpp"
|
||||||
@@ -66,4 +66,4 @@ using iterators::make_shared_container_range;
|
|||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif // SHARED_CONTAINER_ITERATOR_RG08102002_HPP
|
#endif
|
||||||
|
|||||||
+2
-1
@@ -14,5 +14,6 @@
|
|||||||
"David Abrahams <dave -at- boost-consulting.com>",
|
"David Abrahams <dave -at- boost-consulting.com>",
|
||||||
"Thomas Witt <witt - at - acm.org>",
|
"Thomas Witt <witt - at - acm.org>",
|
||||||
"Jeffrey Lee Hellrung Jr. <jeffrey.hellrung -at- gmail.com>"
|
"Jeffrey Lee Hellrung Jr. <jeffrey.hellrung -at- gmail.com>"
|
||||||
]
|
],
|
||||||
|
"cxxstd": "03"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ test-suite iterator
|
|||||||
[ run zip_iterator_test_std_tuple.cpp ]
|
[ run zip_iterator_test_std_tuple.cpp ]
|
||||||
[ run zip_iterator_test_std_pair.cpp ]
|
[ run zip_iterator_test_std_pair.cpp ]
|
||||||
|
|
||||||
|
[ run is_iterator.cpp ]
|
||||||
|
|
||||||
# These tests should work for just about everything.
|
# These tests should work for just about everything.
|
||||||
[ compile is_lvalue_iterator.cpp ]
|
[ compile is_lvalue_iterator.cpp ]
|
||||||
[ compile is_readable_iterator.cpp ]
|
[ compile is_readable_iterator.cpp ]
|
||||||
@@ -50,6 +52,8 @@ test-suite iterator
|
|||||||
[ run permutation_iterator_test.cpp : : : # <stlport-iostream>on
|
[ run permutation_iterator_test.cpp : : : # <stlport-iostream>on
|
||||||
]
|
]
|
||||||
[ run function_input_iterator_test.cpp ]
|
[ run function_input_iterator_test.cpp ]
|
||||||
|
[ run function_output_iterator_test.cpp ]
|
||||||
|
[ compile-fail function_output_iterator_cf.cpp ]
|
||||||
|
|
||||||
[ run generator_iterator_test.cpp ]
|
[ run generator_iterator_test.cpp ]
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ main()
|
|||||||
boost::iterator_traversal<new_iterator>::type tc;
|
boost::iterator_traversal<new_iterator>::type tc;
|
||||||
boost::random_access_traversal_tag derived = tc;
|
boost::random_access_traversal_tag derived = tc;
|
||||||
(void)derived;
|
(void)derived;
|
||||||
|
|
||||||
boost::function_requires<
|
boost::function_requires<
|
||||||
boost_concepts::WritableIteratorConcept<int*> >();
|
boost_concepts::WritableIteratorConcept<int*> >();
|
||||||
boost::function_requires<
|
boost::function_requires<
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
#ifdef __BORLANDC__ // Borland mis-detects our custom iterators
|
#ifdef BOOST_BORLANDC // Borland mis-detects our custom iterators
|
||||||
# pragma warn -8091 // template argument ForwardIterator passed to '...' is a output iterator
|
# pragma warn -8091 // template argument ForwardIterator passed to '...' is a output iterator
|
||||||
# pragma warn -8071 // Conversion may lose significant digits (due to counting_iterator<char> += n).
|
# pragma warn -8071 // Conversion may lose significant digits (due to counting_iterator<char> += n).
|
||||||
#endif
|
#endif
|
||||||
@@ -26,13 +26,11 @@
|
|||||||
# pragma warning(disable:4786) // identifier truncated in debug info
|
# pragma warning(disable:4786) // identifier truncated in debug info
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/detail/iterator.hpp>
|
|
||||||
#include <boost/iterator/counting_iterator.hpp>
|
#include <boost/iterator/counting_iterator.hpp>
|
||||||
#include <boost/iterator/new_iterator_tests.hpp>
|
#include <boost/iterator/new_iterator_tests.hpp>
|
||||||
|
|
||||||
#include <boost/next_prior.hpp>
|
#include <boost/next_prior.hpp>
|
||||||
#include <boost/mpl/if.hpp>
|
#include <boost/type_traits/conditional.hpp>
|
||||||
#include <boost/detail/iterator.hpp>
|
|
||||||
#include <boost/detail/workaround.hpp>
|
#include <boost/detail/workaround.hpp>
|
||||||
#include <boost/limits.hpp>
|
#include <boost/limits.hpp>
|
||||||
|
|
||||||
@@ -40,12 +38,12 @@
|
|||||||
#include <climits>
|
#include <climits>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifndef __BORLANDC__
|
#ifndef BOOST_BORLANDC
|
||||||
# include <boost/tuple/tuple.hpp>
|
# include <boost/tuple/tuple.hpp>
|
||||||
#endif
|
#endif
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#ifndef BOOST_NO_SLIST
|
#ifndef BOOST_NO_SLIST
|
||||||
# ifdef BOOST_SLIST_HEADER
|
# ifdef BOOST_SLIST_HEADER
|
||||||
# include BOOST_SLIST_HEADER
|
# include BOOST_SLIST_HEADER
|
||||||
@@ -70,7 +68,7 @@ struct unsigned_assert_nonnegative
|
|||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct assert_nonnegative
|
struct assert_nonnegative
|
||||||
: boost::mpl::if_c<
|
: boost::conditional<
|
||||||
std::numeric_limits<T>::is_signed
|
std::numeric_limits<T>::is_signed
|
||||||
, signed_assert_nonnegative<T>
|
, signed_assert_nonnegative<T>
|
||||||
, unsigned_assert_nonnegative<T>
|
, unsigned_assert_nonnegative<T>
|
||||||
@@ -88,19 +86,19 @@ void category_test(
|
|||||||
std::random_access_iterator_tag)
|
std::random_access_iterator_tag)
|
||||||
{
|
{
|
||||||
typedef typename
|
typedef typename
|
||||||
boost::detail::iterator_traits<CountingIterator>::difference_type
|
std::iterator_traits<CountingIterator>::difference_type
|
||||||
difference_type;
|
difference_type;
|
||||||
difference_type distance = boost::detail::distance(start, finish);
|
difference_type distance = std::distance(start, finish);
|
||||||
|
|
||||||
// Pick a random position internal to the range
|
// Pick a random position internal to the range
|
||||||
difference_type offset = (unsigned)rand() % distance;
|
difference_type offset = (unsigned)rand() % distance;
|
||||||
|
|
||||||
#ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
#ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||||
BOOST_TEST(offset >= 0);
|
BOOST_TEST(offset >= 0);
|
||||||
#else
|
#else
|
||||||
assert_nonnegative<difference_type>::test(offset);
|
assert_nonnegative<difference_type>::test(offset);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CountingIterator internal = start;
|
CountingIterator internal = start;
|
||||||
std::advance(internal, offset);
|
std::advance(internal, offset);
|
||||||
|
|
||||||
@@ -111,8 +109,8 @@ void category_test(
|
|||||||
std::pair<CountingIterator,CountingIterator> xy(
|
std::pair<CountingIterator,CountingIterator> xy(
|
||||||
std::equal_range(start, finish, *internal));
|
std::equal_range(start, finish, *internal));
|
||||||
CountingIterator x = xy.first, y = xy.second;
|
CountingIterator x = xy.first, y = xy.second;
|
||||||
|
|
||||||
BOOST_TEST(boost::detail::distance(x, y) == 1);
|
BOOST_TEST(std::distance(x, y) == 1);
|
||||||
|
|
||||||
// Show that values outside the range can't be found
|
// Show that values outside the range can't be found
|
||||||
BOOST_TEST(!std::binary_search(start, boost::prior(finish), *finish));
|
BOOST_TEST(!std::binary_search(start, boost::prior(finish), *finish));
|
||||||
@@ -122,7 +120,7 @@ void category_test(
|
|||||||
std::vector<value_type> v;
|
std::vector<value_type> v;
|
||||||
for (value_type z = *start; !(z == *finish); ++z)
|
for (value_type z = *start; !(z == *finish); ++z)
|
||||||
v.push_back(z);
|
v.push_back(z);
|
||||||
|
|
||||||
// Note that this test requires a that the first argument is
|
// Note that this test requires a that the first argument is
|
||||||
// dereferenceable /and/ a valid iterator prior to the first argument
|
// dereferenceable /and/ a valid iterator prior to the first argument
|
||||||
boost::random_access_iterator_test(start, v.size(), v.begin());
|
boost::random_access_iterator_test(start, v.size(), v.begin());
|
||||||
@@ -200,11 +198,11 @@ void test_container(Container* = 0) // default arg works around MSVC bug
|
|||||||
Container c(1 + (unsigned)rand() % 1673);
|
Container c(1 + (unsigned)rand() % 1673);
|
||||||
|
|
||||||
const typename Container::iterator start = c.begin();
|
const typename Container::iterator start = c.begin();
|
||||||
|
|
||||||
// back off by 1 to leave room for dereferenceable value at the end
|
// back off by 1 to leave room for dereferenceable value at the end
|
||||||
typename Container::iterator finish = start;
|
typename Container::iterator finish = start;
|
||||||
std::advance(finish, c.size() - 1);
|
std::advance(finish, c.size() - 1);
|
||||||
|
|
||||||
test(start, finish);
|
test(start, finish);
|
||||||
|
|
||||||
typedef typename Container::const_iterator const_iterator;
|
typedef typename Container::const_iterator const_iterator;
|
||||||
@@ -273,8 +271,12 @@ int main()
|
|||||||
test_integer<long>();
|
test_integer<long>();
|
||||||
test_integer<unsigned long>();
|
test_integer<unsigned long>();
|
||||||
#if defined(BOOST_HAS_LONG_LONG)
|
#if defined(BOOST_HAS_LONG_LONG)
|
||||||
test_integer< ::boost::long_long_type>();
|
test_integer<boost::long_long_type>();
|
||||||
test_integer< ::boost::ulong_long_type>();
|
test_integer<boost::ulong_long_type>();
|
||||||
|
#endif
|
||||||
|
#if defined(BOOST_HAS_INT128)
|
||||||
|
test_integer<boost::int128_type>();
|
||||||
|
test_integer<boost::uint128_type>();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Test user-defined type.
|
// Test user-defined type.
|
||||||
@@ -283,14 +285,14 @@ int main()
|
|||||||
test_integer3<long, std::random_access_iterator_tag, int>();
|
test_integer3<long, std::random_access_iterator_tag, int>();
|
||||||
test_integer<my_int2>();
|
test_integer<my_int2>();
|
||||||
test_integer<my_int3>();
|
test_integer<my_int3>();
|
||||||
|
|
||||||
// Some tests on container iterators, to prove we handle a few different categories
|
// Some tests on container iterators, to prove we handle a few different categories
|
||||||
test_container<std::vector<int> >();
|
test_container<std::vector<int> >();
|
||||||
test_container<std::list<int> >();
|
test_container<std::list<int> >();
|
||||||
# ifndef BOOST_NO_SLIST
|
# ifndef BOOST_NO_SLIST
|
||||||
test_container<BOOST_STD_EXTENSION_NAMESPACE::slist<int> >();
|
test_container<BOOST_STD_EXTENSION_NAMESPACE::slist<int> >();
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// Also prove that we can handle raw pointers.
|
// Also prove that we can handle raw pointers.
|
||||||
int array[2000];
|
int array[2000];
|
||||||
test(boost::make_counting_iterator(array), boost::make_counting_iterator(array+2000-1));
|
test(boost::make_counting_iterator(array), boost::make_counting_iterator(array+2000-1));
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
//
|
//
|
||||||
// See http://www.boost.org for most recent version including documentation.
|
// See http://www.boost.org for most recent version including documentation.
|
||||||
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
#include <boost/assign/list_of.hpp>
|
#include <boost/assign/list_of.hpp>
|
||||||
#include <boost/fusion/include/at.hpp>
|
#include <boost/fusion/include/at.hpp>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright David Abrahams 2003, Jeremy Siek 2004.
|
// Copyright David Abrahams 2003, Jeremy Siek 2004.
|
||||||
|
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using boost::dummyT;
|
using boost::dummyT;
|
||||||
|
|
||||||
struct one_or_four
|
struct one_or_four
|
||||||
{
|
{
|
||||||
bool operator()(dummyT x) const
|
bool operator()(dummyT x) const
|
||||||
@@ -116,7 +116,7 @@ int main()
|
|||||||
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
|
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
|
||||||
boost::function_requires< boost_concepts::SinglePassIteratorConcept<Iter> >();
|
boost::function_requires< boost_concepts::SinglePassIteratorConcept<Iter> >();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
typedef boost::iterator_archetype<
|
typedef boost::iterator_archetype<
|
||||||
const dummyT
|
const dummyT
|
||||||
@@ -128,7 +128,7 @@ int main()
|
|||||||
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||||
boost::function_requires< boost_concepts::ForwardTraversalConcept<Iter> >();
|
boost::function_requires< boost_concepts::ForwardTraversalConcept<Iter> >();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !BOOST_WORKAROUND(BOOST_MSVC, == 1200) // Causes Internal Error in linker.
|
#if !BOOST_WORKAROUND(BOOST_MSVC, == 1200) // Causes Internal Error in linker.
|
||||||
{
|
{
|
||||||
typedef boost::iterator_archetype<
|
typedef boost::iterator_archetype<
|
||||||
@@ -165,7 +165,7 @@ int main()
|
|||||||
boost::function_requires< boost_concepts::LvalueIteratorConcept<Iter> >();
|
boost::function_requires< boost_concepts::LvalueIteratorConcept<Iter> >();
|
||||||
boost::function_requires< boost_concepts::ForwardTraversalConcept<Iter> >();
|
boost::function_requires< boost_concepts::ForwardTraversalConcept<Iter> >();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
typedef boost::iterator_archetype<
|
typedef boost::iterator_archetype<
|
||||||
@@ -178,7 +178,7 @@ int main()
|
|||||||
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||||
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !BOOST_WORKAROUND(BOOST_MSVC, == 1200) // Causes Internal Error in linker.
|
#if !BOOST_WORKAROUND(BOOST_MSVC, == 1200) // Causes Internal Error in linker.
|
||||||
{
|
{
|
||||||
typedef boost::iterator_archetype<
|
typedef boost::iterator_archetype<
|
||||||
@@ -215,11 +215,11 @@ int main()
|
|||||||
boost::function_requires< boost_concepts::LvalueIteratorConcept<Iter> >();
|
boost::function_requires< boost_concepts::LvalueIteratorConcept<Iter> >();
|
||||||
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Run-time tests
|
// Run-time tests
|
||||||
|
|
||||||
dummyT array[] = { dummyT(0), dummyT(1), dummyT(2),
|
dummyT array[] = { dummyT(0), dummyT(1), dummyT(2),
|
||||||
dummyT(3), dummyT(4), dummyT(5) };
|
dummyT(3), dummyT(4), dummyT(5) };
|
||||||
const int N = sizeof(array)/sizeof(dummyT);
|
const int N = sizeof(array)/sizeof(dummyT);
|
||||||
|
|
||||||
@@ -235,9 +235,9 @@ int main()
|
|||||||
, boost::random_access_traversal_tag
|
, boost::random_access_traversal_tag
|
||||||
>::value
|
>::value
|
||||||
));
|
));
|
||||||
|
|
||||||
//# endif
|
//# endif
|
||||||
|
|
||||||
// On compilers not supporting partial specialization, we can do more type
|
// On compilers not supporting partial specialization, we can do more type
|
||||||
// deduction with deque iterators than with pointers... unless the library
|
// deduction with deque iterators than with pointers... unless the library
|
||||||
// is broken ;-(
|
// is broken ;-(
|
||||||
@@ -258,7 +258,7 @@ int main()
|
|||||||
, boost::make_reverse_iterator(array2.begin())
|
, boost::make_reverse_iterator(array2.begin())
|
||||||
),
|
),
|
||||||
dummyT(4), dummyT(1));
|
dummyT(4), dummyT(1));
|
||||||
|
|
||||||
boost::bidirectional_readable_iterator_test(
|
boost::bidirectional_readable_iterator_test(
|
||||||
filter_iter(array+0, array+N),
|
filter_iter(array+0, array+N),
|
||||||
dummyT(1), dummyT(4));
|
dummyT(1), dummyT(4));
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ int main()
|
|||||||
ones ones_generator;
|
ones ones_generator;
|
||||||
vector<int> values(10);
|
vector<int> values(10);
|
||||||
generate(values.begin(), values.end(), ones());
|
generate(values.begin(), values.end(), ones());
|
||||||
|
|
||||||
vector<int> generated;
|
vector<int> generated;
|
||||||
copy(
|
copy(
|
||||||
boost::make_function_input_iterator(ones_generator, 0),
|
boost::make_function_input_iterator(ones_generator, 0),
|
||||||
@@ -99,6 +99,15 @@ int main()
|
|||||||
for(std::size_t i = 0; i != 10; ++i)
|
for(std::size_t i = 0; i != 10; ++i)
|
||||||
BOOST_TEST_EQ(generated[i], static_cast<int>(42 + i));
|
BOOST_TEST_EQ(generated[i], static_cast<int>(42 + i));
|
||||||
|
|
||||||
|
// Test that incrementing the iterator returns a reference to the iterator type
|
||||||
|
{
|
||||||
|
typedef boost::iterators::function_input_iterator<counter, int> function_counter_iterator_t;
|
||||||
|
function_counter_iterator_t it1(counter_generator, 0);
|
||||||
|
function_counter_iterator_t it2(++it1);
|
||||||
|
function_counter_iterator_t it3(it2++);
|
||||||
|
BOOST_TEST_EQ(*it3, 54);
|
||||||
|
}
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_LAMBDAS) && !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) \
|
#if !defined(BOOST_NO_CXX11_LAMBDAS) && !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) \
|
||||||
&& defined(BOOST_RESULT_OF_USE_DECLTYPE)
|
&& defined(BOOST_RESULT_OF_USE_DECLTYPE)
|
||||||
// test the iterator with lambda expressions
|
// test the iterator with lambda expressions
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
// Copyright 2022 (c) Andrey Semashev
|
||||||
|
// 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)
|
||||||
|
|
||||||
|
#include <boost/iterator/function_output_iterator.hpp>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
struct sum_func
|
||||||
|
{
|
||||||
|
typedef void result_type;
|
||||||
|
|
||||||
|
explicit sum_func(int& n) : m_n(n) {}
|
||||||
|
result_type operator() (int x) const
|
||||||
|
{
|
||||||
|
m_n += x;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int& m_n;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int n = 0;
|
||||||
|
boost::iterators::function_output_iterator< sum_func > it1 =
|
||||||
|
boost::iterators::make_function_output_iterator(sum_func(n));
|
||||||
|
boost::iterators::function_output_iterator< sum_func > it2 =
|
||||||
|
boost::iterators::make_function_output_iterator(sum_func(n));
|
||||||
|
|
||||||
|
*it1 = *it2;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
// Copyright 2022 (c) Andrey Semashev
|
||||||
|
// 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)
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <boost/iterator/function_output_iterator.hpp>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
struct sum_func
|
||||||
|
{
|
||||||
|
typedef void result_type;
|
||||||
|
|
||||||
|
explicit sum_func(int& n) : m_n(n) {}
|
||||||
|
result_type operator() (int x) const
|
||||||
|
{
|
||||||
|
m_n += x;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int& m_n;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
int n = 0;
|
||||||
|
boost::iterators::function_output_iterator< sum_func > it =
|
||||||
|
boost::iterators::make_function_output_iterator(sum_func(n));
|
||||||
|
|
||||||
|
*it = 1;
|
||||||
|
++it;
|
||||||
|
*it = 2;
|
||||||
|
++it;
|
||||||
|
*it = 3;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ(n, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_LAMBDAS) && !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS)
|
||||||
|
{
|
||||||
|
int n = 0;
|
||||||
|
auto it = boost::iterators::make_function_output_iterator([&n](int x) { n -= x; });
|
||||||
|
|
||||||
|
*it = 1;
|
||||||
|
++it;
|
||||||
|
*it = 2;
|
||||||
|
++it;
|
||||||
|
*it = 3;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ(n, -6);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <boost/generator_iterator.hpp>
|
#include <boost/generator_iterator.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
class X
|
class X
|
||||||
|
|||||||
@@ -30,16 +30,16 @@ struct my_ptr {
|
|||||||
|
|
||||||
// Borland 5.6.4 and earlier drop const all over the place, so this
|
// Borland 5.6.4 and earlier drop const all over the place, so this
|
||||||
// test will fail in the lines marked with (**)
|
// test will fail in the lines marked with (**)
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
typedef boost::indirect_iterator<int**> Iter;
|
typedef boost::indirect_iterator<int**> Iter;
|
||||||
STATIC_ASSERT_SAME(Iter::value_type, int);
|
STATIC_ASSERT_SAME(Iter::value_type, int);
|
||||||
STATIC_ASSERT_SAME(Iter::reference, int&);
|
STATIC_ASSERT_SAME(Iter::reference, int&);
|
||||||
STATIC_ASSERT_SAME(Iter::pointer, int*);
|
STATIC_ASSERT_SAME(Iter::pointer, int*);
|
||||||
STATIC_ASSERT_SAME(Iter::difference_type, std::ptrdiff_t);
|
STATIC_ASSERT_SAME(Iter::difference_type, std::ptrdiff_t);
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT((boost::is_convertible<Iter::iterator_category,
|
BOOST_STATIC_ASSERT((boost::is_convertible<Iter::iterator_category,
|
||||||
std::random_access_iterator_tag>::value));
|
std::random_access_iterator_tag>::value));
|
||||||
BOOST_STATIC_ASSERT((boost::is_convertible<boost::iterator_traversal<Iter>::type,
|
BOOST_STATIC_ASSERT((boost::is_convertible<boost::iterator_traversal<Iter>::type,
|
||||||
@@ -54,13 +54,13 @@ int main()
|
|||||||
{
|
{
|
||||||
typedef boost::indirect_iterator<int**, int> Iter;
|
typedef boost::indirect_iterator<int**, int> Iter;
|
||||||
STATIC_ASSERT_SAME(Iter::value_type, int);
|
STATIC_ASSERT_SAME(Iter::value_type, int);
|
||||||
STATIC_ASSERT_SAME(Iter::reference, int&);
|
STATIC_ASSERT_SAME(Iter::reference, int&);
|
||||||
STATIC_ASSERT_SAME(Iter::pointer, int*);
|
STATIC_ASSERT_SAME(Iter::pointer, int*);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
typedef boost::indirect_iterator<int**, const int> Iter;
|
typedef boost::indirect_iterator<int**, const int> Iter;
|
||||||
STATIC_ASSERT_SAME(Iter::value_type, int);
|
STATIC_ASSERT_SAME(Iter::value_type, int);
|
||||||
STATIC_ASSERT_SAME(Iter::reference, const int&);
|
STATIC_ASSERT_SAME(Iter::reference, const int&);
|
||||||
STATIC_ASSERT_SAME(Iter::pointer, const int*); // (**)
|
STATIC_ASSERT_SAME(Iter::pointer, const int*); // (**)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -68,9 +68,9 @@ int main()
|
|||||||
STATIC_ASSERT_SAME(Iter::value_type, zow);
|
STATIC_ASSERT_SAME(Iter::value_type, zow);
|
||||||
STATIC_ASSERT_SAME(Iter::reference, const zow&); // (**)
|
STATIC_ASSERT_SAME(Iter::reference, const zow&); // (**)
|
||||||
STATIC_ASSERT_SAME(Iter::pointer, const zow*); // (**)
|
STATIC_ASSERT_SAME(Iter::pointer, const zow*); // (**)
|
||||||
|
|
||||||
STATIC_ASSERT_SAME(Iter::difference_type, std::ptrdiff_t);
|
STATIC_ASSERT_SAME(Iter::difference_type, std::ptrdiff_t);
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT((boost::is_convertible<Iter::iterator_category,
|
BOOST_STATIC_ASSERT((boost::is_convertible<Iter::iterator_category,
|
||||||
std::random_access_iterator_tag>::value));
|
std::random_access_iterator_tag>::value));
|
||||||
BOOST_STATIC_ASSERT((boost::is_convertible<boost::iterator_traversal<Iter>::type,
|
BOOST_STATIC_ASSERT((boost::is_convertible<boost::iterator_traversal<Iter>::type,
|
||||||
@@ -79,9 +79,9 @@ int main()
|
|||||||
{
|
{
|
||||||
typedef boost::indirect_iterator<char**, int, std::random_access_iterator_tag, long&, short> Iter;
|
typedef boost::indirect_iterator<char**, int, std::random_access_iterator_tag, long&, short> Iter;
|
||||||
STATIC_ASSERT_SAME(Iter::value_type, int);
|
STATIC_ASSERT_SAME(Iter::value_type, int);
|
||||||
STATIC_ASSERT_SAME(Iter::reference, long&);
|
STATIC_ASSERT_SAME(Iter::reference, long&);
|
||||||
STATIC_ASSERT_SAME(Iter::pointer, int*);
|
STATIC_ASSERT_SAME(Iter::pointer, int*);
|
||||||
STATIC_ASSERT_SAME(Iter::difference_type, short);
|
STATIC_ASSERT_SAME(Iter::difference_type, short);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include <boost/mpl/has_xxx.hpp>
|
#include <boost/mpl/has_xxx.hpp>
|
||||||
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
// interoperability (but may support const/mutable interop).
|
// interoperability (but may support const/mutable interop).
|
||||||
# define NO_MUTABLE_CONST_STD_SET_ITERATOR_INTEROPERABILITY
|
# define NO_MUTABLE_CONST_STD_SET_ITERATOR_INTEROPERABILITY
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
template <class T> struct see_type;
|
template <class T> struct see_type;
|
||||||
@@ -53,7 +53,7 @@ template <int I> struct see_val;
|
|||||||
struct my_iterator_tag : public std::random_access_iterator_tag { };
|
struct my_iterator_tag : public std::random_access_iterator_tag { };
|
||||||
|
|
||||||
using boost::dummyT;
|
using boost::dummyT;
|
||||||
|
|
||||||
typedef std::vector<int> storage;
|
typedef std::vector<int> storage;
|
||||||
typedef std::vector<int*> pointer_ra_container;
|
typedef std::vector<int*> pointer_ra_container;
|
||||||
typedef std::set<storage::iterator> iterator_set;
|
typedef std::set<storage::iterator> iterator_set;
|
||||||
@@ -62,7 +62,7 @@ template <class Container>
|
|||||||
struct indirect_iterator_pair_generator
|
struct indirect_iterator_pair_generator
|
||||||
{
|
{
|
||||||
typedef boost::indirect_iterator<typename Container::iterator> iterator;
|
typedef boost::indirect_iterator<typename Container::iterator> iterator;
|
||||||
|
|
||||||
typedef boost::indirect_iterator<
|
typedef boost::indirect_iterator<
|
||||||
typename Container::iterator
|
typename Container::iterator
|
||||||
, typename iterator::value_type const
|
, typename iterator::value_type const
|
||||||
@@ -73,7 +73,7 @@ void more_indirect_iterator_tests()
|
|||||||
{
|
{
|
||||||
storage store(1000);
|
storage store(1000);
|
||||||
std::generate(store.begin(), store.end(), rand);
|
std::generate(store.begin(), store.end(), rand);
|
||||||
|
|
||||||
pointer_ra_container ptr_ra_container;
|
pointer_ra_container ptr_ra_container;
|
||||||
iterator_set iter_set;
|
iterator_set iter_set;
|
||||||
|
|
||||||
@@ -90,27 +90,27 @@ void more_indirect_iterator_tests()
|
|||||||
BOOST_TEST(static_cast<std::size_t>(de - db) == store.size());
|
BOOST_TEST(static_cast<std::size_t>(de - db) == store.size());
|
||||||
BOOST_TEST(db + store.size() == de);
|
BOOST_TEST(db + store.size() == de);
|
||||||
indirect_ra_container::const_iterator dci = db;
|
indirect_ra_container::const_iterator dci = db;
|
||||||
|
|
||||||
BOOST_TEST(dci == db);
|
BOOST_TEST(dci == db);
|
||||||
|
|
||||||
#ifndef NO_MUTABLE_CONST_RA_ITERATOR_INTEROPERABILITY
|
#ifndef NO_MUTABLE_CONST_RA_ITERATOR_INTEROPERABILITY
|
||||||
BOOST_TEST(db == dci);
|
BOOST_TEST(db == dci);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BOOST_TEST(dci != de);
|
BOOST_TEST(dci != de);
|
||||||
BOOST_TEST(dci < de);
|
BOOST_TEST(dci < de);
|
||||||
BOOST_TEST(dci <= de);
|
BOOST_TEST(dci <= de);
|
||||||
|
|
||||||
#ifndef NO_MUTABLE_CONST_RA_ITERATOR_INTEROPERABILITY
|
#ifndef NO_MUTABLE_CONST_RA_ITERATOR_INTEROPERABILITY
|
||||||
BOOST_TEST(de >= dci);
|
BOOST_TEST(de >= dci);
|
||||||
BOOST_TEST(de > dci);
|
BOOST_TEST(de > dci);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dci = de;
|
dci = de;
|
||||||
BOOST_TEST(dci == de);
|
BOOST_TEST(dci == de);
|
||||||
|
|
||||||
boost::random_access_iterator_test(db + 1, store.size() - 1, boost::next(store.begin()));
|
boost::random_access_iterator_test(db + 1, store.size() - 1, boost::next(store.begin()));
|
||||||
|
|
||||||
*db = 999;
|
*db = 999;
|
||||||
BOOST_TEST(store.front() == 999);
|
BOOST_TEST(store.front() == 999);
|
||||||
|
|
||||||
@@ -125,15 +125,15 @@ void more_indirect_iterator_tests()
|
|||||||
indirect_set_iterator se(iter_set.end());
|
indirect_set_iterator se(iter_set.end());
|
||||||
const_indirect_set_iterator sci(iter_set.begin());
|
const_indirect_set_iterator sci(iter_set.begin());
|
||||||
BOOST_TEST(sci == sb);
|
BOOST_TEST(sci == sb);
|
||||||
|
|
||||||
# ifndef NO_MUTABLE_CONST_STD_SET_ITERATOR_INTEROPERABILITY
|
# ifndef NO_MUTABLE_CONST_STD_SET_ITERATOR_INTEROPERABILITY
|
||||||
BOOST_TEST(se != sci);
|
BOOST_TEST(se != sci);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
BOOST_TEST(sci != se);
|
BOOST_TEST(sci != se);
|
||||||
sci = se;
|
sci = se;
|
||||||
BOOST_TEST(sci == se);
|
BOOST_TEST(sci == se);
|
||||||
|
|
||||||
*boost::prior(se) = 888;
|
*boost::prior(se) = 888;
|
||||||
BOOST_TEST(store.back() == 888);
|
BOOST_TEST(store.back() == 888);
|
||||||
BOOST_TEST(std::equal(sb, se, store.begin()));
|
BOOST_TEST(std::equal(sb, se, store.begin()));
|
||||||
@@ -145,21 +145,21 @@ void more_indirect_iterator_tests()
|
|||||||
// element_type detector; defaults to true so the test passes when
|
// element_type detector; defaults to true so the test passes when
|
||||||
// has_xxx isn't implemented
|
// has_xxx isn't implemented
|
||||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_element_type, element_type, true)
|
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_element_type, element_type, true)
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
dummyT array[] = { dummyT(0), dummyT(1), dummyT(2),
|
dummyT array[] = { dummyT(0), dummyT(1), dummyT(2),
|
||||||
dummyT(3), dummyT(4), dummyT(5) };
|
dummyT(3), dummyT(4), dummyT(5) };
|
||||||
const int N = sizeof(array)/sizeof(dummyT);
|
const int N = sizeof(array)/sizeof(dummyT);
|
||||||
|
|
||||||
# if BOOST_WORKAROUND(BOOST_MSVC, == 1200)
|
# if BOOST_WORKAROUND(BOOST_MSVC, == 1200)
|
||||||
boost::shared_ptr<dummyT> zz((dummyT*)0); // Why? I don't know, but it suppresses a bad instantiation.
|
boost::shared_ptr<dummyT> zz((dummyT*)0); // Why? I don't know, but it suppresses a bad instantiation.
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
typedef std::vector<boost::shared_ptr<dummyT> > shared_t;
|
typedef std::vector<boost::shared_ptr<dummyT> > shared_t;
|
||||||
shared_t shared;
|
shared_t shared;
|
||||||
|
|
||||||
// Concept checks
|
// Concept checks
|
||||||
{
|
{
|
||||||
typedef boost::indirect_iterator<shared_t::iterator> iter_t;
|
typedef boost::indirect_iterator<shared_t::iterator> iter_t;
|
||||||
@@ -169,7 +169,7 @@ main()
|
|||||||
std::iterator_traits<shared_t::iterator>::value_type
|
std::iterator_traits<shared_t::iterator>::value_type
|
||||||
>::value
|
>::value
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef boost::indirect_iterator<
|
typedef boost::indirect_iterator<
|
||||||
shared_t::iterator
|
shared_t::iterator
|
||||||
, boost::iterator_value<shared_t::iterator>::type const
|
, boost::iterator_value<shared_t::iterator>::type const
|
||||||
@@ -177,14 +177,14 @@ main()
|
|||||||
|
|
||||||
# ifndef NO_MUTABLE_CONST_RA_ITERATOR_INTEROPERABILITY
|
# ifndef NO_MUTABLE_CONST_RA_ITERATOR_INTEROPERABILITY
|
||||||
boost::function_requires< boost_concepts::InteroperableIteratorConcept<iter_t, c_iter_t> >();
|
boost::function_requires< boost_concepts::InteroperableIteratorConcept<iter_t, c_iter_t> >();
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test indirect_iterator_generator
|
// Test indirect_iterator_generator
|
||||||
{
|
{
|
||||||
for (int jj = 0; jj < N; ++jj)
|
for (int jj = 0; jj < N; ++jj)
|
||||||
shared.push_back(boost::shared_ptr<dummyT>(new dummyT(jj)));
|
shared.push_back(boost::shared_ptr<dummyT>(new dummyT(jj)));
|
||||||
|
|
||||||
dummyT* ptr[N];
|
dummyT* ptr[N];
|
||||||
for (int k = 0; k < N; ++k)
|
for (int k = 0; k < N; ++k)
|
||||||
ptr[k] = array + k;
|
ptr[k] = array + k;
|
||||||
@@ -202,16 +202,16 @@ main()
|
|||||||
, N, array);
|
, N, array);
|
||||||
|
|
||||||
boost::random_access_iterator_test(boost::make_indirect_iterator(ptr), N, array);
|
boost::random_access_iterator_test(boost::make_indirect_iterator(ptr), N, array);
|
||||||
|
|
||||||
// check operator->
|
// check operator->
|
||||||
assert((*i).m_x == i->foo());
|
assert((*i).m_x == i->foo());
|
||||||
|
|
||||||
const_indirect_iterator j(ptr);
|
const_indirect_iterator j(ptr);
|
||||||
boost::random_access_iterator_test(j, N, array);
|
boost::random_access_iterator_test(j, N, array);
|
||||||
|
|
||||||
dummyT const*const* const_ptr = ptr;
|
dummyT const*const* const_ptr = ptr;
|
||||||
boost::random_access_iterator_test(boost::make_indirect_iterator(const_ptr), N, array);
|
boost::random_access_iterator_test(boost::make_indirect_iterator(const_ptr), N, array);
|
||||||
|
|
||||||
boost::const_nonconst_iterator_test(i, ++j);
|
boost::const_nonconst_iterator_test(i, ++j);
|
||||||
|
|
||||||
more_indirect_iterator_tests();
|
more_indirect_iterator_tests();
|
||||||
|
|||||||
@@ -4,16 +4,16 @@
|
|||||||
|
|
||||||
#include <boost/iterator/iterator_adaptor.hpp>
|
#include <boost/iterator/iterator_adaptor.hpp>
|
||||||
#include <boost/pending/iterator_tests.hpp>
|
#include <boost/pending/iterator_tests.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
struct mutable_it : boost::iterator_adaptor<mutable_it,int*>
|
struct mutable_it : boost::iterator_adaptor<mutable_it,int*>
|
||||||
{
|
{
|
||||||
typedef boost::iterator_adaptor<mutable_it,int*> super_t;
|
typedef boost::iterator_adaptor<mutable_it,int*> super_t;
|
||||||
|
|
||||||
mutable_it();
|
mutable_it();
|
||||||
explicit mutable_it(int* p) : super_t(p) {}
|
explicit mutable_it(int* p) : super_t(p) {}
|
||||||
|
|
||||||
bool equal(mutable_it const& rhs) const
|
bool equal(mutable_it const& rhs) const
|
||||||
{
|
{
|
||||||
return this->base() == rhs.base();
|
return this->base() == rhs.base();
|
||||||
@@ -23,7 +23,7 @@ struct mutable_it : boost::iterator_adaptor<mutable_it,int*>
|
|||||||
struct constant_it : boost::iterator_adaptor<constant_it,int const*>
|
struct constant_it : boost::iterator_adaptor<constant_it,int const*>
|
||||||
{
|
{
|
||||||
typedef boost::iterator_adaptor<constant_it,int const*> super_t;
|
typedef boost::iterator_adaptor<constant_it,int const*> super_t;
|
||||||
|
|
||||||
constant_it();
|
constant_it();
|
||||||
explicit constant_it(int* p) : super_t(p) {}
|
explicit constant_it(int* p) : super_t(p) {}
|
||||||
constant_it(mutable_it const& x) : super_t(x.base()) {}
|
constant_it(mutable_it const& x) : super_t(x.base()) {}
|
||||||
@@ -37,7 +37,7 @@ struct constant_it : boost::iterator_adaptor<constant_it,int const*>
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int data[] = { 49, 77 };
|
int data[] = { 49, 77 };
|
||||||
|
|
||||||
mutable_it i(data);
|
mutable_it i(data);
|
||||||
constant_it j(data + 1);
|
constant_it j(data + 1);
|
||||||
BOOST_TEST(i < j);
|
BOOST_TEST(i < j);
|
||||||
@@ -46,7 +46,7 @@ int main()
|
|||||||
BOOST_TEST(j >= i);
|
BOOST_TEST(j >= i);
|
||||||
BOOST_TEST(j - i == 1);
|
BOOST_TEST(j - i == 1);
|
||||||
BOOST_TEST(i - j == -1);
|
BOOST_TEST(i - j == -1);
|
||||||
|
|
||||||
constant_it k = i;
|
constant_it k = i;
|
||||||
|
|
||||||
BOOST_TEST(!(i < k));
|
BOOST_TEST(!(i < k));
|
||||||
@@ -55,6 +55,6 @@ int main()
|
|||||||
BOOST_TEST(k >= i);
|
BOOST_TEST(k >= i);
|
||||||
BOOST_TEST(k - i == 0);
|
BOOST_TEST(k - i == 0);
|
||||||
BOOST_TEST(i - k == 0);
|
BOOST_TEST(i - k == 0);
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,164 @@
|
|||||||
|
/*
|
||||||
|
* 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)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Andrey Semashev
|
||||||
|
*/
|
||||||
|
/*!
|
||||||
|
* \file is_iterator.cpp
|
||||||
|
*
|
||||||
|
* This header contains tests for the \c is_iterator type trait.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <boost/iterator/is_iterator.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <list>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <iterator>
|
||||||
|
#include <boost/iterator/iterator_adaptor.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
struct value_iterator
|
||||||
|
{
|
||||||
|
typedef std::input_iterator_tag iterator_category;
|
||||||
|
typedef T value_type;
|
||||||
|
typedef std::ptrdiff_t difference_type;
|
||||||
|
typedef T* pointer;
|
||||||
|
typedef T& reference;
|
||||||
|
|
||||||
|
value_type operator*() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
struct proxy_iterator
|
||||||
|
{
|
||||||
|
typedef T value_type;
|
||||||
|
typedef std::output_iterator_tag iterator_category;
|
||||||
|
typedef std::ptrdiff_t difference_type;
|
||||||
|
typedef T* pointer;
|
||||||
|
typedef T& reference;
|
||||||
|
|
||||||
|
struct proxy
|
||||||
|
{
|
||||||
|
operator value_type&() const;
|
||||||
|
proxy& operator=(value_type) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
proxy operator*() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
struct lvalue_iterator
|
||||||
|
{
|
||||||
|
typedef T value_type;
|
||||||
|
typedef T& reference;
|
||||||
|
typedef T difference_type;
|
||||||
|
typedef std::input_iterator_tag iterator_category;
|
||||||
|
typedef T* pointer;
|
||||||
|
|
||||||
|
T& operator*() const;
|
||||||
|
lvalue_iterator& operator++();
|
||||||
|
lvalue_iterator operator++(int);
|
||||||
|
};
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
struct constant_lvalue_iterator
|
||||||
|
{
|
||||||
|
typedef T value_type;
|
||||||
|
typedef T const& reference;
|
||||||
|
typedef T difference_type;
|
||||||
|
typedef std::input_iterator_tag iterator_category;
|
||||||
|
typedef T const* pointer;
|
||||||
|
|
||||||
|
T const& operator*() const;
|
||||||
|
constant_lvalue_iterator& operator++();
|
||||||
|
constant_lvalue_iterator operator++(int);
|
||||||
|
};
|
||||||
|
|
||||||
|
template< typename Iterator >
|
||||||
|
class adapted_iterator :
|
||||||
|
public boost::iterators::iterator_adaptor< adapted_iterator< Iterator >, Iterator >
|
||||||
|
{
|
||||||
|
friend class iterator_core_access;
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef boost::iterators::iterator_adaptor< adapted_iterator< Iterator >, Iterator > base_type;
|
||||||
|
|
||||||
|
private:
|
||||||
|
typename base_type::reference dereference() const;
|
||||||
|
void increment();
|
||||||
|
void decrement();
|
||||||
|
void advance(typename base_type::difference_type n);
|
||||||
|
template< typename OtherIterator >
|
||||||
|
typename base_type::difference_type distance_to(adapted_iterator< OtherIterator > const& y) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct complete {};
|
||||||
|
struct incomplete;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< int* >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< const int* >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< complete* >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::reverse_iterator< int* > >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::reverse_iterator< complete* > >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< adapted_iterator< int* > >::value);
|
||||||
|
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::string::iterator >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::string::const_iterator >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::string::reverse_iterator >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::string::const_reverse_iterator >::value);
|
||||||
|
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::list< int >::iterator >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::list< int >::const_iterator >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::list< int >::reverse_iterator >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::list< int >::const_reverse_iterator >::value);
|
||||||
|
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::vector< int >::iterator >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::vector< int >::const_iterator >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::vector< int >::reverse_iterator >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::vector< int >::const_reverse_iterator >::value);
|
||||||
|
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::insert_iterator< std::vector< int > > >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::back_insert_iterator< std::vector< int > > >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::front_insert_iterator< std::vector< int > > >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::istream_iterator< int > >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::ostream_iterator< int > >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::istreambuf_iterator< char > >::value);
|
||||||
|
BOOST_TEST(boost::iterators::is_iterator< std::ostreambuf_iterator< char > >::value);
|
||||||
|
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< complete >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< void >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< const void >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< void* >::value);
|
||||||
|
#if defined(BOOST_TT_HAS_WORKING_IS_COMPLETE)
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< incomplete >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< incomplete* >::value);
|
||||||
|
#endif
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int (int) >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int (*)(int) >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int complete::* >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int (complete::*)(int) >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int (complete::*)(int) const >::value);
|
||||||
|
#if defined(__cpp_noexcept_function_type) && (__cpp_noexcept_function_type >= 201510L)
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int (*)(int) noexcept >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int (complete::*)(int) noexcept >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int (complete::*)(int) const noexcept >::value);
|
||||||
|
#endif
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int[] >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int[10] >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int*[] >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int*[10] >::value);
|
||||||
|
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int& >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int*& >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int (&)(int) >::value);
|
||||||
|
BOOST_TEST(!boost::iterators::is_iterator< int (&)[10] >::value);
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
+11
-11
@@ -38,7 +38,7 @@ struct noncopyable_iterator
|
|||||||
typedef std::ptrdiff_t difference_type;
|
typedef std::ptrdiff_t difference_type;
|
||||||
typedef boost::noncopyable* pointer;
|
typedef boost::noncopyable* pointer;
|
||||||
typedef boost::noncopyable& reference;
|
typedef boost::noncopyable& reference;
|
||||||
|
|
||||||
boost::noncopyable const& operator*() const;
|
boost::noncopyable const& operator*() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -50,13 +50,13 @@ struct proxy_iterator
|
|||||||
typedef std::ptrdiff_t difference_type;
|
typedef std::ptrdiff_t difference_type;
|
||||||
typedef T* pointer;
|
typedef T* pointer;
|
||||||
typedef T& reference;
|
typedef T& reference;
|
||||||
|
|
||||||
struct proxy
|
struct proxy
|
||||||
{
|
{
|
||||||
operator value_type&() const;
|
operator value_type&() const;
|
||||||
proxy& operator=(value_type) const;
|
proxy& operator=(value_type) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
proxy operator*() const;
|
proxy operator*() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -111,14 +111,14 @@ int main()
|
|||||||
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<lvalue_iterator<char*> >::value);
|
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<lvalue_iterator<char*> >::value);
|
||||||
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<lvalue_iterator<float> >::value);
|
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<lvalue_iterator<float> >::value);
|
||||||
|
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<constant_lvalue_iterator<v> >::value);
|
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<constant_lvalue_iterator<v> >::value);
|
||||||
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<constant_lvalue_iterator<int> >::value);
|
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<constant_lvalue_iterator<int> >::value);
|
||||||
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<constant_lvalue_iterator<char*> >::value);
|
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<constant_lvalue_iterator<char*> >::value);
|
||||||
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<constant_lvalue_iterator<float> >::value);
|
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<constant_lvalue_iterator<float> >::value);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<v*>::value);
|
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<v*>::value);
|
||||||
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<v const*>::value);
|
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<v const*>::value);
|
||||||
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<std::deque<v>::iterator>::value);
|
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<std::deque<v>::iterator>::value);
|
||||||
@@ -131,18 +131,18 @@ int main()
|
|||||||
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<value_iterator>::value);
|
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<value_iterator>::value);
|
||||||
#endif
|
#endif
|
||||||
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<noncopyable_iterator>::value);
|
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<noncopyable_iterator>::value);
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<lvalue_iterator<v> >::value);
|
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<lvalue_iterator<v> >::value);
|
||||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
|
||||||
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<lvalue_iterator<int> >::value);
|
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<lvalue_iterator<int> >::value);
|
||||||
#endif
|
#endif
|
||||||
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<lvalue_iterator<char*> >::value);
|
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<lvalue_iterator<char*> >::value);
|
||||||
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<lvalue_iterator<float> >::value);
|
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<lvalue_iterator<float> >::value);
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<v> >::value);
|
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<v> >::value);
|
||||||
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<int> >::value);
|
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<int> >::value);
|
||||||
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<char*> >::value);
|
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<char*> >::value);
|
||||||
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<float> >::value);
|
BOOST_STATIC_ASSERT(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<float> >::value);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ struct noncopyable_iterator
|
|||||||
typedef std::ptrdiff_t difference_type;
|
typedef std::ptrdiff_t difference_type;
|
||||||
typedef boost::noncopyable* pointer;
|
typedef boost::noncopyable* pointer;
|
||||||
typedef boost::noncopyable& reference;
|
typedef boost::noncopyable& reference;
|
||||||
|
|
||||||
boost::noncopyable const& operator*() const;
|
boost::noncopyable const& operator*() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -49,13 +49,13 @@ struct proxy_iterator
|
|||||||
typedef std::ptrdiff_t difference_type;
|
typedef std::ptrdiff_t difference_type;
|
||||||
typedef v* pointer;
|
typedef v* pointer;
|
||||||
typedef v& reference;
|
typedef v& reference;
|
||||||
|
|
||||||
struct proxy
|
struct proxy
|
||||||
{
|
{
|
||||||
operator v&();
|
operator v&();
|
||||||
proxy& operator=(v) const;
|
proxy& operator=(v) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
proxy operator*() const;
|
proxy operator*() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -66,12 +66,12 @@ struct proxy_iterator2
|
|||||||
typedef std::ptrdiff_t difference_type;
|
typedef std::ptrdiff_t difference_type;
|
||||||
typedef v* pointer;
|
typedef v* pointer;
|
||||||
typedef v& reference;
|
typedef v& reference;
|
||||||
|
|
||||||
struct proxy
|
struct proxy
|
||||||
{
|
{
|
||||||
proxy& operator=(v) const;
|
proxy& operator=(v) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
proxy operator*() const;
|
proxy operator*() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -87,10 +87,10 @@ int main()
|
|||||||
BOOST_STATIC_ASSERT(boost::is_readable_iterator<proxy_iterator>::value);
|
BOOST_STATIC_ASSERT(boost::is_readable_iterator<proxy_iterator>::value);
|
||||||
BOOST_STATIC_ASSERT(!boost::is_readable_iterator<proxy_iterator2>::value);
|
BOOST_STATIC_ASSERT(!boost::is_readable_iterator<proxy_iterator2>::value);
|
||||||
BOOST_STATIC_ASSERT(boost::is_readable_iterator<value_iterator>::value);
|
BOOST_STATIC_ASSERT(boost::is_readable_iterator<value_iterator>::value);
|
||||||
|
|
||||||
// Make sure inaccessible copy constructor doesn't prevent
|
// Make sure inaccessible copy constructor doesn't prevent
|
||||||
// readability
|
// readability
|
||||||
BOOST_STATIC_ASSERT(boost::is_readable_iterator<noncopyable_iterator>::value);
|
BOOST_STATIC_ASSERT(boost::is_readable_iterator<noncopyable_iterator>::value);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ int main()
|
|||||||
#if defined(__SGI_STL_PORT) \
|
#if defined(__SGI_STL_PORT) \
|
||||||
|| !BOOST_WORKAROUND(__GNUC__, <= 2) \
|
|| !BOOST_WORKAROUND(__GNUC__, <= 2) \
|
||||||
&& !(BOOST_WORKAROUND(__GNUC__, == 3) && BOOST_WORKAROUND(__GNUC_MINOR__, <= 1)) \
|
&& !(BOOST_WORKAROUND(__GNUC__, == 3) && BOOST_WORKAROUND(__GNUC_MINOR__, <= 1)) \
|
||||||
&& !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) \
|
&& !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551)) \
|
||||||
&& !BOOST_WORKAROUND(__LIBCOMO_VERSION__, BOOST_TESTED_AT(29)) \
|
&& !BOOST_WORKAROUND(__LIBCOMO_VERSION__, BOOST_TESTED_AT(29)) \
|
||||||
&& !BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, <= 1)
|
&& !BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, <= 1)
|
||||||
{
|
{
|
||||||
@@ -41,6 +41,6 @@ int main()
|
|||||||
boost::function_requires< boost_concepts::InteroperableIteratorConcept<rev_iter, c_rev_iter> >();
|
boost::function_requires< boost_concepts::InteroperableIteratorConcept<rev_iter, c_rev_iter> >();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return boost::exit_success;
|
return boost::exit_success;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||||
# include <boost/iterator/is_readable_iterator.hpp>
|
# include <boost/iterator/is_readable_iterator.hpp>
|
||||||
# include <boost/iterator/is_lvalue_iterator.hpp>
|
# include <boost/iterator/is_lvalue_iterator.hpp>
|
||||||
#endif
|
#endif
|
||||||
#include <boost/pending/iterator_tests.hpp>
|
#include <boost/pending/iterator_tests.hpp>
|
||||||
|
|
||||||
# include <boost/detail/lightweight_test.hpp>
|
# include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -56,9 +56,9 @@ struct ptr_iterator
|
|||||||
, V*
|
, V*
|
||||||
, V
|
, V
|
||||||
, boost::random_access_traversal_tag
|
, boost::random_access_traversal_tag
|
||||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
|
||||||
, V&
|
, V&
|
||||||
#endif
|
#endif
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -67,11 +67,11 @@ private:
|
|||||||
, V*
|
, V*
|
||||||
, V
|
, V
|
||||||
, boost::random_access_traversal_tag
|
, boost::random_access_traversal_tag
|
||||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551))
|
||||||
, V&
|
, V&
|
||||||
#endif
|
#endif
|
||||||
> super_t;
|
> super_t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ptr_iterator() { }
|
ptr_iterator() { }
|
||||||
ptr_iterator(V* d) : super_t(d) { }
|
ptr_iterator(V* d) : super_t(d) { }
|
||||||
@@ -95,7 +95,7 @@ struct modify_traversal
|
|||||||
, Traversal
|
, Traversal
|
||||||
>
|
>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct fwd_iterator
|
struct fwd_iterator
|
||||||
: boost::iterator_adaptor<
|
: boost::iterator_adaptor<
|
||||||
@@ -108,7 +108,7 @@ private:
|
|||||||
fwd_iterator<T>
|
fwd_iterator<T>
|
||||||
, boost::forward_iterator_archetype<T>
|
, boost::forward_iterator_archetype<T>
|
||||||
> super_t;
|
> super_t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
fwd_iterator() { }
|
fwd_iterator() { }
|
||||||
fwd_iterator(boost::forward_iterator_archetype<T> d) : super_t(d) { }
|
fwd_iterator(boost::forward_iterator_archetype<T> d) : super_t(d) { }
|
||||||
@@ -126,7 +126,7 @@ private:
|
|||||||
in_iterator<T>
|
in_iterator<T>
|
||||||
, boost::input_iterator_archetype_no_proxy<T>
|
, boost::input_iterator_archetype_no_proxy<T>
|
||||||
> super_t;
|
> super_t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
in_iterator() { }
|
in_iterator() { }
|
||||||
in_iterator(boost::input_iterator_archetype_no_proxy<T> d) : super_t(d) { }
|
in_iterator(boost::input_iterator_archetype_no_proxy<T> d) : super_t(d) { }
|
||||||
@@ -145,7 +145,7 @@ struct constant_iterator
|
|||||||
, Iter
|
, Iter
|
||||||
, typename std::iterator_traits<Iter>::value_type const
|
, typename std::iterator_traits<Iter>::value_type const
|
||||||
> base_t;
|
> base_t;
|
||||||
|
|
||||||
constant_iterator() {}
|
constant_iterator() {}
|
||||||
constant_iterator(Iter it)
|
constant_iterator(Iter it)
|
||||||
: base_t(it) {}
|
: base_t(it) {}
|
||||||
@@ -181,7 +181,7 @@ int static_assert_traversal(Iter* = 0, Trav* = 0)
|
|||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
dummyT array[] = { dummyT(0), dummyT(1), dummyT(2),
|
dummyT array[] = { dummyT(0), dummyT(1), dummyT(2),
|
||||||
dummyT(3), dummyT(4), dummyT(5) };
|
dummyT(3), dummyT(4), dummyT(5) };
|
||||||
const int N = sizeof(array)/sizeof(dummyT);
|
const int N = sizeof(array)/sizeof(dummyT);
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ main()
|
|||||||
{
|
{
|
||||||
ptr_iterator<dummyT> i(array);
|
ptr_iterator<dummyT> i(array);
|
||||||
boost::random_access_iterator_test(i, N, array);
|
boost::random_access_iterator_test(i, N, array);
|
||||||
|
|
||||||
ptr_iterator<const dummyT> j(array);
|
ptr_iterator<const dummyT> j(array);
|
||||||
boost::random_access_iterator_test(j, N, array);
|
boost::random_access_iterator_test(j, N, array);
|
||||||
boost::const_nonconst_iterator_test(i, ++j);
|
boost::const_nonconst_iterator_test(i, ++j);
|
||||||
@@ -210,25 +210,25 @@ main()
|
|||||||
test = static_assert_same<Iter1::difference_type, std::ptrdiff_t>::value;
|
test = static_assert_same<Iter1::difference_type, std::ptrdiff_t>::value;
|
||||||
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||||
BOOST_STATIC_ASSERT((boost::is_convertible<Iter1::iterator_category, std::random_access_iterator_tag>::value));
|
BOOST_STATIC_ASSERT((boost::is_convertible<Iter1::iterator_category, std::random_access_iterator_tag>::value));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Test computation of default when the Value is const
|
// Test computation of default when the Value is const
|
||||||
typedef ptr_iterator<int const> Iter1;
|
typedef ptr_iterator<int const> Iter1;
|
||||||
test = static_assert_same<Iter1::value_type, int>::value;
|
test = static_assert_same<Iter1::value_type, int>::value;
|
||||||
test = static_assert_same<Iter1::reference, const int&>::value;
|
test = static_assert_same<Iter1::reference, const int&>::value;
|
||||||
|
|
||||||
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
#if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
|
||||||
BOOST_STATIC_ASSERT(boost::is_readable_iterator<Iter1>::value);
|
BOOST_STATIC_ASSERT(boost::is_readable_iterator<Iter1>::value);
|
||||||
# ifndef BOOST_NO_LVALUE_RETURN_DETECTION
|
# ifndef BOOST_NO_LVALUE_RETURN_DETECTION
|
||||||
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<Iter1>::value);
|
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<Iter1>::value);
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) // borland drops constness
|
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) // borland drops constness
|
||||||
test = static_assert_same<Iter1::pointer, int const*>::value;
|
test = static_assert_same<Iter1::pointer, int const*>::value;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -238,26 +238,26 @@ main()
|
|||||||
|
|
||||||
test = static_assert_same<Iter::value_type, int>::value;
|
test = static_assert_same<Iter::value_type, int>::value;
|
||||||
test = static_assert_same<Iter::reference, int const&>::value;
|
test = static_assert_same<Iter::reference, int const&>::value;
|
||||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) // borland drops constness
|
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) // borland drops constness
|
||||||
test = static_assert_same<Iter::pointer, int const*>::value;
|
test = static_assert_same<Iter::pointer, int const*>::value;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BOOST_NO_LVALUE_RETURN_DETECTION
|
#ifndef BOOST_NO_LVALUE_RETURN_DETECTION
|
||||||
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<BaseIter>::value);
|
BOOST_STATIC_ASSERT(boost::is_non_const_lvalue_iterator<BaseIter>::value);
|
||||||
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<Iter>::value);
|
BOOST_STATIC_ASSERT(boost::is_lvalue_iterator<Iter>::value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef modify_traversal<BaseIter, boost::incrementable_traversal_tag> IncrementableIter;
|
typedef modify_traversal<BaseIter, boost::incrementable_traversal_tag> IncrementableIter;
|
||||||
|
|
||||||
static_assert_traversal<BaseIter,boost::random_access_traversal_tag>();
|
static_assert_traversal<BaseIter,boost::random_access_traversal_tag>();
|
||||||
static_assert_traversal<IncrementableIter,boost::incrementable_traversal_tag>();
|
static_assert_traversal<IncrementableIter,boost::incrementable_traversal_tag>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the iterator_adaptor
|
// Test the iterator_adaptor
|
||||||
{
|
{
|
||||||
ptr_iterator<dummyT> i(array);
|
ptr_iterator<dummyT> i(array);
|
||||||
boost::random_access_iterator_test(i, N, array);
|
boost::random_access_iterator_test(i, N, array);
|
||||||
|
|
||||||
ptr_iterator<const dummyT> j(array);
|
ptr_iterator<const dummyT> j(array);
|
||||||
boost::random_access_iterator_test(j, N, array);
|
boost::random_access_iterator_test(j, N, array);
|
||||||
boost::const_nonconst_iterator_test(i, ++j);
|
boost::const_nonconst_iterator_test(i, ++j);
|
||||||
@@ -272,9 +272,9 @@ main()
|
|||||||
adaptor_type i(forward_iter);
|
adaptor_type i(forward_iter);
|
||||||
int zero = 0;
|
int zero = 0;
|
||||||
if (zero) // don't do this, just make sure it compiles
|
if (zero) // don't do this, just make sure it compiles
|
||||||
BOOST_TEST((*i).m_x == i->foo());
|
BOOST_TEST((*i).m_x == i->foo());
|
||||||
}
|
}
|
||||||
|
|
||||||
// check operator-> with an input iterator
|
// check operator-> with an input iterator
|
||||||
{
|
{
|
||||||
boost::input_iterator_archetype_no_proxy<dummyT> input_iter;
|
boost::input_iterator_archetype_no_proxy<dummyT> input_iter;
|
||||||
@@ -282,7 +282,7 @@ main()
|
|||||||
adaptor_type i(input_iter);
|
adaptor_type i(input_iter);
|
||||||
int zero = 0;
|
int zero = 0;
|
||||||
if (zero) // don't do this, just make sure it compiles
|
if (zero) // don't do this, just make sure it compiles
|
||||||
BOOST_TEST((*i).m_x == i->foo());
|
BOOST_TEST((*i).m_x == i->foo());
|
||||||
}
|
}
|
||||||
|
|
||||||
// check that base_type is correct
|
// check that base_type is correct
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ int main()
|
|||||||
|
|
||||||
boost::function_requires< boost_concepts::ReadableIteratorConcept<iter> >();
|
boost::function_requires< boost_concepts::ReadableIteratorConcept<iter> >();
|
||||||
boost::function_requires< boost_concepts::RandomAccessTraversalConcept<iter> >();
|
boost::function_requires< boost_concepts::RandomAccessTraversalConcept<iter> >();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
typedef boost::iterator_archetype<
|
typedef boost::iterator_archetype<
|
||||||
int
|
int
|
||||||
@@ -32,7 +32,7 @@ int main()
|
|||||||
boost::function_requires< boost_concepts::ReadableIteratorConcept<iter> >();
|
boost::function_requires< boost_concepts::ReadableIteratorConcept<iter> >();
|
||||||
boost::function_requires< boost_concepts::WritableIteratorConcept<iter> >();
|
boost::function_requires< boost_concepts::WritableIteratorConcept<iter> >();
|
||||||
boost::function_requires< boost_concepts::RandomAccessTraversalConcept<iter> >();
|
boost::function_requires< boost_concepts::RandomAccessTraversalConcept<iter> >();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
typedef boost::iterator_archetype<
|
typedef boost::iterator_archetype<
|
||||||
const int // I don't like adding const to Value. It is redundant. -JGS
|
const int // I don't like adding const to Value. It is redundant. -JGS
|
||||||
@@ -43,7 +43,7 @@ int main()
|
|||||||
boost::function_requires< boost_concepts::ReadableIteratorConcept<iter> >();
|
boost::function_requires< boost_concepts::ReadableIteratorConcept<iter> >();
|
||||||
boost::function_requires< boost_concepts::LvalueIteratorConcept<iter> >();
|
boost::function_requires< boost_concepts::LvalueIteratorConcept<iter> >();
|
||||||
boost::function_requires< boost_concepts::RandomAccessTraversalConcept<iter> >();
|
boost::function_requires< boost_concepts::RandomAccessTraversalConcept<iter> >();
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
typedef boost::iterator_archetype<
|
typedef boost::iterator_archetype<
|
||||||
int
|
int
|
||||||
@@ -54,7 +54,7 @@ int main()
|
|||||||
boost::function_requires< boost_concepts::WritableIteratorConcept<iter> >();
|
boost::function_requires< boost_concepts::WritableIteratorConcept<iter> >();
|
||||||
boost::function_requires< boost_concepts::LvalueIteratorConcept<iter> >();
|
boost::function_requires< boost_concepts::LvalueIteratorConcept<iter> >();
|
||||||
boost::function_requires< boost_concepts::RandomAccessTraversalConcept<iter> >();
|
boost::function_requires< boost_concepts::RandomAccessTraversalConcept<iter> >();
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::exit_success;
|
return boost::exit_success;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,8 @@
|
|||||||
#include <boost/iterator/new_iterator_tests.hpp>
|
#include <boost/iterator/new_iterator_tests.hpp>
|
||||||
|
|
||||||
#include <boost/call_traits.hpp>
|
#include <boost/call_traits.hpp>
|
||||||
#include <boost/polymorphic_cast.hpp>
|
|
||||||
#include <boost/type_traits/is_convertible.hpp>
|
#include <boost/type_traits/is_convertible.hpp>
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/core/enable_if.hpp>
|
||||||
|
|
||||||
// This is a really, really limited test so far. All we're doing
|
// This is a really, really limited test so far. All we're doing
|
||||||
// right now is checking that the postfix++ proxy for single-pass
|
// right now is checking that the postfix++ proxy for single-pass
|
||||||
@@ -63,7 +62,23 @@ struct proxy
|
|||||||
|
|
||||||
struct value
|
struct value
|
||||||
{
|
{
|
||||||
void mutator() {} // non-const member function
|
int increment_count;
|
||||||
|
int private_mutator_count;
|
||||||
|
int& shared_mutator_count;
|
||||||
|
|
||||||
|
explicit value(int& shared_mutator_count) :
|
||||||
|
increment_count(0),
|
||||||
|
private_mutator_count(0),
|
||||||
|
shared_mutator_count(shared_mutator_count)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// non-const member function
|
||||||
|
void mutator()
|
||||||
|
{
|
||||||
|
++private_mutator_count;
|
||||||
|
++shared_mutator_count;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct input_iter
|
struct input_iter
|
||||||
@@ -75,21 +90,25 @@ struct input_iter
|
|||||||
>
|
>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
input_iter() {}
|
explicit input_iter(value& val) : state(&val) {}
|
||||||
|
|
||||||
void increment()
|
void increment()
|
||||||
{
|
{
|
||||||
|
++(state->increment_count);
|
||||||
}
|
}
|
||||||
value
|
value
|
||||||
dereference() const
|
dereference() const
|
||||||
{
|
{
|
||||||
return value();
|
return *state;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool equal(input_iter const&) const
|
bool equal(input_iter const&) const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
value* state;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@@ -127,7 +146,7 @@ struct iterator_with_proxy_reference
|
|||||||
|
|
||||||
template <class T, class U>
|
template <class T, class U>
|
||||||
void same_type(U const&)
|
void same_type(U const&)
|
||||||
{ BOOST_MPL_ASSERT((boost::is_same<T,U>)); }
|
{ BOOST_STATIC_ASSERT((boost::is_same<T,U>::value)); }
|
||||||
|
|
||||||
template <class I, class A>
|
template <class I, class A>
|
||||||
struct abstract_iterator
|
struct abstract_iterator
|
||||||
@@ -168,12 +187,12 @@ struct derived : base
|
|||||||
|
|
||||||
virtual void assign(const base &b)
|
virtual void assign(const base &b)
|
||||||
{
|
{
|
||||||
state = boost::polymorphic_cast<const derived *>(&b)->state;
|
state = dynamic_cast<const derived &>(b).state;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool equal(const base &b) const
|
virtual bool equal(const base &b) const
|
||||||
{
|
{
|
||||||
return state == boost::polymorphic_cast<const derived *>(&b)->state;
|
return state == dynamic_cast<const derived &>(b).state;
|
||||||
}
|
}
|
||||||
|
|
||||||
int state;
|
int state;
|
||||||
@@ -198,13 +217,30 @@ int main()
|
|||||||
{
|
{
|
||||||
// test for a fix to http://tinyurl.com/zuohe
|
// test for a fix to http://tinyurl.com/zuohe
|
||||||
// These two lines should be equivalent (and both compile)
|
// These two lines should be equivalent (and both compile)
|
||||||
input_iter p;
|
int shared_mutator_count = 0;
|
||||||
|
value val(shared_mutator_count);
|
||||||
|
input_iter p(val);
|
||||||
(*p).mutator();
|
(*p).mutator();
|
||||||
p->mutator();
|
p->mutator();
|
||||||
|
BOOST_TEST_EQ(val.increment_count, 0);
|
||||||
|
BOOST_TEST_EQ(val.private_mutator_count, 0); // mutator() should be invoked on an object returned by value
|
||||||
|
BOOST_TEST_EQ(shared_mutator_count, 2);
|
||||||
|
|
||||||
same_type<input_iter::pointer>(p.operator->());
|
same_type<input_iter::pointer>(p.operator->());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Test that accessing dereferenced value of a post-incremented iterator works
|
||||||
|
int shared_mutator_count = 0;
|
||||||
|
value val(shared_mutator_count);
|
||||||
|
input_iter p(val);
|
||||||
|
(*p++).mutator();
|
||||||
|
(p++)->mutator();
|
||||||
|
BOOST_TEST_EQ(val.increment_count, 2);
|
||||||
|
BOOST_TEST_EQ(val.private_mutator_count, 0); // mutator() should be invoked on an object returned by value
|
||||||
|
BOOST_TEST_EQ(shared_mutator_count, 2);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
iterator_with_proxy_reference i(x);
|
iterator_with_proxy_reference i(x);
|
||||||
|
|||||||
@@ -20,14 +20,14 @@
|
|||||||
// reference type from operator* (David Abrahams)
|
// reference type from operator* (David Abrahams)
|
||||||
// 19 Jan 2001 Initial version with iterator operators (David Abrahams)
|
// 19 Jan 2001 Initial version with iterator operators (David Abrahams)
|
||||||
|
|
||||||
#include <boost/detail/iterator.hpp>
|
|
||||||
#include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
#include <boost/operators.hpp>
|
#include <boost/operators.hpp>
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// A UDT for which we can specialize std::iterator_traits<element*> on
|
// A UDT for which we can specialize std::iterator_traits<element*> on
|
||||||
@@ -40,7 +40,7 @@ struct my_iterator1
|
|||||||
: boost::forward_iterator_helper<my_iterator1, char, long, const char*, const char&>
|
: boost::forward_iterator_helper<my_iterator1, char, long, const char*, const char&>
|
||||||
{
|
{
|
||||||
my_iterator1(const char* p) : m_p(p) {}
|
my_iterator1(const char* p) : m_p(p) {}
|
||||||
|
|
||||||
bool operator==(const my_iterator1& rhs) const
|
bool operator==(const my_iterator1& rhs) const
|
||||||
{ return this->m_p == rhs.m_p; }
|
{ return this->m_p == rhs.m_p; }
|
||||||
|
|
||||||
@@ -63,9 +63,9 @@ struct my_iterator2
|
|||||||
typedef const char* pointer;
|
typedef const char* pointer;
|
||||||
typedef const char& reference;
|
typedef const char& reference;
|
||||||
typedef std::forward_iterator_tag iterator_category;
|
typedef std::forward_iterator_tag iterator_category;
|
||||||
|
|
||||||
my_iterator2(const char* p) : m_p(p) {}
|
my_iterator2(const char* p) : m_p(p) {}
|
||||||
|
|
||||||
bool operator==(const my_iterator2& rhs) const
|
bool operator==(const my_iterator2& rhs) const
|
||||||
{ return this->m_p == rhs.m_p; }
|
{ return this->m_p == rhs.m_p; }
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ struct my_iterator2
|
|||||||
|
|
||||||
// Used to prove that we're not overly confused by the existence of
|
// Used to prove that we're not overly confused by the existence of
|
||||||
// std::iterator<> in the hierarchy under MSVC6 - we should find that
|
// std::iterator<> in the hierarchy under MSVC6 - we should find that
|
||||||
// boost::detail::iterator_traits<my_iterator3>::difference_type is int.
|
// std::iterator_traits<my_iterator3>::difference_type is int.
|
||||||
struct my_iterator3 : my_iterator1
|
struct my_iterator3 : my_iterator1
|
||||||
{
|
{
|
||||||
typedef int difference_type;
|
typedef int difference_type;
|
||||||
@@ -108,8 +108,8 @@ template <class Iterator,
|
|||||||
class value_type, class difference_type, class pointer, class reference, class category>
|
class value_type, class difference_type, class pointer, class reference, class category>
|
||||||
struct non_portable_tests
|
struct non_portable_tests
|
||||||
{
|
{
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::pointer test_pt;
|
typedef typename std::iterator_traits<Iterator>::pointer test_pt;
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::reference test_rt;
|
typedef typename std::iterator_traits<Iterator>::reference test_rt;
|
||||||
typedef typename assert_same<test_pt, pointer>::type a1;
|
typedef typename assert_same<test_pt, pointer>::type a1;
|
||||||
typedef typename assert_same<test_rt, reference>::type a2;
|
typedef typename assert_same<test_rt, reference>::type a2;
|
||||||
};
|
};
|
||||||
@@ -118,8 +118,8 @@ template <class Iterator,
|
|||||||
class value_type, class difference_type, class pointer, class reference, class category>
|
class value_type, class difference_type, class pointer, class reference, class category>
|
||||||
struct portable_tests
|
struct portable_tests
|
||||||
{
|
{
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::difference_type test_dt;
|
typedef typename std::iterator_traits<Iterator>::difference_type test_dt;
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::iterator_category test_cat;
|
typedef typename std::iterator_traits<Iterator>::iterator_category test_cat;
|
||||||
typedef typename assert_same<test_dt, difference_type>::type a1;
|
typedef typename assert_same<test_dt, difference_type>::type a1;
|
||||||
typedef typename assert_same<test_cat, category>::type a2;
|
typedef typename assert_same<test_cat, category>::type a2;
|
||||||
};
|
};
|
||||||
@@ -130,7 +130,7 @@ template <class Iterator,
|
|||||||
struct input_iterator_test
|
struct input_iterator_test
|
||||||
: portable_tests<Iterator,value_type,difference_type,pointer,reference,category>
|
: portable_tests<Iterator,value_type,difference_type,pointer,reference,category>
|
||||||
{
|
{
|
||||||
typedef typename boost::detail::iterator_traits<Iterator>::value_type test_vt;
|
typedef typename std::iterator_traits<Iterator>::value_type test_vt;
|
||||||
typedef typename assert_same<test_vt, value_type>::type a1;
|
typedef typename assert_same<test_vt, value_type>::type a1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -153,7 +153,17 @@ struct maybe_pointer_test
|
|||||||
input_iterator_test<std::istream_iterator<int>, int, std::ptrdiff_t, int*, int&, std::input_iterator_tag>
|
input_iterator_test<std::istream_iterator<int>, int, std::ptrdiff_t, int*, int&, std::input_iterator_tag>
|
||||||
istream_iterator_test;
|
istream_iterator_test;
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(__BORLANDC__, <= 0x564) && !defined(__SGI_STL_PORT)
|
// C++20 changed ostream_iterator::difference_type to ptrdiff_t.
|
||||||
|
// Note: gcc 10.1 defines __cplusplus to a value less than 202002L, but greater than 201703L in C++20 mode.
|
||||||
|
#if (__cplusplus > 201703L && ( \
|
||||||
|
(defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION >= 100100) || \
|
||||||
|
(defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 12000) \
|
||||||
|
)) || \
|
||||||
|
(defined(_MSVC_LANG) && _MSVC_LANG > 201703L && _MSVC_STL_UPDATE >= 202010L)
|
||||||
|
#define BOOST_ITERATOR_CXX20_OSTREAM_ITERATOR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if BOOST_WORKAROUND(BOOST_BORLANDC, <= 0x564) && !defined(__SGI_STL_PORT)
|
||||||
typedef ::std::char_traits<char>::off_type distance;
|
typedef ::std::char_traits<char>::off_type distance;
|
||||||
non_pointer_test<std::ostream_iterator<int>,int,
|
non_pointer_test<std::ostream_iterator<int>,int,
|
||||||
distance,int*,int&,std::output_iterator_tag> ostream_iterator_test;
|
distance,int*,int&,std::output_iterator_tag> ostream_iterator_test;
|
||||||
@@ -165,6 +175,10 @@ non_pointer_test<std::ostream_iterator<int>,
|
|||||||
non_pointer_test<std::ostream_iterator<int>,
|
non_pointer_test<std::ostream_iterator<int>,
|
||||||
int, long, int*, int&, std::output_iterator_tag>
|
int, long, int*, int&, std::output_iterator_tag>
|
||||||
ostream_iterator_test;
|
ostream_iterator_test;
|
||||||
|
#elif defined(BOOST_ITERATOR_CXX20_OSTREAM_ITERATOR)
|
||||||
|
non_pointer_test<std::ostream_iterator<int>,
|
||||||
|
void, std::ptrdiff_t, void, void, std::output_iterator_tag>
|
||||||
|
ostream_iterator_test;
|
||||||
#else
|
#else
|
||||||
non_pointer_test<std::ostream_iterator<int>,
|
non_pointer_test<std::ostream_iterator<int>,
|
||||||
void, void, void, void, std::output_iterator_tag>
|
void, void, void, void, std::output_iterator_tag>
|
||||||
@@ -189,7 +203,7 @@ maybe_pointer_test<int*, int, std::ptrdiff_t, int*, int&, std::random_access_ite
|
|||||||
|
|
||||||
non_pointer_test<my_iterator1, char, long, const char*, const char&, std::forward_iterator_tag>
|
non_pointer_test<my_iterator1, char, long, const char*, const char&, std::forward_iterator_tag>
|
||||||
my_iterator1_test;
|
my_iterator1_test;
|
||||||
|
|
||||||
non_pointer_test<my_iterator2, char, long, const char*, const char&, std::forward_iterator_tag>
|
non_pointer_test<my_iterator2, char, long, const char*, const char&, std::forward_iterator_tag>
|
||||||
my_iterator2_test;
|
my_iterator2_test;
|
||||||
|
|
||||||
@@ -204,15 +218,15 @@ int main()
|
|||||||
for (int length = 3; length < 100; length += length / 3)
|
for (int length = 3; length < 100; length += length / 3)
|
||||||
{
|
{
|
||||||
std::list<int> l(length);
|
std::list<int> l(length);
|
||||||
BOOST_TEST(boost::detail::distance(l.begin(), l.end()) == length);
|
BOOST_TEST(std::distance(l.begin(), l.end()) == length);
|
||||||
|
|
||||||
std::vector<int> v(length);
|
|
||||||
BOOST_TEST(boost::detail::distance(v.begin(), v.end()) == length);
|
|
||||||
|
|
||||||
BOOST_TEST(boost::detail::distance(&ints[0], ints + length) == length);
|
std::vector<int> v(length);
|
||||||
BOOST_TEST(boost::detail::distance(my_iterator1(chars), my_iterator1(chars + length)) == length);
|
BOOST_TEST(std::distance(v.begin(), v.end()) == length);
|
||||||
BOOST_TEST(boost::detail::distance(my_iterator2(chars), my_iterator2(chars + length)) == length);
|
|
||||||
BOOST_TEST(boost::detail::distance(my_iterator3(chars), my_iterator3(chars + length)) == length);
|
BOOST_TEST(std::distance(&ints[0], ints + length) == length);
|
||||||
|
BOOST_TEST(std::distance(my_iterator1(chars), my_iterator1(chars + length)) == length);
|
||||||
|
BOOST_TEST(std::distance(my_iterator2(chars), my_iterator2(chars + length)) == length);
|
||||||
|
BOOST_TEST(std::distance(my_iterator3(chars), my_iterator3(chars + length)) == length);
|
||||||
}
|
}
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/test/minimal.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
#include <boost/iterator/permutation_iterator.hpp>
|
#include <boost/iterator/permutation_iterator.hpp>
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
@@ -27,7 +27,7 @@ void iterop_test()
|
|||||||
{
|
{
|
||||||
typedef boost::permutation_iterator< double*, int const* > permutation_type;
|
typedef boost::permutation_iterator< double*, int const* > permutation_type;
|
||||||
typedef boost::permutation_iterator< double const*, int const* > permutation_const_type;
|
typedef boost::permutation_iterator< double const*, int const* > permutation_const_type;
|
||||||
|
|
||||||
BOOST_CONCEPT_ASSERT((
|
BOOST_CONCEPT_ASSERT((
|
||||||
boost_concepts::InteroperableIteratorConcept<
|
boost_concepts::InteroperableIteratorConcept<
|
||||||
permutation_type
|
permutation_type
|
||||||
@@ -58,46 +58,46 @@ void permutation_test()
|
|||||||
permutation_type begin = boost::make_permutation_iterator( elements.begin(), indices.begin() );
|
permutation_type begin = boost::make_permutation_iterator( elements.begin(), indices.begin() );
|
||||||
permutation_type it = begin;
|
permutation_type it = begin;
|
||||||
permutation_type end = boost::make_permutation_iterator( elements.begin(), indices.end() );
|
permutation_type end = boost::make_permutation_iterator( elements.begin(), indices.end() );
|
||||||
|
|
||||||
BOOST_CHECK( it == begin );
|
|
||||||
BOOST_CHECK( it != end );
|
|
||||||
|
|
||||||
BOOST_CHECK( std::distance( begin, end ) == index_size );
|
BOOST_TEST( it == begin );
|
||||||
|
BOOST_TEST( it != end );
|
||||||
|
|
||||||
|
BOOST_TEST( std::distance( begin, end ) == index_size );
|
||||||
|
|
||||||
for( index_type::iterator i_it1 = indices.begin(); it != end; ++i_it1, ++it )
|
for( index_type::iterator i_it1 = indices.begin(); it != end; ++i_it1, ++it )
|
||||||
{
|
{
|
||||||
BOOST_CHECK( *it == elements[ *i_it1 ] );
|
BOOST_TEST( *it == elements[ *i_it1 ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
it = begin;
|
it = begin;
|
||||||
for( int i1 = 0; i1 < index_size - 1 ; ++++i1, ++++it )
|
for( int i1 = 0; i1 < index_size - 1 ; ++++i1, ++++it )
|
||||||
{
|
{
|
||||||
index_type::iterator i_it2 = indices.begin();
|
index_type::iterator i_it2 = indices.begin();
|
||||||
std::advance( i_it2, i1 );
|
std::advance( i_it2, i1 );
|
||||||
BOOST_CHECK( *it == elements[ *i_it2 ] );
|
BOOST_TEST( *it == elements[ *i_it2 ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
it = begin;
|
it = begin;
|
||||||
std::advance(it, index_size);
|
std::advance(it, index_size);
|
||||||
for( index_type::iterator i_it3 = indices.end(); it != begin; )
|
for( index_type::iterator i_it3 = indices.end(); it != begin; )
|
||||||
{
|
{
|
||||||
BOOST_CHECK( *--it == elements[ *--i_it3 ] );
|
BOOST_TEST( *--it == elements[ *--i_it3 ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
it = begin;
|
it = begin;
|
||||||
std::advance(it, index_size);
|
std::advance(it, index_size);
|
||||||
for( int i2 = 0; i2 < index_size - 1; i2+=2, --it )
|
for( int i2 = 0; i2 < index_size - 1; i2+=2, --it )
|
||||||
{
|
{
|
||||||
index_type::iterator i_it4 = --indices.end();
|
index_type::iterator i_it4 = --indices.end();
|
||||||
std::advance( i_it4, -i2 );
|
std::advance( i_it4, -i2 );
|
||||||
BOOST_CHECK( *--it == elements[ *i_it4 ] );
|
BOOST_TEST( *--it == elements[ *i_it4 ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int test_main(int, char *[])
|
int main()
|
||||||
{
|
{
|
||||||
permutation_test();
|
permutation_test();
|
||||||
return 0;
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -35,7 +35,7 @@ struct X {
|
|||||||
template <class T> operator T&() const;
|
template <class T> operator T&() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
STATIC_ASSERT_SAME(boost::pointee<proxy_ref_ptr<int> >::type, int);
|
STATIC_ASSERT_SAME(boost::pointee<proxy_ref_ptr<int> >::type, int);
|
||||||
@@ -43,16 +43,16 @@ int main()
|
|||||||
|
|
||||||
STATIC_ASSERT_SAME(boost::pointee<proxy_ref_ptr<int const> >::type, int const);
|
STATIC_ASSERT_SAME(boost::pointee<proxy_ref_ptr<int const> >::type, int const);
|
||||||
STATIC_ASSERT_SAME(boost::pointee<proxy_ref_ptr<X const> >::type, X const);
|
STATIC_ASSERT_SAME(boost::pointee<proxy_ref_ptr<X const> >::type, X const);
|
||||||
|
|
||||||
STATIC_ASSERT_SAME(boost::pointee<proxy_value_ptr<int> >::type, int const);
|
STATIC_ASSERT_SAME(boost::pointee<proxy_value_ptr<int> >::type, int const);
|
||||||
STATIC_ASSERT_SAME(boost::pointee<proxy_value_ptr<X> >::type, X const);
|
STATIC_ASSERT_SAME(boost::pointee<proxy_value_ptr<X> >::type, X const);
|
||||||
|
|
||||||
STATIC_ASSERT_SAME(boost::pointee<proxy_value_ptr<int const> >::type, int const);
|
STATIC_ASSERT_SAME(boost::pointee<proxy_value_ptr<int const> >::type, int const);
|
||||||
STATIC_ASSERT_SAME(boost::pointee<proxy_value_ptr<X const> >::type, X const);
|
STATIC_ASSERT_SAME(boost::pointee<proxy_value_ptr<X const> >::type, X const);
|
||||||
|
|
||||||
STATIC_ASSERT_SAME(boost::pointee<int*>::type, int);
|
STATIC_ASSERT_SAME(boost::pointee<int*>::type, int);
|
||||||
STATIC_ASSERT_SAME(boost::pointee<int const*>::type, int const);
|
STATIC_ASSERT_SAME(boost::pointee<int const*>::type, int const);
|
||||||
|
|
||||||
STATIC_ASSERT_SAME(boost::pointee<X*>::type, X);
|
STATIC_ASSERT_SAME(boost::pointee<X*>::type, X);
|
||||||
STATIC_ASSERT_SAME(boost::pointee<X const*>::type, X const);
|
STATIC_ASSERT_SAME(boost::pointee<X const*>::type, X const);
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ int main()
|
|||||||
|
|
||||||
STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<int> >::type, int);
|
STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<int> >::type, int);
|
||||||
STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<X> >::type, X);
|
STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<X> >::type, X);
|
||||||
|
|
||||||
STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<int const> >::type, int const);
|
STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<int const> >::type, int const);
|
||||||
STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<X const> >::type, X const);
|
STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<X const> >::type, X const);
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ int main()
|
|||||||
|
|
||||||
STATIC_ASSERT_SAME(boost::pointee<std::unique_ptr<int> >::type, int);
|
STATIC_ASSERT_SAME(boost::pointee<std::unique_ptr<int> >::type, int);
|
||||||
STATIC_ASSERT_SAME(boost::pointee<std::unique_ptr<X> >::type, X);
|
STATIC_ASSERT_SAME(boost::pointee<std::unique_ptr<X> >::type, X);
|
||||||
|
|
||||||
STATIC_ASSERT_SAME(boost::pointee<std::unique_ptr<int const> >::type, int const);
|
STATIC_ASSERT_SAME(boost::pointee<std::unique_ptr<int const> >::type, int const);
|
||||||
STATIC_ASSERT_SAME(boost::pointee<std::unique_ptr<X const> >::type, X const);
|
STATIC_ASSERT_SAME(boost::pointee<std::unique_ptr<X const> >::type, X const);
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ int main()
|
|||||||
|
|
||||||
STATIC_ASSERT_SAME(boost::pointee<std::list<int>::iterator >::type, int);
|
STATIC_ASSERT_SAME(boost::pointee<std::list<int>::iterator >::type, int);
|
||||||
STATIC_ASSERT_SAME(boost::pointee<std::list<X>::iterator >::type, X);
|
STATIC_ASSERT_SAME(boost::pointee<std::list<X>::iterator >::type, X);
|
||||||
|
|
||||||
STATIC_ASSERT_SAME(boost::pointee<std::list<int>::const_iterator >::type, int const);
|
STATIC_ASSERT_SAME(boost::pointee<std::list<int>::const_iterator >::type, int const);
|
||||||
STATIC_ASSERT_SAME(boost::pointee<std::list<X>::const_iterator >::type, X const);
|
STATIC_ASSERT_SAME(boost::pointee<std::list<X>::const_iterator >::type, X const);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ using boost::dummyT;
|
|||||||
// Test reverse iterator
|
// Test reverse iterator
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
dummyT array[] = { dummyT(0), dummyT(1), dummyT(2),
|
dummyT array[] = { dummyT(0), dummyT(1), dummyT(2),
|
||||||
dummyT(3), dummyT(4), dummyT(5) };
|
dummyT(3), dummyT(4), dummyT(5) };
|
||||||
const int N = sizeof(array)/sizeof(dummyT);
|
const int N = sizeof(array)/sizeof(dummyT);
|
||||||
|
|
||||||
@@ -104,29 +104,29 @@ int main()
|
|||||||
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Test reverse_iterator
|
// Test reverse_iterator
|
||||||
{
|
{
|
||||||
dummyT reversed[N];
|
dummyT reversed[N];
|
||||||
std::copy(array, array + N, reversed);
|
std::copy(array, array + N, reversed);
|
||||||
std::reverse(reversed, reversed + N);
|
std::reverse(reversed, reversed + N);
|
||||||
|
|
||||||
typedef boost::reverse_iterator<dummyT*> reverse_iterator;
|
typedef boost::reverse_iterator<dummyT*> reverse_iterator;
|
||||||
|
|
||||||
reverse_iterator i(reversed + N);
|
reverse_iterator i(reversed + N);
|
||||||
boost::random_access_iterator_test(i, N, array);
|
boost::random_access_iterator_test(i, N, array);
|
||||||
|
|
||||||
boost::random_access_iterator_test(boost::make_reverse_iterator(reversed + N), N, array);
|
boost::random_access_iterator_test(boost::make_reverse_iterator(reversed + N), N, array);
|
||||||
|
|
||||||
typedef boost::reverse_iterator<const dummyT*> const_reverse_iterator;
|
typedef boost::reverse_iterator<const dummyT*> const_reverse_iterator;
|
||||||
|
|
||||||
const_reverse_iterator j(reversed + N);
|
const_reverse_iterator j(reversed + N);
|
||||||
boost::random_access_iterator_test(j, N, array);
|
boost::random_access_iterator_test(j, N, array);
|
||||||
|
|
||||||
const dummyT* const_reversed = reversed;
|
const dummyT* const_reversed = reversed;
|
||||||
|
|
||||||
boost::random_access_iterator_test(boost::make_reverse_iterator(const_reversed + N), N, array);
|
boost::random_access_iterator_test(boost::make_reverse_iterator(const_reversed + N), N, array);
|
||||||
|
|
||||||
boost::const_nonconst_iterator_test(i, ++j);
|
boost::const_nonconst_iterator_test(i, ++j);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ int main()
|
|||||||
// (e.g. "reversed + N") is used in the constructor below.
|
// (e.g. "reversed + N") is used in the constructor below.
|
||||||
const std::deque<dummyT>::iterator finish = reversed_container.end();
|
const std::deque<dummyT>::iterator finish = reversed_container.end();
|
||||||
reverse_iterator i(finish);
|
reverse_iterator i(finish);
|
||||||
|
|
||||||
boost::random_access_iterator_test(i, N, array);
|
boost::random_access_iterator_test(i, N, array);
|
||||||
boost::random_access_iterator_test(boost::make_reverse_iterator(reversed + N), N, array);
|
boost::random_access_iterator_test(boost::make_reverse_iterator(reversed + N), N, array);
|
||||||
|
|
||||||
@@ -155,18 +155,18 @@ int main()
|
|||||||
|
|
||||||
const std::deque<dummyT>::const_iterator const_reversed = reversed;
|
const std::deque<dummyT>::const_iterator const_reversed = reversed;
|
||||||
boost::random_access_iterator_test(boost::make_reverse_iterator(const_reversed + N), N, array);
|
boost::random_access_iterator_test(boost::make_reverse_iterator(const_reversed + N), N, array);
|
||||||
|
|
||||||
// Many compilers' builtin deque iterators don't interoperate well, though
|
// Many compilers' builtin deque iterators don't interoperate well, though
|
||||||
// STLport fixes that problem.
|
// STLport fixes that problem.
|
||||||
#if defined(__SGI_STL_PORT) \
|
#if defined(__SGI_STL_PORT) \
|
||||||
|| !BOOST_WORKAROUND(__GNUC__, <= 2) \
|
|| !BOOST_WORKAROUND(__GNUC__, <= 2) \
|
||||||
&& !(BOOST_WORKAROUND(__GNUC__, == 3) && BOOST_WORKAROUND(__GNUC_MINOR__, <= 1)) \
|
&& !(BOOST_WORKAROUND(__GNUC__, == 3) && BOOST_WORKAROUND(__GNUC_MINOR__, <= 1)) \
|
||||||
&& !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) \
|
&& !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551)) \
|
||||||
&& !BOOST_WORKAROUND(__LIBCOMO_VERSION__, BOOST_TESTED_AT(29)) \
|
&& !BOOST_WORKAROUND(__LIBCOMO_VERSION__, BOOST_TESTED_AT(29)) \
|
||||||
&& !BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, <= 1)
|
&& !BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, <= 1)
|
||||||
|
|
||||||
boost::const_nonconst_iterator_test(i, ++j);
|
boost::const_nonconst_iterator_test(i, ++j);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
// Copyright 2003 The Trustees of Indiana University.
|
// Copyright 2003 The Trustees of Indiana University.
|
||||||
|
|
||||||
// Use, modification and distribution is subject to the Boost Software
|
// Use, modification and distribution is subject to the Boost Software
|
||||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// Shared container iterator adaptor
|
// Shared container iterator adaptor
|
||||||
// Author: Ronald Garcia
|
// Author: Ronald Garcia
|
||||||
// See http://boost.org/libs/utility/shared_container_iterator.html
|
// See http://boost.org/libs/utility/shared_container_iterator.html
|
||||||
// for documentation.
|
// for documentation.
|
||||||
|
|
||||||
//
|
//
|
||||||
// shared_iterator_test.cpp - Regression tests for shared_container_iterator.
|
// shared_iterator_test.cpp - Regression tests for shared_container_iterator.
|
||||||
@@ -38,7 +38,7 @@ void set_range(iterator& i, iterator& end) {
|
|||||||
|
|
||||||
for (int j = 0; j != 6; ++j)
|
for (int j = 0; j != 6; ++j)
|
||||||
objs->push_back(resource());
|
objs->push_back(resource());
|
||||||
|
|
||||||
i = iterator(objs->begin(),objs);
|
i = iterator(objs->begin(),objs);
|
||||||
end = iterator(objs->end(),objs);
|
end = iterator(objs->end(),objs);
|
||||||
BOOST_TEST_EQ(resource::count, 6);
|
BOOST_TEST_EQ(resource::count, 6);
|
||||||
@@ -48,7 +48,7 @@ void set_range(iterator& i, iterator& end) {
|
|||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
BOOST_TEST_EQ(resource::count, 0);
|
BOOST_TEST_EQ(resource::count, 0);
|
||||||
|
|
||||||
{
|
{
|
||||||
iterator i;
|
iterator i;
|
||||||
{
|
{
|
||||||
@@ -59,6 +59,6 @@ int main() {
|
|||||||
BOOST_TEST_EQ(resource::count, 6);
|
BOOST_TEST_EQ(resource::count, 6);
|
||||||
}
|
}
|
||||||
BOOST_TEST_EQ(resource::count, 0);
|
BOOST_TEST_EQ(resource::count, 0);
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,15 +5,15 @@
|
|||||||
#ifndef STATIC_ASSERT_SAME_DWA2003530_HPP
|
#ifndef STATIC_ASSERT_SAME_DWA2003530_HPP
|
||||||
# define STATIC_ASSERT_SAME_DWA2003530_HPP
|
# define STATIC_ASSERT_SAME_DWA2003530_HPP
|
||||||
|
|
||||||
#include <boost/mpl/assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
# include <boost/type_traits/is_same.hpp>
|
#include <boost/type_traits/is_same.hpp>
|
||||||
|
|
||||||
#define STATIC_ASSERT_SAME( T1,T2 ) BOOST_MPL_ASSERT((::boost::is_same< T1, T2 >))
|
#define STATIC_ASSERT_SAME( T1,T2 ) BOOST_STATIC_ASSERT((::boost::is_same< T1, T2 >::value))
|
||||||
|
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
struct static_assert_same
|
struct static_assert_same
|
||||||
{
|
{
|
||||||
BOOST_MPL_ASSERT((::boost::is_same< T1, T2 >));
|
STATIC_ASSERT_SAME(T1, T2);
|
||||||
enum { value = 1 };
|
enum { value = 1 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Copyright 2023 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
|
||||||
|
#
|
||||||
|
# NOTE: This does NOT run the unit tests for Boost.Atomic.
|
||||||
|
# It only tests if the CMakeLists.txt file in its root works as expected
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
project(BoostIteratorCMakeSelfTest)
|
||||||
|
|
||||||
|
# Use experimental superproject to pull library dependencies recursively
|
||||||
|
set(BOOST_ENABLE_CMAKE 1)
|
||||||
|
add_subdirectory(../../../.. "${CMAKE_CURRENT_BINARY_DIR}/boost_superproject")
|
||||||
|
|
||||||
|
add_definitions(-DBOOST_ALL_NO_LIB)
|
||||||
|
|
||||||
|
add_executable(boost_iterator_cmake_self_test main.cpp)
|
||||||
|
target_link_libraries(boost_iterator_cmake_self_test Boost::iterator)
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
// Copyright (c) 2023 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)
|
||||||
|
|
||||||
|
#include <boost/generator_iterator.hpp>
|
||||||
|
#include <boost/indirect_reference.hpp>
|
||||||
|
#include <boost/next_prior.hpp>
|
||||||
|
#include <boost/pointee.hpp>
|
||||||
|
#include <boost/shared_container_iterator.hpp>
|
||||||
|
#include <boost/iterator/advance.hpp>
|
||||||
|
#include <boost/iterator/counting_iterator.hpp>
|
||||||
|
#include <boost/iterator/distance.hpp>
|
||||||
|
#include <boost/iterator/filter_iterator.hpp>
|
||||||
|
#include <boost/iterator/function_input_iterator.hpp>
|
||||||
|
#include <boost/iterator/function_output_iterator.hpp>
|
||||||
|
#include <boost/iterator/indirect_iterator.hpp>
|
||||||
|
#include <boost/iterator/interoperable.hpp>
|
||||||
|
#include <boost/iterator/is_iterator.hpp>
|
||||||
|
#include <boost/iterator/is_lvalue_iterator.hpp>
|
||||||
|
#include <boost/iterator/is_readable_iterator.hpp>
|
||||||
|
#include <boost/iterator/iterator_adaptor.hpp>
|
||||||
|
#include <boost/iterator/iterator_archetypes.hpp>
|
||||||
|
#include <boost/iterator/iterator_categories.hpp>
|
||||||
|
#include <boost/iterator/iterator_concepts.hpp>
|
||||||
|
#include <boost/iterator/iterator_facade.hpp>
|
||||||
|
#include <boost/iterator/iterator_traits.hpp>
|
||||||
|
#include <boost/iterator/minimum_category.hpp>
|
||||||
|
#include <boost/iterator/new_iterator_tests.hpp>
|
||||||
|
#include <boost/iterator/permutation_iterator.hpp>
|
||||||
|
#include <boost/iterator/reverse_iterator.hpp>
|
||||||
|
#include <boost/iterator/transform_iterator.hpp>
|
||||||
|
#include <boost/iterator/zip_iterator.hpp>
|
||||||
|
|
||||||
|
template< typename Iterator >
|
||||||
|
class adapted_iterator :
|
||||||
|
public boost::iterators::iterator_adaptor< adapted_iterator< Iterator >, Iterator >
|
||||||
|
{
|
||||||
|
friend class iterator_core_access;
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef boost::iterators::iterator_adaptor< adapted_iterator< Iterator >, Iterator > base_type;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit adapted_iterator(Iterator it) : base_type(it) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
unsigned char buf[8];
|
||||||
|
adapted_iterator< unsigned char* > b(buf), e(buf + sizeof(buf));
|
||||||
|
return boost::iterators::distance(b, e) == static_cast< adapted_iterator< unsigned char* >::difference_type >(sizeof(buf));
|
||||||
|
}
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
#include <boost/iterator/iterator_concepts.hpp>
|
#include <boost/iterator/iterator_concepts.hpp>
|
||||||
#include <boost/iterator/new_iterator_tests.hpp>
|
#include <boost/iterator/new_iterator_tests.hpp>
|
||||||
#include <boost/pending/iterator_tests.hpp>
|
#include <boost/pending/iterator_tests.hpp>
|
||||||
#include <boost/bind.hpp>
|
|
||||||
#include <boost/concept_check.hpp>
|
#include <boost/concept_check.hpp>
|
||||||
|
|
||||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||||
@@ -43,7 +42,7 @@ struct mult_functor {
|
|||||||
int a;
|
int a;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct adaptable_mult_functor
|
struct adaptable_mult_functor
|
||||||
: mult_functor
|
: mult_functor
|
||||||
{
|
{
|
||||||
typedef int result_type;
|
typedef int result_type;
|
||||||
@@ -114,9 +113,9 @@ struct polymorphic_mult_functor
|
|||||||
template <class F, class T> struct result<F(T& )> {typedef void type;};
|
template <class F, class T> struct result<F(T& )> {typedef void type;};
|
||||||
template <class F, class T> struct result<F(const T&)> {typedef void type;};
|
template <class F, class T> struct result<F(const T&)> {typedef void type;};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
T operator()(const T& _arg) const {return _arg*2;}
|
T operator()(const T& _arg) const {return _arg*2;}
|
||||||
template <class T>
|
template <class T>
|
||||||
void operator()(const T& _arg) { BOOST_ASSERT(0); }
|
void operator()(const T& _arg) { BOOST_ASSERT(0); }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -139,15 +138,15 @@ main()
|
|||||||
for (int k = 0; k < N; ++k)
|
for (int k = 0; k < N; ++k)
|
||||||
x[k] = k;
|
x[k] = k;
|
||||||
std::copy(x, x + N, y);
|
std::copy(x, x + N, y);
|
||||||
|
|
||||||
for (int k2 = 0; k2 < N; ++k2)
|
for (int k2 = 0; k2 < N; ++k2)
|
||||||
x[k2] = x[k2] * 2;
|
x[k2] = x[k2] * 2;
|
||||||
|
|
||||||
typedef boost::transform_iterator<adaptable_mult_functor, int*> iter_t;
|
typedef boost::transform_iterator<adaptable_mult_functor, int*> iter_t;
|
||||||
iter_t i(y, adaptable_mult_functor(2));
|
iter_t i(y, adaptable_mult_functor(2));
|
||||||
boost::input_iterator_test(i, x[0], x[1]);
|
boost::input_iterator_test(i, x[0], x[1]);
|
||||||
boost::input_iterator_test(iter_t(&y[0], adaptable_mult_functor(2)), x[0], x[1]);
|
boost::input_iterator_test(iter_t(&y[0], adaptable_mult_functor(2)), x[0], x[1]);
|
||||||
|
|
||||||
boost::random_access_readable_iterator_test(i, N, x);
|
boost::random_access_readable_iterator_test(i, N, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,15 +156,15 @@ main()
|
|||||||
for (int k = 0; k < N; ++k)
|
for (int k = 0; k < N; ++k)
|
||||||
x[k] = k;
|
x[k] = k;
|
||||||
std::copy(x, x + N, y);
|
std::copy(x, x + N, y);
|
||||||
|
|
||||||
for (int k2 = 0; k2 < N; ++k2)
|
for (int k2 = 0; k2 < N; ++k2)
|
||||||
x[k2] = x[k2] * 2;
|
x[k2] = x[k2] * 2;
|
||||||
|
|
||||||
typedef boost::transform_iterator<mult_functor, int*, int> iter_t;
|
typedef boost::transform_iterator<mult_functor, int*, int> iter_t;
|
||||||
iter_t i(y, mult_functor(2));
|
iter_t i(y, mult_functor(2));
|
||||||
boost::input_iterator_test(i, x[0], x[1]);
|
boost::input_iterator_test(i, x[0], x[1]);
|
||||||
boost::input_iterator_test(iter_t(&y[0], mult_functor(2)), x[0], x[1]);
|
boost::input_iterator_test(iter_t(&y[0], mult_functor(2)), x[0], x[1]);
|
||||||
|
|
||||||
boost::random_access_readable_iterator_test(i, N, x);
|
boost::random_access_readable_iterator_test(i, N, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,16 +195,16 @@ main()
|
|||||||
for (int k = 0; k < N; ++k)
|
for (int k = 0; k < N; ++k)
|
||||||
x[k] = k;
|
x[k] = k;
|
||||||
std::copy(x, x + N, y);
|
std::copy(x, x + N, y);
|
||||||
|
|
||||||
for (int k2 = 0; k2 < N; ++k2)
|
for (int k2 = 0; k2 < N; ++k2)
|
||||||
x[k2] = x[k2] * 2;
|
x[k2] = x[k2] * 2;
|
||||||
|
|
||||||
boost::input_iterator_test(
|
boost::input_iterator_test(
|
||||||
boost::make_transform_iterator(y, mult_2), x[0], x[1]);
|
boost::make_transform_iterator(y, mult_2), x[0], x[1]);
|
||||||
|
|
||||||
boost::input_iterator_test(
|
boost::input_iterator_test(
|
||||||
boost::make_transform_iterator(&y[0], mult_2), x[0], x[1]);
|
boost::make_transform_iterator(&y[0], mult_2), x[0], x[1]);
|
||||||
|
|
||||||
boost::random_access_readable_iterator_test(
|
boost::random_access_readable_iterator_test(
|
||||||
boost::make_transform_iterator(y, mult_2), N, x);
|
boost::make_transform_iterator(y, mult_2), N, x);
|
||||||
|
|
||||||
@@ -250,7 +249,7 @@ main()
|
|||||||
);
|
);
|
||||||
|
|
||||||
boost::constant_lvalue_iterator_test(
|
boost::constant_lvalue_iterator_test(
|
||||||
boost::make_transform_iterator((pair_t*)values, const_select_first()), x[0]);
|
boost::make_transform_iterator((pair_t*)values, const_select_first()), x[0]);
|
||||||
|
|
||||||
boost::non_const_lvalue_iterator_test(
|
boost::non_const_lvalue_iterator_test(
|
||||||
boost::make_transform_iterator((pair_t*)values, select_first()), x[0], 17);
|
boost::make_transform_iterator((pair_t*)values, select_first()), x[0], 17);
|
||||||
@@ -267,16 +266,16 @@ main()
|
|||||||
for (int k = 0; k < N; ++k)
|
for (int k = 0; k < N; ++k)
|
||||||
x[k] = k;
|
x[k] = k;
|
||||||
std::copy(x, x + N, y);
|
std::copy(x, x + N, y);
|
||||||
|
|
||||||
for (int k2 = 0; k2 < N; ++k2)
|
for (int k2 = 0; k2 < N; ++k2)
|
||||||
x[k2] = x[k2] * 2;
|
x[k2] = x[k2] * 2;
|
||||||
|
|
||||||
boost::input_iterator_test(
|
boost::input_iterator_test(
|
||||||
boost::make_transform_iterator(y, polymorphic_mult_functor()), x[0], x[1]);
|
boost::make_transform_iterator(y, polymorphic_mult_functor()), x[0], x[1]);
|
||||||
|
|
||||||
boost::input_iterator_test(
|
boost::input_iterator_test(
|
||||||
boost::make_transform_iterator(&y[0], polymorphic_mult_functor()), x[0], x[1]);
|
boost::make_transform_iterator(&y[0], polymorphic_mult_functor()), x[0], x[1]);
|
||||||
|
|
||||||
boost::random_access_readable_iterator_test(
|
boost::random_access_readable_iterator_test(
|
||||||
boost::make_transform_iterator(y, polymorphic_mult_functor()), N, x);
|
boost::make_transform_iterator(y, polymorphic_mult_functor()), N, x);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
// libstdc++ from gcc 4.4 has a broken std::tuple that cannot be constructed from a compatible tuple,
|
||||||
|
// e.g. std::tuple<int, double> from std::tuple<int const&, double const&>.
|
||||||
|
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
|
||||||
|
(!defined(BOOST_LIBSTDCXX_VERSION) || BOOST_LIBSTDCXX_VERSION >= 40500)
|
||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <boost/fusion/adapted/std_tuple.hpp>
|
#include <boost/fusion/adapted/std_tuple.hpp>
|
||||||
@@ -14,8 +17,8 @@
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user