mirror of
https://github.com/boostorg/iterator.git
synced 2026-08-26 15:17:38 +02:00
Compare commits
23
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2732300e8 | ||
|
|
0316628863 | ||
|
|
286c9885d6 | ||
|
|
4dcba468e2 | ||
|
|
b74b553482 | ||
|
|
2a4dbd1d8d | ||
|
|
e16399b613 | ||
|
|
ecf4ed8bf5 | ||
|
|
248494330d | ||
|
|
ca0e772d2a | ||
|
|
2a0b753691 | ||
|
|
0087a426d9 | ||
|
|
c409288ff5 | ||
|
|
01ac4e1a47 | ||
|
|
e968c3312b | ||
|
|
da00617e56 | ||
|
|
7c77e52509 | ||
|
|
256004a446 | ||
|
|
7e3e9a584e | ||
|
|
3767696513 | ||
|
|
1372e9afb6 | ||
|
|
6428e552e4 | ||
|
|
766c881f9a |
+104
-79
@@ -1,4 +1,4 @@
|
||||
# Copyright 2021-2025 Andrey Semashev
|
||||
# Copyright 2021-2026 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)
|
||||
@@ -33,18 +33,6 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
# Linux, gcc
|
||||
- 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
|
||||
@@ -71,22 +59,26 @@ jobs:
|
||||
- g++-8
|
||||
- toolset: gcc-9
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:20.04
|
||||
install:
|
||||
- g++-9
|
||||
- toolset: gcc-10
|
||||
cxxstd: "11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:20.04
|
||||
install:
|
||||
- g++-10
|
||||
- toolset: gcc-11
|
||||
cxxstd: "11,14,17,20,23"
|
||||
os: ubuntu-22.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:22.04
|
||||
install:
|
||||
- g++-11
|
||||
- toolset: gcc-12
|
||||
cxxstd: "11,14,17,20,23"
|
||||
os: ubuntu-22.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:22.04
|
||||
install:
|
||||
- g++-12
|
||||
- toolset: gcc-13
|
||||
@@ -99,14 +91,24 @@ jobs:
|
||||
os: ubuntu-24.04
|
||||
install:
|
||||
- g++-14
|
||||
- toolset: gcc-15
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
os: ubuntu-26.04
|
||||
install:
|
||||
- g++-15
|
||||
- toolset: gcc-16
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
os: ubuntu-26.04
|
||||
install:
|
||||
- g++-16
|
||||
- name: UBSAN
|
||||
toolset: gcc-13
|
||||
cxxstd: "11,14,17,20,23"
|
||||
toolset: gcc-15
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
ubsan: 1
|
||||
build_variant: debug
|
||||
os: ubuntu-24.04
|
||||
os: ubuntu-26.04
|
||||
install:
|
||||
- g++-13
|
||||
- g++-15
|
||||
|
||||
# Linux, clang
|
||||
- toolset: clang
|
||||
@@ -185,19 +187,22 @@ jobs:
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:20.04
|
||||
install:
|
||||
- clang-9
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:20.04
|
||||
install:
|
||||
- clang-10
|
||||
- toolset: clang
|
||||
compiler: clang++-11
|
||||
cxxstd: "11,14,17,20"
|
||||
os: ubuntu-22.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:22.04
|
||||
install:
|
||||
- clang-11
|
||||
- g++-11
|
||||
@@ -205,7 +210,8 @@ jobs:
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:22.04
|
||||
install:
|
||||
- clang-12
|
||||
- g++-11
|
||||
@@ -213,7 +219,8 @@ jobs:
|
||||
- toolset: clang
|
||||
compiler: clang++-13
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:22.04
|
||||
install:
|
||||
- clang-13
|
||||
- g++-11
|
||||
@@ -221,7 +228,8 @@ jobs:
|
||||
- toolset: clang
|
||||
compiler: clang++-14
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:22.04
|
||||
install:
|
||||
- clang-14
|
||||
- g++-11
|
||||
@@ -229,7 +237,8 @@ jobs:
|
||||
- toolset: clang
|
||||
compiler: clang++-15
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:22.04
|
||||
install:
|
||||
- clang-15
|
||||
- g++-11
|
||||
@@ -263,51 +272,61 @@ jobs:
|
||||
os: ubuntu-24.04
|
||||
install:
|
||||
- clang-19
|
||||
sources:
|
||||
- "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main"
|
||||
source_keys:
|
||||
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
- toolset: clang
|
||||
compiler: clang++-19
|
||||
compiler: clang++-20
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
os: ubuntu-24.04
|
||||
os: ubuntu-26.04
|
||||
install:
|
||||
- clang-19
|
||||
- libc++-19-dev
|
||||
- libc++abi-19-dev
|
||||
sources:
|
||||
- "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main"
|
||||
source_keys:
|
||||
- "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
- clang-20
|
||||
- toolset: clang
|
||||
compiler: clang++-21
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
os: ubuntu-26.04
|
||||
install:
|
||||
- clang-21
|
||||
- toolset: clang
|
||||
compiler: clang++-22
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
os: ubuntu-26.04
|
||||
install:
|
||||
- clang-22
|
||||
- toolset: clang
|
||||
compiler: clang++-22
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
os: ubuntu-26.04
|
||||
install:
|
||||
- clang-22
|
||||
- libc++-22-dev
|
||||
- libc++abi-22-dev
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
- name: UBSAN
|
||||
toolset: clang
|
||||
compiler: clang++-18
|
||||
compiler: clang++-22
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: "-stdlib=libc++ -lubsan"
|
||||
ubsan: 1
|
||||
build_variant: debug
|
||||
os: ubuntu-24.04
|
||||
os: ubuntu-26.04
|
||||
install:
|
||||
- clang-18
|
||||
- libc++-18-dev
|
||||
- libc++abi-18-dev
|
||||
- clang-22
|
||||
- libc++-22-dev
|
||||
- libc++abi-22-dev
|
||||
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-13
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-14
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
- toolset: clang
|
||||
os: macos-15
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
- toolset: clang
|
||||
os: macos-26
|
||||
cxxstd: "11,14,17,20,23,26"
|
||||
|
||||
- name: CMake tests
|
||||
cmake_tests: 1
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-24.04
|
||||
|
||||
timeout-minutes: 20
|
||||
runs-on: ${{matrix.os}}
|
||||
@@ -326,6 +345,22 @@ jobs:
|
||||
echo "GHA_CONTAINER=${{matrix.container}}" >> $GITHUB_ENV
|
||||
if [ -f "/etc/debian_version" ]
|
||||
then
|
||||
# Use Azure APT mirrors in containers to avoid HTTP errors due to DDoS filters triggered by lots of CI jobs launching concurrently.
|
||||
# Note that not all Ubuntu versions support "mirror+file:..." URIs in APT sources, so just use Azure mirrors exclusively.
|
||||
# Note also that on recent Ubuntu versions DEB822 format is used for source files.
|
||||
APT_SOURCES=()
|
||||
if [ -d "/etc/apt/sources.list.d" ]
|
||||
then
|
||||
readarray -t APT_SOURCES < <(find "/etc/apt/sources.list.d" -type f -name '*.sources' -print)
|
||||
fi
|
||||
if [ -f "/etc/apt/sources.list" ]
|
||||
then
|
||||
APT_SOURCES+=("/etc/apt/sources.list")
|
||||
fi
|
||||
if [ "${#APT_SOURCES[@]}" -gt 0 ]
|
||||
then
|
||||
sed -i -E -e 's!([^ ]+) (http|https)://(archive|security)\.ubuntu\.com/ubuntu[^ ]*(.*)!\1 http://azure.archive.ubuntu.com/ubuntu/\4!' "${APT_SOURCES[@]}"
|
||||
fi
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
if [ "$(apt-cache search "^python-is-python3$" | wc -l)" -ne 0 ]
|
||||
then
|
||||
@@ -423,6 +458,7 @@ jobs:
|
||||
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
|
||||
echo BUILD_JOBS: $BUILD_JOBS
|
||||
DEPINST_ARGS=()
|
||||
GIT_VERSION="$(git --version | sed -e 's/git version //')"
|
||||
GIT_HAS_JOBS=1
|
||||
@@ -474,25 +510,22 @@ jobs:
|
||||
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
|
||||
./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
|
||||
B2_ARGS=("-j" "$BUILD_JOBS" "toolset=${{matrix.toolset}}" "cxxstd=${{matrix.cxxstd}}")
|
||||
if [ -n "${{matrix.build_variant}}" ]
|
||||
then
|
||||
@@ -507,7 +540,7 @@ jobs:
|
||||
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")
|
||||
B2_ARGS+=("cxxflags=-fsanitize=undefined -fno-sanitize-recover=undefined" "linkflags=-fsanitize=undefined" "define=UBSAN=1" "debug-symbols=on" "visibility=global")
|
||||
fi
|
||||
if [ -n "${{matrix.cxxflags}}" ]
|
||||
then
|
||||
@@ -545,14 +578,6 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc-14.0
|
||||
cxxstd: "14"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.2
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.3
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
@@ -562,9 +587,9 @@ jobs:
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: gcc
|
||||
cxxstd: "11,14,17,2a"
|
||||
cxxstd: "11,14,17,20,23"
|
||||
addrmd: 64
|
||||
os: windows-2019
|
||||
os: windows-2022
|
||||
|
||||
timeout-minutes: 20
|
||||
runs-on: ${{matrix.os}}
|
||||
@@ -602,12 +627,12 @@ jobs:
|
||||
rmdir /s /q "..\snapshot"
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd boost-root
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
if not "${{matrix.cxxstd}}" == "" set CXXSTD=cxxstd=${{matrix.cxxstd}}
|
||||
if not "${{matrix.addrmd}}" == "" set ADDRMD=address-model=${{matrix.addrmd}}
|
||||
if not "${{matrix.build_variant}}" == "" (set BUILD_VARIANT=variant=${{matrix.build_variant}}) else (set BUILD_VARIANT=variant=%DEFAULT_BUILD_VARIANT%)
|
||||
|
||||
@@ -19,8 +19,8 @@ Boost.Iterator, part of collection of the [Boost C++ Libraries](https://github.c
|
||||
|
||||
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)
|
||||
[`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) | [](https://regression.boost.io/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) | [](https://regression.boost.io/develop/developer/iterator.html) | [](https://pdimov.github.io/boostdep-report/develop/iterator.html)
|
||||
|
||||
### License
|
||||
|
||||
|
||||
+9
-6
@@ -32,9 +32,15 @@ environment:
|
||||
CXXSTD: 14,17,20,latest
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
|
||||
- TOOLSET: clang-win
|
||||
ADDRMD: 32,64
|
||||
ADDRMD: 32
|
||||
CXXSTD: 14,17,latest
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
ENV_SCRIPT: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
- TOOLSET: clang-win
|
||||
ADDRMD: 64
|
||||
CXXSTD: 14,17,latest
|
||||
ENV_SCRIPT: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
- TOOLSET: gcc
|
||||
CXXSTD: 11,14,1z
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
@@ -43,10 +49,6 @@ environment:
|
||||
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;
|
||||
@@ -80,6 +82,7 @@ build: off
|
||||
|
||||
test_script:
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
- if not "%ENV_SCRIPT%" == "" call "%ENV_SCRIPT%"
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||
- b2 -j %NUMBER_OF_PROCESSORS% libs/iterator/test toolset=%TOOLSET% %CXXSTD% %ADDRMD%
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
#ifndef BOOST_ITERATOR_ADVANCE_HPP
|
||||
#define BOOST_ITERATOR_ADVANCE_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/iterator/is_iterator.hpp>
|
||||
#include <boost/iterator/iterator_categories.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -56,7 +59,8 @@ inline BOOST_CXX14_CONSTEXPR void advance_impl(RandomAccessIterator& it, Distanc
|
||||
namespace advance_adl_barrier {
|
||||
|
||||
template< typename InputIterator, typename Distance >
|
||||
inline BOOST_CXX14_CONSTEXPR void advance(InputIterator& it, Distance n)
|
||||
inline BOOST_CXX14_CONSTEXPR typename std::enable_if< is_iterator< InputIterator >::value >::type
|
||||
advance(InputIterator& it, Distance n)
|
||||
{
|
||||
detail::advance_impl(it, n, typename iterator_traversal< InputIterator >::type());
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Copyright (C) 2017 Michel Morin.
|
||||
// Copyright (C) 2026 Jeremy W. Murphy
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -7,7 +8,10 @@
|
||||
#ifndef BOOST_ITERATOR_DISTANCE_HPP
|
||||
#define BOOST_ITERATOR_DISTANCE_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/iterator/is_iterator.hpp>
|
||||
#include <boost/iterator/iterator_categories.hpp>
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
|
||||
@@ -40,8 +44,10 @@ distance_impl(RandomAccessIterator first, RandomAccessIterator last, random_acce
|
||||
namespace distance_adl_barrier {
|
||||
|
||||
template< typename SinglePassIterator >
|
||||
inline BOOST_CXX14_CONSTEXPR typename iterator_difference< SinglePassIterator >::type
|
||||
distance(SinglePassIterator first, SinglePassIterator last)
|
||||
inline BOOST_CXX14_CONSTEXPR typename std::enable_if<
|
||||
is_iterator< SinglePassIterator >::value,
|
||||
iterator_difference< SinglePassIterator >
|
||||
>::type::type distance(SinglePassIterator first, SinglePassIterator last)
|
||||
{
|
||||
return detail::distance_impl(first, last, typename iterator_traversal< SinglePassIterator >::type());
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
|
||||
template< typename OtherIterator, typename = enable_if_convertible_t< OtherIterator, Iterator > >
|
||||
filter_iterator(filter_iterator< Predicate, OtherIterator > const& t) :
|
||||
super_t(t.base()), m_storage(t.m_storage.predicate(), m_storage.m_end)
|
||||
super_t(t.base()), m_storage(t.m_storage.predicate(), t.m_storage.m_end)
|
||||
{}
|
||||
|
||||
Predicate predicate() const { return m_storage.predicate(); }
|
||||
|
||||
@@ -139,10 +139,19 @@ 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 {};
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
template< typename T >
|
||||
BOOST_INLINE_VARIABLE constexpr bool is_iterator_v = iterators::is_iterator< T >::value;
|
||||
#endif // !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
|
||||
} // namespace iterators
|
||||
|
||||
using iterators::is_iterator;
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
using iterators::is_iterator_v;
|
||||
#endif // !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ITERATOR_IS_ITERATOR_HPP_INCLUDED_
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#ifndef IS_LVALUE_ITERATOR_DWA2003112_HPP
|
||||
#define IS_LVALUE_ITERATOR_DWA2003112_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/iterator/detail/type_traits/conjunction.hpp>
|
||||
|
||||
#include <iterator>
|
||||
@@ -71,11 +72,23 @@ struct is_non_const_lvalue_iterator :
|
||||
{
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
template< typename T >
|
||||
BOOST_INLINE_VARIABLE constexpr bool is_lvalue_iterator_v = iterators::is_lvalue_iterator< T >::value;
|
||||
template< typename T >
|
||||
BOOST_INLINE_VARIABLE constexpr bool is_non_const_lvalue_iterator_v = iterators::is_non_const_lvalue_iterator< T >::value;
|
||||
#endif // !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
|
||||
} // namespace iterators
|
||||
|
||||
using iterators::is_lvalue_iterator;
|
||||
using iterators::is_non_const_lvalue_iterator;
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
using iterators::is_lvalue_iterator_v;
|
||||
using iterators::is_non_const_lvalue_iterator_v;
|
||||
#endif // !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // IS_LVALUE_ITERATOR_DWA2003112_HPP
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace iterators {
|
||||
@@ -60,10 +61,19 @@ struct is_readable_iterator :
|
||||
{
|
||||
};
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
template< typename T >
|
||||
BOOST_INLINE_VARIABLE constexpr bool is_readable_iterator_v = iterators::is_readable_iterator< T >::value;
|
||||
#endif // !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
|
||||
} // namespace iterators
|
||||
|
||||
using iterators::is_readable_iterator;
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
using iterators::is_readable_iterator_v;
|
||||
#endif // !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // IS_READABLE_ITERATOR_DWA2003112_HPP
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
@@ -346,63 +347,52 @@ class operator_brackets_proxy
|
||||
// Iterator is actually an iterator_facade, so we do not have to
|
||||
// go through iterator_traits to access the traits.
|
||||
using reference = typename Iterator::reference;
|
||||
using value_type = typename Iterator::value_type;
|
||||
|
||||
public:
|
||||
operator_brackets_proxy(Iterator const& iter) :
|
||||
explicit operator_brackets_proxy(Iterator const& iter) noexcept(std::is_nothrow_copy_constructible< Iterator >::value) :
|
||||
m_iter(iter)
|
||||
{}
|
||||
|
||||
operator reference() const
|
||||
operator reference() const noexcept(noexcept(*std::declval< Iterator const& >()))
|
||||
{
|
||||
return *m_iter;
|
||||
}
|
||||
|
||||
operator_brackets_proxy& operator=(value_type const& val)
|
||||
template< typename T >
|
||||
typename std::enable_if<
|
||||
detail::conjunction<
|
||||
detail::negation<
|
||||
std::is_same<
|
||||
operator_brackets_proxy< Iterator >,
|
||||
typename std::remove_cv< typename std::remove_reference< T >::type >::type
|
||||
>
|
||||
>,
|
||||
std::is_assignable< reference, T&& >
|
||||
>::value,
|
||||
operator_brackets_proxy&
|
||||
>::type operator= (T&& val) noexcept(noexcept(*std::declval< Iterator& >() = std::declval< T&& >()))
|
||||
{
|
||||
*m_iter = val;
|
||||
*m_iter = static_cast< T&& >(val);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Provides it[n]->foo(). Leverages chaining of operator->.
|
||||
reference operator->() const noexcept(noexcept(*std::declval< Iterator const& >()))
|
||||
{
|
||||
return *m_iter;
|
||||
}
|
||||
|
||||
// Provides (*it[n]).foo()
|
||||
template< typename Ref = reference, typename Result = decltype(*std::declval< Ref >()) >
|
||||
Result operator*() const noexcept(noexcept(**std::declval< Iterator const& >()))
|
||||
{
|
||||
return **m_iter;
|
||||
}
|
||||
|
||||
private:
|
||||
Iterator m_iter;
|
||||
};
|
||||
|
||||
// A metafunction that determines whether operator[] must return a
|
||||
// proxy, or whether it can simply return a copy of the value_type.
|
||||
template< typename ValueType, typename Reference >
|
||||
struct use_operator_brackets_proxy :
|
||||
public detail::negation<
|
||||
detail::conjunction<
|
||||
std::is_copy_constructible< ValueType >,
|
||||
std::is_trivial< ValueType >,
|
||||
iterator_writability_disabled< ValueType, Reference >
|
||||
>
|
||||
>
|
||||
{};
|
||||
|
||||
template< typename Iterator, typename Value, typename Reference >
|
||||
struct operator_brackets_result
|
||||
{
|
||||
using type = typename std::conditional<
|
||||
use_operator_brackets_proxy<Value, Reference>::value,
|
||||
operator_brackets_proxy<Iterator>,
|
||||
Value
|
||||
>::type;
|
||||
};
|
||||
|
||||
template< typename Iterator >
|
||||
inline operator_brackets_proxy<Iterator> make_operator_brackets_result(Iterator const& iter, std::true_type)
|
||||
{
|
||||
return operator_brackets_proxy< Iterator >(iter);
|
||||
}
|
||||
|
||||
template< typename Iterator >
|
||||
inline typename Iterator::value_type make_operator_brackets_result(Iterator const& iter, std::false_type)
|
||||
{
|
||||
return *iter;
|
||||
}
|
||||
|
||||
// A binary metafunction class that always returns bool.
|
||||
template< typename Iterator1, typename Iterator2 >
|
||||
using always_bool_t = bool;
|
||||
@@ -679,13 +669,9 @@ public:
|
||||
using difference_type = typename base_type::difference_type;
|
||||
|
||||
public:
|
||||
typename boost::iterators::detail::operator_brackets_result< Derived, Value, reference >::type
|
||||
operator[](difference_type n) const
|
||||
operator_brackets_proxy< Derived > operator[](difference_type n) const
|
||||
{
|
||||
return boost::iterators::detail::make_operator_brackets_result< Derived >(
|
||||
this->derived() + n,
|
||||
std::integral_constant< bool, boost::iterators::detail::use_operator_brackets_proxy< Value, Reference >::value >{}
|
||||
);
|
||||
return operator_brackets_proxy< Derived >(this->derived() + n);
|
||||
}
|
||||
|
||||
Derived& operator+=(difference_type n)
|
||||
|
||||
@@ -57,7 +57,7 @@ private:
|
||||
std::remove_reference< reference >
|
||||
>;
|
||||
|
||||
public:
|
||||
public:
|
||||
using type = iterator_adaptor<
|
||||
transform_iterator< UnaryFunc, Iterator, Reference, Value >,
|
||||
Iterator,
|
||||
|
||||
+1
-1
@@ -15,5 +15,5 @@
|
||||
"Thomas Witt <witt - at - acm.org>",
|
||||
"Jeffrey Lee Hellrung Jr. <jeffrey.hellrung -at- gmail.com>"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
"cxxstd": "11"
|
||||
}
|
||||
|
||||
@@ -20,6 +20,20 @@ void test_advance(Iterator it_from, Iterator it_to, int n)
|
||||
BOOST_TEST(it_from == it_to);
|
||||
}
|
||||
|
||||
// Definitely not an iterator
|
||||
struct Foo
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
// Don't use type "int" for "n", otherwise it matches literal int exactly
|
||||
// and doesn't demonstrate the effect of enable_if.
|
||||
friend
|
||||
void advance(Foo &value, long n)
|
||||
{
|
||||
value.x += 10 * n;
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
int array[3] = {1, 2, 3};
|
||||
@@ -87,5 +101,12 @@ int main()
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
using boost::advance;
|
||||
Foo bar;
|
||||
advance(bar, 3);
|
||||
BOOST_TEST(bar.x == 30);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <boost/container/slist.hpp>
|
||||
@@ -19,6 +20,13 @@ void test_distance(Iterator it_from, Iterator it_to, int n)
|
||||
BOOST_TEST(boost::distance(it_from, it_to) == n);
|
||||
}
|
||||
|
||||
// Definitely not an iterator.
|
||||
struct Foo
|
||||
{
|
||||
constexpr friend
|
||||
std::ptrdiff_t distance(Foo const &, Foo const &) { return -1; }
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
int array[3] = {1, 2, 3};
|
||||
@@ -80,5 +88,11 @@ int main()
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
// Make boost::distance visible since we're not actually in the boost namespace here.
|
||||
using boost::distance;
|
||||
auto result = distance(Foo{}, Foo{});
|
||||
BOOST_TEST(result == -1);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iterator>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/iterator/iterator_adaptor.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
@@ -160,5 +161,25 @@ int main()
|
||||
BOOST_TEST(!boost::iterators::is_iterator< int (&)(int) >::value);
|
||||
BOOST_TEST(!boost::iterators::is_iterator< int (&)[10] >::value);
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
BOOST_TEST(boost::iterators::is_iterator_v< int* >);
|
||||
BOOST_TEST(boost::iterators::is_iterator_v< const int* >);
|
||||
BOOST_TEST(boost::iterators::is_iterator_v< complete* >);
|
||||
BOOST_TEST(boost::iterators::is_iterator_v< std::reverse_iterator< int* > >);
|
||||
BOOST_TEST(boost::iterators::is_iterator_v< std::reverse_iterator< complete* > >);
|
||||
BOOST_TEST(boost::iterators::is_iterator_v< adapted_iterator< int* > >);
|
||||
|
||||
BOOST_TEST(!boost::iterators::is_iterator_v< int >);
|
||||
BOOST_TEST(!boost::iterators::is_iterator_v< void* >);
|
||||
BOOST_TEST(!boost::iterators::is_iterator_v< int (int) >);
|
||||
BOOST_TEST(!boost::iterators::is_iterator_v< int (*)(int) >);
|
||||
BOOST_TEST(!boost::iterators::is_iterator_v< int complete::* >);
|
||||
BOOST_TEST(!boost::iterators::is_iterator_v< int (complete::*)(int) >);
|
||||
BOOST_TEST(!boost::iterators::is_iterator_v< int*[] >);
|
||||
BOOST_TEST(!boost::iterators::is_iterator_v< int*[10] >);
|
||||
BOOST_TEST(!boost::iterators::is_iterator_v< int& >);
|
||||
BOOST_TEST(!boost::iterators::is_iterator_v< int*& >);
|
||||
#endif // !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
// subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/iterator/is_lvalue_iterator.hpp>
|
||||
#include <deque>
|
||||
#include <iterator>
|
||||
#include <cstddef> // std::ptrdiff_t
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/iterator/is_lvalue_iterator.hpp>
|
||||
|
||||
struct v
|
||||
{
|
||||
@@ -168,5 +169,25 @@ int main()
|
||||
static_assert(!boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<float>>::value,
|
||||
"boost::is_non_const_lvalue_iterator<constant_lvalue_iterator<float>>::value is expected to be false.");
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
static_assert(boost::is_lvalue_iterator_v<v*>,
|
||||
"boost::is_lvalue_iterator_v<v*> is expected to be true.");
|
||||
static_assert(boost::is_lvalue_iterator_v<v const*>,
|
||||
"boost::is_lvalue_iterator_v<v const*> is expected to be true.");
|
||||
static_assert(!boost::is_lvalue_iterator_v<proxy_iterator<int>>,
|
||||
"boost::is_lvalue_iterator_v<proxy_iterator<int>> is expected to be false.");
|
||||
static_assert(!boost::is_lvalue_iterator_v<value_iterator>,
|
||||
"boost::is_lvalue_iterator_v<value_iterator> is expected to be false.");
|
||||
|
||||
static_assert(boost::is_non_const_lvalue_iterator_v<v*>,
|
||||
"boost::is_non_const_lvalue_iterator_v<v*> is expected to be true.");
|
||||
static_assert(!boost::is_non_const_lvalue_iterator_v<v const*>,
|
||||
"boost::is_non_const_lvalue_iterator_v<v const*> is expected to be false.");
|
||||
static_assert(!boost::is_non_const_lvalue_iterator_v<proxy_iterator<int>>,
|
||||
"boost::is_non_const_lvalue_iterator_v<proxy_iterator<int>> is expected to be false.");
|
||||
static_assert(!boost::is_non_const_lvalue_iterator_v<value_iterator>,
|
||||
"boost::is_non_const_lvalue_iterator_v<value_iterator> is expected to be false.");
|
||||
#endif // !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
// subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/iterator/is_readable_iterator.hpp>
|
||||
#include <deque>
|
||||
#include <iterator>
|
||||
#include <cstddef> // std::ptrdiff_t
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/iterator/is_readable_iterator.hpp>
|
||||
|
||||
struct v
|
||||
{
|
||||
@@ -97,5 +98,16 @@ int main()
|
||||
static_assert(boost::is_readable_iterator<noncopyable_iterator>::value,
|
||||
"boost::is_readable_iterator<noncopyable_iterator>::value is expected to be true.");
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
static_assert(boost::is_readable_iterator_v<v*>,
|
||||
"boost::is_readable_iterator_v<v*> is expected to be true.");
|
||||
static_assert(boost::is_readable_iterator_v<v const*>,
|
||||
"boost::is_readable_iterator_v<v const*> is expected to be true.");
|
||||
static_assert(boost::is_readable_iterator_v<proxy_iterator>,
|
||||
"boost::is_readable_iterator_v<proxy_iterator> is expected to be true.");
|
||||
static_assert(!boost::is_readable_iterator_v<proxy_iterator2>,
|
||||
"boost::is_readable_iterator_v<proxy_iterator2> is expected to be false.");
|
||||
#endif // !defined(BOOST_NO_CXX14_VARIABLE_TEMPLATES)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -189,6 +189,16 @@ main()
|
||||
boost::const_nonconst_iterator_test(i, ++j);
|
||||
}
|
||||
|
||||
// Test that operator_brackets_proxy forwards operator-> and operator*
|
||||
{
|
||||
dummyT* ptr_array[] = { array + 0, array + 1, array + 2,
|
||||
array + 3, array + 4, array + 5 };
|
||||
|
||||
ptr_iterator<dummyT*> i(ptr_array);
|
||||
BOOST_TEST_EQ(i[2]->foo(), 2);
|
||||
BOOST_TEST_EQ((*i[2]).foo(), 2);
|
||||
}
|
||||
|
||||
int test;
|
||||
// Test the iterator_traits
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user