Compare commits

..

116 Commits

Author SHA1 Message Date
0013c5c4f0 Skip zip_iterator_test_std_pair on g++ in C++03 mode 2017-12-24 04:56:47 +02:00
386dbf1054 Skip zip_iterator_test_std_pair on msvc-9.0 and below 2017-12-24 04:38:07 +02:00
486721bbfe Update .travis.yml, appveyor.yml 2017-12-24 01:47:23 +02:00
5ad48c4d14 Fix links to examples 2017-12-23 23:54:33 +02:00
adecfd94f3 Use lightweight_test in shared_iterator_test.cpp 2017-12-23 23:45:59 +02:00
affe7e6d84 Add shared_iterator_test to test/Jamfile 2017-12-23 23:45:33 +02:00
91b392a478 Move test files to test/ 2017-12-23 22:05:35 +02:00
84227ea6ba Move shared_iterator_example* to example/ 2017-12-23 22:04:25 +02:00
67ac957273 shared_container_iterator library: - updated Copyright and License notices - Added shared_iterator_test to the iterator test suite.
[SVN r22140]
2017-12-23 22:02:20 +02:00
f86cd29f52 Fix tabs in file.
[SVN r21399]
2017-12-23 22:02:20 +02:00
fff85e7db9 Updated shared_container_iterator to use the new iterator adaptors library. Updated the documentation and examples as well to reflect the changes.
[SVN r19535]
2017-12-23 22:02:20 +02:00
d6c6f0ce16 Added Shared Container Iterator adaptor to iterator adaptor library.
[SVN r15169]
2017-12-23 22:02:20 +02:00
81faa161cf Add #include <boost/next_prior.hpp>; no longer in utility.hpp 2017-12-02 04:04:32 +02:00
7e5a32b3ea Merge pull request #38 from pavelkryukov/patch-1
Remove std::unary_function from zip_iterator_eg.rst
2017-11-25 13:58:41 -05:00
1b388c2496 Remove std::unary_function from zip_iterator_eg.rst 2017-11-25 12:15:52 +03:00
30b93d7428 Removed the use of std::unary_function. 2017-11-20 16:28:28 +03:00
28b8cc8c9c Removed --depth 1 2017-10-29 21:43:30 -04:00
992a314211 Better appveyor file setup. 2017-10-09 12:07:41 -04:00
422ad12716 Merge branch 'develop' of https://github.com/boostorg/iterator into develop 2017-10-09 08:17:24 -04:00
b2585dda6a Added Appveyor file. 2017-10-09 08:16:23 -04:00
8b5e92a0c4 Converted asserts in tests to tests using lightweight_test.hpp. 2017-10-02 01:26:39 +03:00
a36ed0f35d Replaced type_traits.hpp with more fine-grained includes. Replaced assert with BOOST_ASSERT. 2017-10-02 01:18:17 +03:00
0a08203107 Replaced type_traits.hpp with more fine grained includes.
This should work around compilation failures on gcc 4.6, which apparently
cannot handle all headers in Boost.TypeTraits.
2017-09-30 15:56:53 +03:00
38ef552209 Add the new path to the header to the comment. 2017-09-18 01:50:55 +03:00
a85dfaa7f2 Added a forwarding header for function_output_iterator.hpp 2017-09-18 01:43:24 +03:00
2af60e066d Move function_output_iterator.hpp into the iterator directory. 2017-09-18 01:39:00 +03:00
7442334ce1 Merge pull request #35 from morinmorin/fix_result_of_in_transform_iterator
Fix usage of decltype-based result_of in transform_iterator.
2017-09-18 01:23:43 +03:00
8577675c85 Renamed scripts to have a meaningful extension. 2017-09-18 01:09:42 +03:00
685b3fe855 Re-added executable permissions for scripts.
The executable bit was removed previously because the files have no extension
and were not considered as scripts by the search command.
2017-09-18 00:30:45 +03:00
a653a39cf4 Removed executable tags. 2017-09-16 07:19:04 -04:00
c338572735 Fix usage of decltype-based result_of in transform_iterator.
Regardless of value categories of a transform_iterator object, its
dereference operator calls m_f as an lvalue. Thus, correct usage of
decltype-based result_of is result_of<const UnaryFunc&(...)>.
2017-09-16 18:01:03 +09:00
07afd26ca2 Merge pull request #34 from morinmorin/fix_result_of_usage
Fix result_of usage
2017-09-11 23:44:36 +03:00
d058933767 Correct the result_of usage. 2017-09-12 02:54:50 +09:00
e2f81e9b48 Silenced signed/unsigned mismatch warning. 2017-09-08 18:12:58 +03:00
379200dfd1 Force result_of use decltype whenever possible to maximize testing of function input iterator with lambdas. 2017-09-08 18:12:02 +03:00
a26314dfb9 Added a check for BOOST_RESULT_OF_USE_DECLTYPE in case if tests are run with forced use of decltype in result_of. 2017-09-07 18:51:36 +03:00
e61592c553 Merge pull request #32 from morinmorin/clean_up_function_input_iterator
Clean up function_input_iterator
2017-09-07 18:46:07 +03:00
a3751006db Merge pull request #33 from morinmorin/fix_lambda_test
Fix lambda test
2017-09-07 18:36:10 +03:00
40da532a4d Suppress signed-unsigned comparison warning. 2017-09-07 20:17:35 +09:00
7ce9f87954 Add more feature checks; lambda test needs decltype-based result_of. 2017-09-07 20:14:39 +09:00
553b9713ac Remove dead class template (i.e. function_reference_input_iterator).
Both make_function_input_iterator(function) and make...(&function)
do not depend on function_reference_input_iterator. Actually, passing a
function reference as a template argument to function_input_iterator is
not supported. Doing so results in compiler errors.
2017-09-06 23:12:18 +09:00
ba32745e80 Replace ugly BOOST_DEDUCED_TYPENAME with typename. 2017-09-06 19:50:15 +09:00
282b28e51f Use boost::addressof instead of &. 2017-09-06 19:47:55 +09:00
479898d9d5 Remove unnecessary headers in test. 2017-09-06 19:41:24 +09:00
c1a375284d Merge pull request #31 from morinmorin/clean_up_test
Clean up function_input_iterator_test.cpp
2017-09-04 12:02:15 -04:00
24d2f58f98 Use lightweight_test.hpp instead of <cassert> 2017-09-05 00:32:15 +09:00
25a91d5981 Silenced gcc warnings about unused parameters. 2017-09-01 20:51:07 +03:00
9b78dc1006 Replaced vector::data() with &v[0] for compatibility with older compilers that don't provide this function. 2017-08-30 17:09:19 +03:00
89ca2fd1ae Shortened internal ids of qbk sections regarding iterator concepts. 2017-08-28 21:48:24 +03:00
79277b78d2 Added references to generator_iterator docs to rst and qbk docs. 2017-08-28 21:45:03 +03:00
eb90ad7a99 Merge pull request #30 from morinmorin/port_rst_to_quickbook
Port rst docs changeset to quickbook
2017-08-28 15:56:05 +03:00
de07014e9a Port rst docs changeset to quickbook (230d47e).
Move difference_type from the Forward Traversal Iterator concept to
the Single Pass Traversal concept.
2017-08-28 20:47:09 +09:00
25dc5c6c9c Port rst docs changeset to quickbook (6368d38).
Fix base class for const_node_iterator.
2017-08-28 20:42:43 +09:00
048c3dfa72 Port rst docs changeset to quickbook (daac0f2).
The argument order is flipped in the documentation.
2017-08-28 20:40:47 +09:00
f7dfc36a9c Port rst docs changeset to quickbook (ad90dac).
UnaryFunction is treated as a const object, but the documentation was missing
the const qualification.
2017-08-28 20:39:10 +09:00
c529399fb1 Reworked the test to avoid bogus warnings from gcc. 2017-08-27 17:48:47 +03:00
6faa3a942b Merge branch 'develop' of github.com:boostorg/iterator into develop 2017-08-27 17:31:54 +03:00
0c6b09ef6a Workaround MSVC 14.1 problem with template specialization partial ordering that caused compilation failure when next/prior is used with pointers. Added a test. 2017-08-27 17:31:34 +03:00
83220e7aea Merge branch 'develop' 2017-08-27 14:02:11 +03:00
991ea534ee Silenced warnings about signed/unsigned mismatch in comparisons. 2017-08-27 13:59:52 +03:00
210633c08c Silenced warnings about signed/unsigned mismatch in comparisons. 2017-08-27 13:59:09 +03:00
3275ee3c82 Updated examples to use unique_ptr when available rather than auto_ptr, which is being deprecated. 2017-08-26 15:04:47 -04:00
a72deda3ac Merge branch 'develop' 2017-08-26 20:39:41 +03:00
2b6b6bf8ad Silence warnings in tests about unused variables and local typedefs. 2017-08-26 20:39:26 +03:00
0107df44ab Remove unused deprecated includes
A comment in boost/iterator.hpp and boost/detail/iterator.hpp mentions that
the files are obsolete and will be deprecated. All they do is pull some types
from namespace std into namespace boost.
2017-08-26 20:23:14 +03:00
011288c2c8 Merge branch 'develop' 2017-08-26 20:07:54 +03:00
eaf1a48583 Added documentation for advance and distance. Various cleanup and fixes.
- Fixed multiple broken links to the documentation. Converted some of the
  links to internal references to the QuickBook documentation. Not all
  links converted because some of the QuickBook pages are not completely
  converted.
- Renamed utilities.qbk to type_traits.qbk and removed the part duplicated
  by concept_checking.qbk.
- Renamed traits.qbk to iterator_traits.qbk to better disambiguate with
  other type traits documented in type_traits.qbk.
- Converted some of the headings in iterator concepts to sections to be
  able to give those sections ids. This allows to reference those sections
  from other places in the documentation.
- In order to preserve the more compact pagination of the new sections
  (i.e. to have multiple sections on one page, like it was with headings)
  set chunk.section.depth=2 in the docs Jamfile.
2017-08-26 19:56:23 +03:00
52fbe950ec Minor next/prior docs corrections to better fit the rest of the docs. 2017-08-26 17:48:38 +03:00
6a672cecbd Replaced non-functional list syntax with direct wording. 2017-08-26 17:36:28 +03:00
577203bee8 Merge branch 'develop' 2017-08-26 17:25:35 +03:00
5f6ac9c020 Added next/prior documentation. 2017-08-26 16:27:55 +03:00
a48de6a8b8 Added tests for next/prior to the Jamfile. Ported tests to lightweight_test.hpp. 2017-08-26 15:31:38 +03:00
5f6fd2dec6 Use std::iterator_traits to detect iterators, when possible.
This allows next/prior to detect user's iterators that do not
define iterator_category nested type but specialize
std::iterator_traits instead.
2017-08-26 15:23:36 +03:00
e3577e7687 Use Boost.Iterator to advance iterators.
By using Boost.Iterator we rely on the separate traversal category instead of
the standard iterator category to advance iterators efficiently. For instance,
this allows to advance transform iterators over a random access sequence
in constant time, despite that they are formally input iterators.

Also, std::reverse_iterator formally requires at least bidirectional iterator
as the underlying iterator type. Transform iterators from the example above
don't qualify, so potentially std::reverse_iterator could fail to compile.
2017-08-26 15:23:36 +03:00
5ba36b063e Changed iterator_category nested type detection to work with MSVC and different versions of gcc. 2017-08-26 15:23:36 +03:00
bab02bb82e Add test cases for std::reverse_iterator 2017-08-26 15:23:36 +03:00
d251a6f515 Reworked iterator handling in next/prior helpers.
The new implementation tries to detect if the incremented/decremented type
is an iterator first and if not falls back to operator probing. This way
iterators that are not SFINAE-friendly (i.e. unconditionally define
arithmetic operators regardless of the iterator category) are still treated
as iterators through std::advance and do not fail the compilation.

The iterator detection is based on probing for the nested iterator_category
type that is expected to be present in class-type iterators. This heuristic
is not flawless since iterators are not required to defined this type.
User-defined iterators may not have it and instead specialize
std::iterator_traits. This use case is not covered by the current implementation
and will likely fail to compile. With C++17 SFINAE-friendly std::iterator_traits
this can be fixed, but currently Boost.Config lacks the macro to detect
availability of this feature. Support for it can be added by a later commit.

Also simplified boost::prior for iterators, removing the possibility of
integer overflow caused by negation of the distance value.
2017-08-26 15:23:36 +03:00
9d054b25ce Reworked next() and prior() taking the distance arguments.
The new version should provide the expected behavior in the case (prior(v.end(), v.size()) == v.begin()). It should also work with integers now, as was originally intended by David Abrahams. Added tests to verify these new use cases.
2017-08-26 15:23:36 +03:00
d1b22ac8e8 Remove executable bit from the file. 2017-08-26 15:23:36 +03:00
abe77db3e0 Added Daryle Walker's copyrights as requested.
[SVN r24481]
2017-08-26 15:23:36 +03:00
398819237e Removed Boost.org copyrights and replaced with originating authors copyright instead.
[SVN r24372]
2017-08-26 15:23:36 +03:00
a4bacb5077 Extended next/prior using patch from Daniel Walker (Daniel.Walker-at-bowneglobal.com)
[SVN r21382]
2017-08-26 15:23:36 +03:00
5ba5f2c2d4 split utility.hpp header
[SVN r17472]
2017-08-26 15:23:36 +03:00
6c1b356be1 Merge pull request #29 from morinmorin/add_doc_for_advance_and_distance
Add doc for advance and distance
2017-07-23 12:38:00 -04:00
bfcf52ace6 Add links to advance and distance 2017-07-23 23:49:30 +09:00
e2c927628c Add documentation for advance and distance 2017-07-23 23:46:26 +09:00
ed027c2cce Merge branch 'develop'
# Conflicts:
#	include/boost/iterator/reverse_iterator.hpp
2017-07-17 12:03:38 -04:00
4791425000 Merge pull request #27 from Lastique/advance_generic_distance
Use a separate template parameter for distance in advance().
2017-07-12 12:20:34 -04:00
b7e7e83a11 Merge pull request #28 from Lastique/patch-2
Avoid integer overflow on negating distance in reverse_iterator
2017-07-12 12:17:22 -04:00
c148962bd9 Avoid integer overflow on negating distance 2017-07-10 14:57:40 +03:00
5bfbfb7716 Use a separate template parameter for distance in advance().
This follows std::advance interface and also allows to use distance types
other than iterator's difference_type (if the iterator supports that).
2017-07-10 14:51:07 +03:00
af5f6e49e0 Merge pull request #26 from Lastique/patch-2
Remove dependency on boost::prior.
2017-07-09 11:59:18 -04:00
26ee5ba754 Remove dependency on boost::prior. 2017-07-09 18:31:06 +03:00
67a2336cf4 Merge pull request #25 from morinmorin/add_readable_iterator_tests
Add more ReabableIterator tests for advance/distance
2017-07-09 11:14:04 -04:00
029277f3ed Add more tests for ReabableIterator 2017-07-08 13:30:28 +09:00
847b2a1be3 Added Travis testing 2017-06-30 20:29:49 -04:00
18268069d9 Merge pull request #24 from morinmorin/add_advance_and_distance
Add boost::advance and boost::distance
2017-06-29 15:02:38 -04:00
bb54ee7900 Update Jamfile.v2 for new tests 2017-06-29 22:49:05 +09:00
d5b67c7fab Add tests for boost::advance/distance 2017-06-29 22:09:26 +09:00
663a30f659 Implement BoostIteratorTraversalConcepts-aware boost::advance/distance 2017-06-29 22:06:12 +09:00
177f719d15 Merge branch 'develop' 2017-04-24 12:24:21 -04:00
cccbd8c6aa Test needs both std::typle support and variadic template support. 2017-04-08 16:53:02 -04:00
d6cfed4b20 Merge pull request #23 from morinmorin/testcase_for_trac_12895
Testcase for PR #22 (trac ticket 12895)
2017-03-15 12:19:13 -04:00
514ac53326 Merge pull request #22 from Dani-Hub/develop
Bug fix for ticket #12895: Apply remove_reference before remove_cv
2017-03-15 12:12:12 -04:00
ca3b7505ce Add a testcase for trac ticket 12895 2017-03-15 20:41:24 +09:00
d7c8cccd64 Bug fix for ticket #12895: Apply remove_reference before remove_cv 2017-03-14 20:45:48 +01:00
7b627fa679 Merge branch 'develop' 2017-01-04 10:58:14 -05:00
760da84f9c Merge branch 'develop' of https://github.com/eldiener/iterator into nekko1119-support-lambda-expression 2016-12-17 19:34:48 -05:00
89d3ec7662 Add inclusion of config.hpp 2016-12-17 19:32:52 -05:00
c86db2ec8a Merge branch 'support-lambda-expression' of https://github.com/nekko1119/iterator into nekko1119-support-lambda-expression 2016-12-16 04:22:44 -05:00
0a18cfb255 Merge pull request #21 from Wilson-N/feature-bug-fix-8010
Remove incorrect documentation stating iterator_facade and iterator_a…
2016-12-01 08:53:05 -05:00
11e3715f37 Updated to use unique_ptr instead of auto_ptr when appropriate. Removed unnecessary structs. 2016-11-07 14:01:19 -05:00
f2d07f76b5 Add, and update, documentation build targets. 2016-10-10 11:39:50 -05:00
53e8ac401f Add, and update, documentation build targets. 2016-10-07 23:07:34 -05:00
434818cce7 Remove incorrect documentation stating iterator_facade and iterator_adapter had
been accepted into the TR1.

Fixes #8010
2016-01-27 22:22:55 -06:00
c09c8ca2b2 Support lambda expressions in function_input_iterator 2015-12-28 02:45:49 +09:00
67 changed files with 1805 additions and 486 deletions

87
.travis.yml Normal file
View File

@ -0,0 +1,87 @@
# 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:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/build
- git submodule update --init libs/config
- git submodule update --init tools/boostdep
- cp -r $TRAVIS_BUILD_DIR/* libs/iterator
- python tools/boostdep/depinst/depinst.py iterator
- ./bootstrap.sh
- ./b2 headers
script:
- ./b2 -j3 libs/iterator/test toolset=$TOOLSET cxxstd=$CXXSTD
notifications:
email:
on_success: always

43
appveyor.yml Normal file
View File

@ -0,0 +1,43 @@
# Copyright 2017 Edward Diener
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- master
- develop
- /feature\/.*/
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 14,17
install:
- set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- cd ..
- git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/build
- git submodule update --init libs/config
- git submodule update --init tools/boostdep
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\iterator
- python tools/boostdep/depinst/depinst.py iterator
- cmd /c bootstrap
- b2 -d0 headers
build: off
test_script:
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- b2 -j3 libs/iterator/test toolset=%TOOLSET% %CXXSTD%

View File

@ -16,8 +16,12 @@ boostbook standalone
<xsl:param>boost.root=../../../..
<xsl:param>toc.max.depth=3
<xsl:param>toc.section.depth=3
<xsl:param>chunk.section.depth=4
<xsl:param>chunk.section.depth=2
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/iterator/doc
;
###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : standalone ;
explicit boostrelease ;

75
doc/advance.rst Normal file
View File

@ -0,0 +1,75 @@
.. Copyright (C) 2017 Michel Morin.
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)
=======
advance
=======
``boost::iterators::advance`` is an adapted version of ``std::advance`` for
the Boost iterator traversal concepts.
Header
------
``<boost/iterator/advance.hpp>``
Synopsis
--------
::
template <typename Iterator, typename Distance>
constexpr void advance(Iterator& it, Distance n);
Description
-----------
Moves ``it`` forward by ``n`` increments
(or backward by ``|n|`` decrements if ``n`` is negative).
Requirements
------------
``Iterator`` should model Incrementable Iterator.
Preconditions
-------------
Let ``it``\ :sub:`i` be the iterator obtained by incrementing
(or decrementing if ``n`` is negative) ``it`` by *i*. All the iterators
``it``\ :sub:`i` for *i* = 0, 1, 2, ..., ``|n|`` should be valid.
If ``Iterator`` does not model Bidirectional Traversal Iterator,
``n`` should be non-negative.
Complexity
----------
If ``Iterator`` models Random Access Traversal Iterator, it takes constant time;
otherwise it takes linear time.
Notes
-----
- This function is not a customization point and is protected against
being found by argument-dependent lookup (ADL).
- This function is ``constexpr`` only in C++14 or later.
--------------------------------------------------------------------------------
| Author: Michel Morin
| Copyright |C| 2017 Michel Morin
| Distributed under the `Boost Software License, Version 1.0
<http://www.boost.org/LICENSE_1_0.txt>`_.
.. |C| unicode:: U+00A9 .. COPYRIGHT SIGN

72
doc/distance.rst Normal file
View File

@ -0,0 +1,72 @@
.. Copyright (C) 2017 Michel Morin.
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)
========
distance
========
``boost::iterators::distance`` is an adapted version of ``std::distance`` for
the Boost iterator traversal concepts.
Header
------
``<boost/iterator/distance.hpp>``
Synopsis
--------
::
template <typename Iterator>
constexpr typename iterator_difference<Iterator>::type
distance(Iterator first, Iterator last);
Description
-----------
Computes the (signed) distance from ``first`` to ``last``.
Requirements
------------
``Iterator`` should model Single Pass Iterator.
Preconditions
-------------
If ``Iterator`` models Random Access Traversal Iterator,
``[first, last)`` or ``[last, first)`` should be valid;
otherwise ``[first, last)`` should be valid.
Complexity
----------
If ``Iterator`` models Random Access Traversal Iterator, it takes constant time;
otherwise it takes linear time.
Notes
-----
- This function is not a customization point and is protected against
being found by argument-dependent lookup (ADL).
- This function is ``constexpr`` only in C++14 or later.
--------------------------------------------------------------------------------
| Author: Michel Morin
| Copyright |C| 2017 Michel Morin
| Distributed under the `Boost Software License, Version 1.0
<http://www.boost.org/LICENSE_1_0.txt>`_.
.. |C| unicode:: U+00A9 .. COPYRIGHT SIGN

View File

@ -131,6 +131,9 @@ is called to get the value to return.</li>
<li><a class="reference external" href="function_output_iterator.html"><tt class="docutils literal"><span class="pre">function_output_iterator</span></tt></a> (<a class="reference external" href="function_output_iterator.pdf">PDF</a>): an output iterator wrapping a unary function
object; each time an element is written into the dereferenced
iterator, it is passed as a parameter to the function object.</li>
<li><a class="reference external" href="generator_iterator.htm"><tt class="docutils literal"><span class="pre">generator_iterator</span></tt></a>: an input iterator wrapping a reference to a generator (nullary function object);
each time the iterator is dereferenced, the function object
is called to get the value to return. This is a more outdated analogue of <tt class="docutils literal"><span class="pre">function_input_iterator</span></tt>.</li>
<li><a class="reference external" href="indirect_iterator.html"><tt class="docutils literal"><span class="pre">indirect_iterator</span></tt></a> (<a class="reference external" href="indirect_iterator.pdf">PDF</a>): an iterator over the objects <em>pointed-to</em> by the
elements of some sequence.</li>
<li><a class="reference external" href="permutation_iterator.html"><tt class="docutils literal"><span class="pre">permutation_iterator</span></tt></a> (<a class="reference external" href="permutation_iterator.pdf">PDF</a>): an iterator over the elements of some random-access

View File

@ -115,8 +115,8 @@ __ iterator_facade.pdf
__ iterator_adaptor.pdf
Both |facade| and |adaptor| as well as many of the `specialized
adaptors`_ mentioned below have been proposed for standardization,
and accepted into the first C++ technical report; see our
adaptors`_ mentioned below have been proposed for standardization;
see our
`Standard Proposal For Iterator Facade and Adaptor`__ (PDF__)
@ -146,6 +146,10 @@ iterator templates based on the Boost `iterator facade and adaptor`_.
object; each time an element is written into the dereferenced
iterator, it is passed as a parameter to the function object.
* |generator|_: an input iterator wrapping a generator (nullary
function object); each time the iterator is dereferenced, the function object
is called to get the value to return. This is an outdated analogue of |function_input|_.
* |indirect|_ (PDF__): an iterator over the objects *pointed-to* by the
elements of some sequence.
@ -183,6 +187,9 @@ __ function_input_iterator.pdf
.. _function_output: function_output_iterator.html
__ function_output_iterator.pdf
.. |generator| replace:: ``generator_iterator``
.. _generator: generator_iterator.htm
.. |indirect| replace:: ``indirect_iterator``
.. _indirect: indirect_iterator.html
__ indirect_iterator.pdf
@ -213,6 +220,23 @@ __ zip_iterator.pdf
Iterator Utilities
====================
Operations
----------
The standard library does not handle new-style iterators properly,
because it knows nothing about the iterator traversal concepts.
The Boost.Iterator library provides implementations that fully understand
the new concepts for the two basic operations:
- |advance|_
- |distance|_
.. |advance| replace:: ``advance``
.. _advance: advance.html
.. |distance| replace:: ``distance``
.. _distance: distance.html
Traits
------

View File

@ -0,0 +1,149 @@
[section:algorithms Algorithms]
[section:advance Function template `advance()`]
The `boost::iterators::advance` function template is an adapted version of `std::advance` for the Boost iterator [link iterator.concepts.traversal traversal concepts].
[heading Header]
<boost/iterator/advance.hpp>
[heading Synopsis]
template <typename Iterator, typename Distance>
constexpr void advance(Iterator& it, Distance n);
[heading Description]
Moves `it` forward by `n` increments (or backward by `|n|` decrements if `n` is negative).
[heading Requirements]
`Iterator` should model Incrementable Iterator.
[heading Preconditions]
Let `it`[sub `i`] be the iterator obtained by incrementing (or decrementing if `n` is negative) `it` by `i`. All the iterators `it`[sub `i`] for `i` = 0, 1, 2, ..., `|n|` should be valid.
If `Iterator` does not model [link iterator.concepts.traversal.bidirectional Bidirectional Traversal Iterator], `n` should be non-negative.
[heading Complexity]
If `Iterator` models [link iterator.concepts.traversal.random_access Random Access Traversal Iterator], it takes constant time; otherwise it takes linear time.
[heading Notes]
* This function is not a customization point and is protected against being found by argument-dependent lookup (ADL).
* This function is `constexpr` only in C++14 or later.
[heading Acknowledgements]
Contributed by Michel Morin.
[endsect]
[section:distance Function template `distance()`]
The `boost::iterators::distance` function template is an adapted version of `std::distance` for the Boost iterator [link iterator.concepts.traversal traversal concepts].
[heading Header]
<boost/iterator/distance.hpp>
[heading Synopsis]
template <typename Iterator>
constexpr typename iterator_difference<Iterator>::type
distance(Iterator first, Iterator last);
[heading Description]
Computes the (signed) distance from `first` to `last`.
[heading Requirements]
`Iterator` should model [link iterator.concepts.traversal.single_pass Single Pass Iterator].
[heading Preconditions]
If `Iterator` models [link iterator.concepts.traversal.random_access Random Access Traversal Iterator], `[first, last)` or `[last, first)` should be valid; otherwise `[first, last)` should be valid.
[heading Complexity]
If `Iterator` models [link iterator.concepts.traversal.random_access Random Access Traversal Iterator], it takes constant time; otherwise it takes linear time.
[heading Notes]
* This function is not a customization point and is protected against being found by argument-dependent lookup (ADL).
* This function is `constexpr` only in C++14 or later.
[heading Acknowledgements]
Contributed by Michel Morin.
[endsect]
[section:next_prior Function templates `next()` and `prior()`]
Certain data types, such as the C++ Standard Library's forward and bidirectional iterators, do not provide addition and subtraction via `operator+()` or `operator-()`. This means that non-modifying computation of the next or prior value requires a temporary, even though `operator++()` or `operator--()` is provided. It also means that writing code like `itr+1` inside a template restricts the iterator category to random access iterators.
The `next()` and `prior()` functions defined in `boost/next_prior.hpp` provide a simple way around these problems.
[heading Synopsis]
template <class T>
T next(T x)
{
return ++x;
}
template <class T, class Distance>
T next(T x, Distance n)
{
std::advance(x, n);
return x;
}
template <class T>
T prior(T x)
{
return --x;
}
template <class T, class Distance>
T prior(T x, Distance n)
{
std::advance(x, -n);
return x;
}
[note Function implementations above are given for exposition only. The actual implementation has the same effect for iterators, but has different properties, as documented later.]
[heading Usage]
Usage is simple:
const std::list<T>::iterator p = get_some_iterator();
const std::list<T>::iterator prev = boost::prior(p);
const std::list<T>::iterator next = boost::next(prev, 2);
The distance from the given iterator should be supplied as an absolute value. For example, the iterator four iterators prior to the given iterator `p` may be obtained by `prior(p, 4)`.
With C++11, the Standard Library provides `std::next()` and `std::prev()` function templates, which serve the same purpose. However, there are advantages to `boost::next()` and `boost::prior()`.
First, `boost::next()` and `boost::prior()` are compatible not only with iterators but with any type that provides arithmetic operators `operator++()`, `operator--()`, `operator+()`, `operator-()`, `operator+=()` or `operator-=()`. For example, this is possible:
int x = 10;
int y = boost::next(x, 5);
assert(y == 15);
Second, `boost::next()` and `boost::prior()` use [link iterator.concepts.traversal traversal categories] to select the most efficient implementation. For some kinds of iterators, such as [link iterator.specialized.transform transform iterators], the standard iterator category does not reflect the traversal category correctly and therefore `std::next()` and `std::prev()` will fall back to linear complexity.
[heading Acknowledgements]
Contributed by [@http://www.boost.org/people/dave_abrahams.htm Dave Abrahams]. Two-argument versions by Daniel Walker.
[endsect]
[endsect]

View File

@ -4,7 +4,7 @@ The iterator concept checking classes provide a mechanism for a
template to report better error messages when a user instantiates the
template with a type that does not meet the requirements of the
template. For an introduction to using concept checking classes, see
the documentation for the boost::concept_check library.
the documentation for the _concept_check_ library.
[h2 `iterator_concepts.hpp` Synopsis]
@ -51,4 +51,4 @@ the documentation for the boost::concept_check library.
}
[endsect]
[endsect]

View File

@ -1,9 +1,9 @@
[section:concepts Iterator Concepts]
[section:concepts_access Access]
[section:access Access]
[h2 Readable Iterator Concept]
[section:readable Readable Iterator Concept]
A class or built-in type `X` models the *Readable Iterator* concept
for value type `T` if, in addition to `X` being Assignable and
@ -32,17 +32,18 @@ type `T`.
[`U&`]
[pre: `(*a).m` is well-defined. Equivalent to `(*a).m`.]
]
]
[h2 Writable Iterator Concept ]
]
[endsect]
[section:writable Writable Iterator Concept]
A class or built-in type `X` models the *Writable Iterator* concept
if, in addition to `X` being Copy Constructible, the following
expressions are valid and respect the stated semantics. Writable
Iterators have an associated *set of value types*.
[table Writable Iterator Requirements (in addition to Copy Constructible)
[table Writable Iterator Requirements (in addition to Copy Constructible)
[
[Expression]
[Return Type]
@ -55,13 +56,15 @@ Iterators have an associated *set of value types*.
]
]
[h2 Swappable Iterator Concept]
[endsect]
[section:swappable Swappable Iterator Concept]
A class or built-in type `X` models the *Swappable Iterator* concept
if, in addition to `X` being Copy Constructible, the following
expressions are valid and respect the stated semantics.
[table Swappable Iterator Requirements (in addition to Copy Constructible)
[table Swappable Iterator Requirements (in addition to Copy Constructible)
[
[Expression]
[Return Type]
@ -77,7 +80,9 @@ expressions are valid and respect the stated semantics.
[blurb *Note:* An iterator that is a model of the *Readable* and *Writable Iterator* concepts
is also a model of *Swappable Iterator*. *--end note*]
[h2 Lvalue Iterator Concept]
[endsect]
[section:lvalue Lvalue Iterator Concept]
The *Lvalue Iterator* concept adds the requirement that the return
type of `operator*` type be a reference to the value type of the
@ -101,17 +106,17 @@ iterator.
[endsect]
[section:concepts_traversal Traversal]
[endsect]
[h2 Incrementable Iterator Concept]
[section:traversal Traversal]
[section:incrementable Incrementable Iterator Concept]
A class or built-in type `X` models the *Incrementable Iterator*
concept if, in addition to `X` being Assignable and Copy
Constructible, the following expressions are valid and respect the
stated semantics.
[table Incrementable Iterator Requirements (in addition to Assignable, Copy Constructible)
[
[Expression ]
@ -129,7 +134,7 @@ stated semantics.
[``
{
X tmp = r;
++r;
++r;
return tmp;
}
``]
@ -141,7 +146,9 @@ stated semantics.
]
]
[h2 Single Pass Iterator Concept]
[endsect]
[section:single_pass Single Pass Iterator Concept]
A class or built-in type `X` models the *Single Pass Iterator*
concept if the following expressions are valid and respect the stated
@ -168,6 +175,11 @@ semantics.
[convertible to `bool`]
[`!(a == b)`]
]
[
[`iterator_traits<X>::difference_type`]
[A signed integral type representing the distance between iterators]
[]
]
[
[`iterator_traversal<X>::type`]
[Convertible to`single_pass_traversal_tag`]
@ -175,8 +187,9 @@ semantics.
]
]
[endsect]
[h2 Forward Traversal Concept]
[section:forward Forward Traversal Concept]
A class or built-in type `X` models the *Forward Traversal*
concept if, in addition to `X` meeting the requirements of Default
@ -199,11 +212,6 @@ valid and respect the stated semantics.
[`X&`]
[`r == s` and `r` is dereferenceable implies `++r == ++s.`]
]
[
[`iterator_traits<X>::difference_type`]
[A signed integral type representing the distance between iterators]
[]
]
[
[`iterator_traversal<X>::type`]
[Convertible to `forward_traversal_tag`]
@ -211,7 +219,9 @@ valid and respect the stated semantics.
]
]
[h2 Bidirectional Traversal Concept]
[endsect]
[section:bidirectional Bidirectional Traversal Concept]
A class or built-in type `X` models the *Bidirectional Traversal*
concept if, in addition to `X` meeting the requirements of Forward
@ -223,7 +233,7 @@ the stated semantics.
[Expression]
[Return Type]
[Assertion/Semantics/Pre-/Post-condition]
]
]
[
[`--r`]
[`X&`]
@ -247,7 +257,9 @@ the stated semantics.
]
]
[h2 Random Access Traversal Concept]
[endsect]
[section:random_access Random Access Traversal Concept]
A class or built-in type `X` models the *Random Access Traversal*
concept if the following expressions are valid and respect the stated
@ -255,8 +267,8 @@ semantics. In the table below, `Distance` is
`iterator_traits<X>::difference_type` and `n` represents a
constant object of type `Distance`.
[table Random Access Traversal Iterator Requirements (in addition to Bidirectional Traversal)
[
[table Random Access Traversal Iterator Requirements (in addition to Bidirectional Traversal)
[
[Expression]
[Return Type]
[Operational Semantics]
@ -266,10 +278,10 @@ constant object of type `Distance`.
[`r += n`]
[ `X&`]
[``
{
{
Distance m = n;
if (m >= 0)
while (m--)
while (m--)
++r;
else
while (m++)
@ -279,18 +291,18 @@ constant object of type `Distance`.
``]
[ ]
]
[
[
[`a + n`, `n + a`]
[`X`]
[``
{
{
X tmp = a;
return tmp+= n;
}
``]
[]
]
[
[
[`r -= n`]
[`X&`]
[`return r += -n`]
@ -300,9 +312,9 @@ constant object of type `Distance`.
[`a - n`]
[`X`]
[``
{
{
X tmp = a;
return tmp-= n;
return tmp-= n;
}
``]
[]
@ -320,7 +332,7 @@ constant object of type `Distance`.
[pre: a is a *Readable Iterator*]
]
[
[`a\[n\] = v`]
[`a\[n\] = v`]
[convertible to T]
[`*(a + n) = v`]
[pre: a is a *Writable iterator*]
@ -359,4 +371,6 @@ constant object of type `Distance`.
[endsect]
[endsect]
[endsect]
[endsect]

View File

@ -141,7 +141,7 @@ standardize the gateway protocol. Note that even if
open a safety loophole, as every core member function preserves the
invariants of the iterator.
[h2 `operator\[\]`]
[h2 `operator[]`]
The indexing operator for a generalized iterator presents special
challenges. A random access iterator's `operator[]` is only
@ -289,7 +289,7 @@ The `iterator_category` member of `iterator_facade` is
.. parsed-literal::
*iterator-category*\ (CategoryOrTraversal, value_type, reference)
*iterator-category*\ (CategoryOrTraversal, reference, value_type)
where *iterator-category* is defined as follows:
@ -297,10 +297,10 @@ where *iterator-category* is defined as follows:
The `enable_if_interoperable` template used above is for exposition
purposes. The member operators should only be in an overload set
provided the derived types `Dr1` and `Dr2` are interoperable,
provided the derived types `Dr1` and `Dr2` are interoperable,
meaning that at least one of the types is convertible to the other. The
`enable_if_interoperable` approach uses SFINAE to take the operators
out of the overload set when the types are not interoperable.
out of the overload set when the types are not interoperable.
The operators should behave *as-if* `enable_if_interoperable`
were defined to be:
@ -400,7 +400,7 @@ through member functions of class `iterator_core_access`.
__ `operator arrow`_
[*Returns:] If `reference` is a reference type, an object of type `pointer` equal to: `&static_cast<Derived const*>(this)->dereference()`
Otherwise returns an object of unspecified type such that,
Otherwise returns an object of unspecified type such that,
`(*static_cast<Derived const*>(this))->m` is equivalent to `(w = **static_cast<Derived const*>(this),
w.m)` for some temporary object `w` of type `value_type`.
@ -417,7 +417,7 @@ w.m)` for some temporary object `w` of type `value_type`.
Derived& operator++();
[*Effects:]
[*Effects:]
static_cast<Derived*>(this)->increment();
return *static_cast<Derived*>(this);
@ -457,7 +457,7 @@ w.m)` for some temporary object `w` of type `value_type`.
Derived& operator-=(difference_type n);
[*Effects:]
static_cast<Derived*>(this)->advance(-n);
return *static_cast<Derived*>(this);
@ -493,10 +493,10 @@ w.m)` for some temporary object `w` of type `value_type`.
[pre
if `is_convertible<Dr2,Dr1>::value`
then
then
`((Dr1 const&)lhs).equal((Dr2 const&)rhs)`.
Otherwise,
Otherwise,
`((Dr2 const&)rhs).equal((Dr1 const&)lhs)`.
]
@ -508,14 +508,14 @@ w.m)` for some temporary object `w` of type `value_type`.
iterator_facade<Dr2,V2,TC2,R2,D2> const& rhs);
[*Returns:]
[pre
if `is_convertible<Dr2,Dr1>::value`
then
then
`!((Dr1 const&)lhs).equal((Dr2 const&)rhs)`.
Otherwise,
Otherwise,
`!((Dr2 const&)rhs).equal((Dr1 const&)lhs)`.
]
@ -527,14 +527,14 @@ w.m)` for some temporary object `w` of type `value_type`.
iterator_facade<Dr2,V2,TC2,R2,D2> const& rhs);
[*Returns:]
[pre
if `is_convertible<Dr2,Dr1>::value`
then
then
`((Dr1 const&)lhs).distance_to((Dr2 const&)rhs) < 0`.
Otherwise,
Otherwise,
`((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) > 0`.
]
@ -546,14 +546,14 @@ w.m)` for some temporary object `w` of type `value_type`.
iterator_facade<Dr2,V2,TC2,R2,D2> const& rhs);
[*Returns:]
[pre
if `is_convertible<Dr2,Dr1>::value`
then
then
`((Dr1 const&)lhs).distance_to((Dr2 const&)rhs) <= 0`.
Otherwise,
Otherwise,
`((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) >= 0`.
]
@ -565,14 +565,14 @@ w.m)` for some temporary object `w` of type `value_type`.
iterator_facade<Dr2,V2,TC2,R2,D2> const& rhs);
[*Returns:]
[pre
if `is_convertible<Dr2,Dr1>::value`
then
then
`((Dr1 const&)lhs).distance_to((Dr2 const&)rhs) > 0`.
Otherwise,
Otherwise,
`((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) < 0`.
]
@ -584,14 +584,14 @@ w.m)` for some temporary object `w` of type `value_type`.
iterator_facade<Dr2,V2,TC2,R2,D2> const& rhs);
[*Returns:]
[pre
if `is_convertible<Dr2,Dr1>::value`
then
then
`((Dr1 const&)lhs).distance_to((Dr2 const&)rhs) >= 0`.
Otherwise,
Otherwise,
`((Dr2 const&)rhs).distance_to((Dr1 const&)lhs) <= 0`.
]
@ -605,27 +605,27 @@ w.m)` for some temporary object `w` of type `value_type`.
iterator_facade<Dr2,V2,TC2,R2,D2> const& rhs);
[*Return Type:]
[pre
if `is_convertible<Dr2,Dr1>::value`
then
then
`difference` shall be
`iterator_traits<Dr1>::difference_type`.
Otherwise
Otherwise
`difference` shall be `iterator_traits<Dr2>::difference_type`
]
[*Returns:]
[pre
if `is_convertible<Dr2,Dr1>::value`
then
then
`-((Dr1 const&)lhs).distance_to((Dr2 const&)rhs)`.
Otherwise,
Otherwise,
`((Dr2 const&)rhs).distance_to((Dr1 const&)lhs)`.
]
@ -634,4 +634,4 @@ w.m)` for some temporary object `w` of type `value_type`.
[include facade_tutorial.qbk]
[endsect]
[endsect]

View File

@ -285,7 +285,7 @@ changes:
class const_node_iterator
: public boost::iterator_facade<
node_iterator
const_node_iterator
, node_base **const**
, boost::forward_traversal_tag
>

View File

@ -35,7 +35,7 @@ proxy object.
std::string s = "";
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;
@ -97,4 +97,4 @@ Incrementable Iterator concepts.
[*Returns: ] `*this`.
[endsect]
[endsect]

View File

@ -29,7 +29,10 @@
[/ Links ]
[def _iterator_ [@../../libs/iterator/doc/index.html Boost.Iterator]]
[def _iterator_ [@../../../iterator/doc/index.html Boost.Iterator]]
[def _concept_check_ [@../../../concept_check/index.html Boost.ConceptCheck]]
[template sub[x]'''<subscript>'''[x]'''</subscript>''']
[section:intro Introduction]
@ -71,19 +74,23 @@ and a _GOTW_50_. New-style iterators go well beyond
patching up `vector<bool>`, though: there are lots of other
iterators already in use which can't be adequately represented by
the existing concepts. For details about the new iterator
concepts, see our [@./new-iter-concepts.html Standard Proposal for New-Style Iterators].
concepts, see our [@../new-iter-concepts.html Standard Proposal for New-Style Iterators].
[h2 Iterator Facade and Adaptor]
[def _facade_ [@./iterator_facade.html facade]]
[def _adaptor_ [@./iterator_adaptor.html adaptor]]
[/
[def _facade_ [link iterator.generic.facade facade]]
[def _adaptor_ [link iterator.generic.adaptor adaptor]]
]
[def _facade_ [@../iterator_facade.html facade]]
[def _adaptor_ [@../iterator_adaptor.html adaptor]]
Writing standard-conforming iterators is tricky, but the need comes
up often. In order to ease the implementation of new iterators,
the Boost.Iterator library provides the _facade_ class template,
which implements many useful defaults and compile-time checks
designed to help the iterator author ensure that his iterator is
correct.
correct.
It is also common to define a new iterator that is similar to some
underlying iterator or iterator-like type, but that modifies some
@ -92,9 +99,9 @@ library supplies the _adaptor_ class template, which is specially
designed to take advantage of as much of the underlying type's
behavior as possible.
Both _facade_ and _adaptor_ as well as many of the `specialized
adaptors`_ mentioned below have been proposed for standardization
([@./facade-and-adaptor.html Standard Proposal For Iterator Facade and Adaptor]).
Both _facade_ and _adaptor_ as well as many of the [link iterator.specialized specialized
adaptors] mentioned below have been proposed for standardization
([@../facade-and-adaptor.html Standard Proposal For Iterator Facade and Adaptor]).
[h2 Specialized Adaptors]
@ -103,15 +110,17 @@ iterator templates based on the Boost [link
iterator.intro.iterator_facade_and_adaptor iterator facade and adaptor]
templates.
[def _counting_ [@./counting_iterator.html `counting_iterator`]]
[def _filter_ [@./filter_iterator.html `filter_iterator`]]
[def _function_ [@./function_output_iterator.html `function_output_iterator`]]
[def _indirect_ [@./indirect_iterator.html `indirect_iterator`]]
[def _permutation_ [@./permutation_iterator.html `permutation_iterator`]]
[def _reverse_ [@./reverse_iterator.html `reverse_iterator`]]
[def _shared_ [@./shared_container_iterator.html `shared_container_iterator`]]
[def _transform_ [@./transform_iterator.html `transform_iterator`]]
[def _zip_ [@./zip_iterator.html `zip_iterator`]]
[def _counting_ [link iterator.specialized.counting `counting_iterator`]]
[def _filter_ [link iterator.specialized.filter `filter_iterator`]]
[def _function_input_ [@../function_input_iterator.html `function_input_iterator`]]
[def _function_output_ [link iterator.specialized.function_output `function_output_iterator`]]
[def _generator_ [@../generator_iterator.htm `generator_iterator`]]
[def _indirect_ [link iterator.specialized.indirect `indirect_iterator`]]
[def _permutation_ [link iterator.specialized.permutation `permutation_iterator`]]
[def _reverse_ [link iterator.specialized.reverse `reverse_iterator`]]
[def _shared_ [link iterator.specialized.shared_container `shared_container_iterator`]]
[def _transform_ [link iterator.specialized.transform `transform_iterator`]]
[def _zip_ [link iterator.specialized.zip `zip_iterator`]]
[def _shared_ptr_ [@../../smart_ptr/shared_ptr.htm `shared_ptr`]]
@ -121,10 +130,18 @@ templates.
* _filter_: an iterator over the subset of elements of some
sequence which satisfy a given predicate
* _function_: an output iterator wrapping a unary function
* _function_input_: an input iterator wrapping a generator (nullary
function object); each time the iterator is dereferenced, the function object
is called to get the value to return.
* _function_output_: an output iterator wrapping a unary function
object; each time an element is written into the dereferenced
iterator, it is passed as a parameter to the function object.
* _generator_: an input iterator wrapping a generator (nullary
function object); each time the iterator is dereferenced, the function object
is called to get the value to return. An outdated analogue of _function_input_.
* _indirect_: an iterator over the objects *pointed-to* by the
elements of some sequence.
@ -133,7 +150,7 @@ templates.
* _reverse_: an iterator which traverses the elements of some
bidirectional sequence in reverse. Corrects many of the
shortcomings of C++98's ``std::reverse_iterator``.
shortcomings of C++98's `std::reverse_iterator`.
* _shared_: an iterator over elements of a container whose
lifetime is maintained by a _shared_ptr_ stored in the iterator.
@ -141,7 +158,7 @@ templates.
* _transform_: an iterator over elements which are the result of
applying some functional transformation to the elements of an
underlying sequence. This component also replaces the old
``projection_iterator_adaptor``.
`projection_iterator_adaptor`.
* _zip_: an iterator over tuples of the elements at corresponding
positions of heterogeneous underlying iterators.
@ -150,9 +167,9 @@ templates.
[h3 Traits]
[def _pointee_ [@./pointee.html `pointee.hpp`]]
[def _iterator_traits_ [@./iterator_traits.html `iterator_traits.hpp`]]
[def _interoperable_ [@./interoperable.html `interoperable.hpp`]]
[def _pointee_ [link iterator.utilities.traits `pointee.hpp`]]
[def _iterator_traits_ [link iterator.utilities.iterator_traits `iterator_traits.hpp`]]
[def _interoperable_ [@../interoperable.html `interoperable.hpp`]]
[def _MPL_ [@../../mpl/doc/index.html [*MPL]]]
* _pointee_: Provides the capability to deduce the referent types
@ -163,19 +180,40 @@ templates.
retrieve an iterator's traits. Also corrects for the deficiencies
of broken implementations of `std::iterator_traits`.
[\ * |interoperable|_ (PDF__): Provides an _MPL_ compatible metafunction for
testing iterator interoperability
[/
* _interoperable_: Provides an _MPL_ compatible metafunction for
testing iterator interoperability
]
[h3 Testing and Concept Checking]
[def _iterator_concepts_ [@./iterator_concepts.html `iterator_concepts.hpp`]]
[def _iterator_archetypes_ [@./iterator_archetypes.html `iterator_archetypes.hpp`]]
[def _iterator_concepts_ [link iterator.concepts `iterator_concepts.hpp`]]
[def _iterator_archetypes_ [link iterator.utilities.archetypes `iterator_archetypes.hpp`]]
* _iterator_concepts_: Concept checking classes for the new iterator concepts.
* _iterator_archetypes_: Concept archetype classes for the new iterators concepts.
[h2 Iterator Algorithms]
The library provides a number of generic algorithms for use with iterators. These
algorithms take advantage of the new concepts defined by the library to provide
better performance and functionality.
[def _advance_ [link iterator.algorithms.advance `advance.hpp`]]
[def _distance_ [link iterator.algorithms.distance `distance.hpp`]]
[def _next_prior_ [link iterator.algorithms.next_prior `next_prior.hpp`]]
* _advance_: Provides `advance()` function for advancing an iterator a given number
of positions forward or backward.
* _distance_: Provides `distance()` function for computing distance between two
iterators.
* _next_prior_: Provides `next()` and `prior()` functions for obtaining
next and prior iterators to a given iterator. The functions are also compatible
with non-iterator types.
[endsect]
[include concepts.qbk]
@ -196,12 +234,14 @@ templates.
[include concept_checking.qbk]
[include traits.qbk]
[include iterator_traits.qbk]
[include utilities.qbk]
[include type_traits.qbk]
[endsect]
[include algorithms.qbk]
[section:upgrading Upgrading from the old Boost Iterator Adaptor Library]
[def _type_generator_ [@http://www.boost.org/more/generic_programming.html#type_generator type generator]]
@ -266,4 +306,3 @@ library you see today.
[endsect]

View File

@ -1,5 +1,5 @@
[section:traits Iterator Traits]
[section:iterator_traits Iterator Traits]
`std::iterator_traits` provides access to five associated types
of any iterator: its `value_type`, `reference`, `pointer`,
@ -15,15 +15,15 @@ Header `<boost/iterator/iterator_traits.hpp>`:
template <class Iterator>
struct iterator_value
{
typedef typename
std::iterator_traits<Iterator>::value_type
typedef typename
std::iterator_traits<Iterator>::value_type
type;
};
template <class Iterator>
struct iterator_reference
{
typedef typename
typedef typename
std::iterator_traits<Iterator>::reference
type;
};
@ -31,8 +31,8 @@ Header `<boost/iterator/iterator_traits.hpp>`:
template <class Iterator>
struct iterator_pointer
{
typedef typename
std::iterator_traits<Iterator>::pointer
typedef typename
std::iterator_traits<Iterator>::pointer
type;
};

View File

@ -56,7 +56,7 @@ original shared pointer `ints` ceases to exist after `set_range()`
returns, the `shared_counter_iterator` objects maintain references to
the underlying vector and thereby extend the container's lifetime.
[@../../../libs/utility/shared_iterator_example1.cpp `shared_iterator_example1.cpp`]:
[@../../example/shared_iterator_example1.cpp `shared_iterator_example1.cpp`]:
#include "shared_container_iterator.hpp"
#include "boost/shared_ptr.hpp"
@ -139,7 +139,7 @@ explicitly specifying its type.
This example, similar to the previous,
uses `make_shared_container_iterator()` to create the iterators.
[@../../../libs/utility/shared_iterator_example2.cpp `shared_iterator_example2.cpp`]:
[@../../example/shared_iterator_example2.cpp `shared_iterator_example2.cpp`]:
#include "shared_container_iterator.hpp"
#include "boost/shared_ptr.hpp"
@ -200,7 +200,7 @@ 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.
[@../../../libs/utility/shared_iterator_example3.cpp `shared_iterator_example3.cpp`]:
[@../../example/shared_iterator_example3.cpp `shared_iterator_example3.cpp`]:
#include "shared_container_iterator.hpp"
#include "boost/shared_ptr.hpp"

View File

@ -86,7 +86,7 @@ The source code for this example can be found
If `Reference` is `use_default` then the `reference` member of
`transform_iterator` is[br]
`result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type`.
`result_of<const UnaryFunction(iterator_traits<Iterator>::reference)>::type`.
Otherwise, `reference` is `Reference`.
@ -110,10 +110,10 @@ convertible to `input_iterator_tag`.
The type `UnaryFunction` must be Assignable, Copy Constructible, and
the expression `f(*i)` must be valid where `f` is an object of
the expression `f(*i)` must be valid where `f` is a const object of
type `UnaryFunction`, `i` is an object of type `Iterator`, and
where the type of `f(*i)` must be
`result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type`.
`result_of<const UnaryFunction(iterator_traits<Iterator>::reference)>::type`.
The argument `Iterator` shall model Readable Iterator.

View File

@ -1,7 +1,4 @@
[section:utilities Iterator Utilities]
[section:utilities_traits Traits]
[section:traits Type Traits]
[h2 Overview]
@ -212,113 +209,3 @@ Otherwise, `type` is defined to the closest iterator traversal tag matching `C`.
[*Requires:] `Iterator` shall be an iterator.
[endsect]
[section:utilities_testing Testing and Concept Checking]
The iterator concept checking classes provide a mechanism for a
template to report better error messages when a user instantiates
the template with a type that does not meet the requirements of the
template.
For an introduction to using concept checking classes, see
the documentation for the
[@../../concept_check/index.html `boost::concept_check`] library.
[h2 Reference]
[h3 Iterator Access Concepts]
* |Readable|_
* |Writable|_
* |Swappable|_
* |Lvalue|_
[/ .. |Readable| replace:: *Readable Iterator* ]
[/ .. _Readable: ReadableIterator.html ]
[/ ]
[/ .. |Writable| replace:: *Writable Iterator* ]
[/ .. _Writable: WritableIterator.html ]
[/ ]
[/ .. |Swappable| replace:: *Swappable Iterator* ]
[/ .. _Swappable: SwappableIterator.html ]
[/ ]
[/ .. |Lvalue| replace:: *Lvalue Iterator* ]
[/ .. _Lvalue: LvalueIterator.html ]
Iterator Traversal Concepts
...........................
* |Incrementable|_
* |SinglePass|_
* |Forward|_
* |Bidir|_
* |Random|_
[/ .. |Incrementable| replace:: *Incrementable Iterator* ]
[/ .. _Incrementable: IncrementableIterator.html ]
[/ ]
[/ .. |SinglePass| replace:: *Single Pass Iterator* ]
[/ .. _SinglePass: SinglePassIterator.html ]
[/ ]
[/ .. |Forward| replace:: *Forward Traversal* ]
[/ .. _Forward: ForwardTraversal.html ]
[/ ]
[/ .. |Bidir| replace:: *Bidirectional Traversal* ]
[/ .. _Bidir: BidirectionalTraversal.html ]
[/ ]
[/ .. |Random| replace:: *Random Access Traversal* ]
[/ .. _Random: RandomAccessTraversal.html ]
[h3 `iterator_concepts.hpp` Synopsis]
namespace boost_concepts {
// Iterator Access Concepts
template <typename Iterator>
class ReadableIteratorConcept;
template <
typename Iterator
, typename ValueType = std::iterator_traits<Iterator>::value_type
>
class WritableIteratorConcept;
template <typename Iterator>
class SwappableIteratorConcept;
template <typename Iterator>
class LvalueIteratorConcept;
// Iterator Traversal Concepts
template <typename Iterator>
class IncrementableIteratorConcept;
template <typename Iterator>
class SinglePassIteratorConcept;
template <typename Iterator>
class ForwardTraversalConcept;
template <typename Iterator>
class BidirectionalTraversalConcept;
template <typename Iterator>
class RandomAccessTraversalConcept;
// Interoperability
template <typename Iterator, typename ConstIterator>
class InteroperableIteratorConcept;
}
[endsect]
[endsect]

View File

@ -45,8 +45,7 @@ A non-generic implementation of ``zip_func`` could look as follows:
::
struct zip_func :
public std::unary_function<const boost::tuple<const double&, const int&>&, void>
struct zip_func
{
void operator()(const boost::tuple<const double&, const int&>& t) const
{

View File

@ -11,7 +11,17 @@
int main()
{
#if defined(BOOST_NO_CXX11_SMART_PTR)
std::auto_ptr<node<int> > nodes(new node<int>(42));
#else
std::unique_ptr<node<int> > nodes(new node<int>(42));
#endif
nodes->append(new node<std::string>(" is greater than "));
nodes->append(new node<int>(13));

View File

@ -12,7 +12,17 @@
int main()
{
#if defined(BOOST_NO_CXX11_SMART_PTR)
std::auto_ptr<node<int> > nodes(new node<int>(42));
#else
std::unique_ptr<node<int> > nodes(new node<int>(42));
#endif
nodes->append(new node<std::string>(" is greater than "));
nodes->append(new node<int>(13));

View File

@ -12,7 +12,17 @@
int main()
{
#if defined(BOOST_NO_CXX11_SMART_PTR)
std::auto_ptr<node<int> > nodes(new node<int>(42));
#else
std::unique_ptr<node<int> > nodes(new node<int>(42));
#endif
nodes->append(new node<std::string>(" is greater than "));
nodes->append(new node<int>(13));

View File

@ -0,0 +1,42 @@
// Copyright 2003 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "boost/shared_container_iterator.hpp"
#include "boost/shared_ptr.hpp"
#include <algorithm>
#include <iostream>
#include <vector>
typedef boost::shared_container_iterator< std::vector<int> > iterator;
void set_range(iterator& i, iterator& end) {
boost::shared_ptr< std::vector<int> > ints(new std::vector<int>());
ints->push_back(0);
ints->push_back(1);
ints->push_back(2);
ints->push_back(3);
ints->push_back(4);
ints->push_back(5);
i = iterator(ints->begin(),ints);
end = iterator(ints->end(),ints);
}
int main() {
iterator i,end;
set_range(i,end);
std::copy(i,end,std::ostream_iterator<int>(std::cout,","));
std::cout.put('\n');
return 0;
}

View File

@ -0,0 +1,43 @@
// Copyright 2003 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "boost/shared_container_iterator.hpp"
#include "boost/shared_ptr.hpp"
#include <algorithm>
#include <iterator>
#include <iostream>
#include <vector>
template <typename Iterator>
void print_range_nl (Iterator begin, Iterator end) {
typedef typename std::iterator_traits<Iterator>::value_type val;
std::copy(begin,end,std::ostream_iterator<val>(std::cout,","));
std::cout.put('\n');
}
int main() {
typedef boost::shared_ptr< std::vector<int> > ints_t;
{
ints_t ints(new std::vector<int>());
ints->push_back(0);
ints->push_back(1);
ints->push_back(2);
ints->push_back(3);
ints->push_back(4);
ints->push_back(5);
print_range_nl(boost::make_shared_container_iterator(ints->begin(),ints),
boost::make_shared_container_iterator(ints->end(),ints));
}
return 0;
}

View File

@ -0,0 +1,41 @@
// Copyright 2003 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "boost/shared_container_iterator.hpp"
#include "boost/shared_ptr.hpp"
#include "boost/tuple/tuple.hpp" // for boost::tie
#include <algorithm> // for std::copy
#include <iostream>
#include <vector>
typedef boost::shared_container_iterator< std::vector<int> > iterator;
std::pair<iterator,iterator>
return_range() {
boost::shared_ptr< std::vector<int> > range(new std::vector<int>());
range->push_back(0);
range->push_back(1);
range->push_back(2);
range->push_back(3);
range->push_back(4);
range->push_back(5);
return boost::make_shared_container_range(range);
}
int main() {
iterator i,end;
boost::tie(i,end) = return_range();
std::copy(i,end,std::ostream_iterator<int>(std::cout,","));
std::cout.put('\n');
return 0;
}

View File

@ -16,9 +16,10 @@
namespace boost {
template <class Operation>
class binder1st
: public std::unary_function<typename Operation::second_argument_type,
typename Operation::result_type> {
class binder1st {
public:
typedef typename Operation::result_type result_type;
typedef typename Operation::second_argument_type argument_type;
protected:
Operation op;
typename Operation::first_argument_type value;
@ -29,7 +30,7 @@ namespace boost {
: op(x), value(y) {}
typename Operation::result_type
operator()(const typename Operation::second_argument_type& x) const {
return op(value, x);
return op(value, x);
}
};
@ -72,5 +73,3 @@ main(int, char*[])
return 0;
}

View File

@ -1,62 +1,14 @@
// (C) Copyright Jeremy Siek 2001.
// (C) Copyright Andrey Semashev 2017.
// 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)
// Revision History:
// 27 Feb 2001 Jeremy Siek
// Initial checkin.
#ifndef BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
#define BOOST_FUNCTION_OUTPUT_ITERATOR_HPP
#include <iterator>
// This is a deprecated header left for backward compatibility.
// Use boost/iterator/function_output_iterator.hpp instead.
namespace boost {
namespace iterators {
template <class UnaryFunction>
class function_output_iterator {
typedef function_output_iterator self;
public:
typedef std::output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
explicit function_output_iterator() {}
explicit function_output_iterator(const UnaryFunction& 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); }
self& operator++() { return *this; }
self& operator++(int) { return *this; }
private:
UnaryFunction m_f;
};
template <class UnaryFunction>
inline function_output_iterator<UnaryFunction>
make_function_output_iterator(const UnaryFunction& f = UnaryFunction()) {
return function_output_iterator<UnaryFunction>(f);
}
} // namespace iterators
using iterators::function_output_iterator;
using iterators::make_function_output_iterator;
} // namespace boost
#include <boost/iterator/function_output_iterator.hpp>
#endif // BOOST_FUNCTION_OUTPUT_ITERATOR_HPP

View File

@ -0,0 +1,84 @@
// Copyright (C) 2017 Michel Morin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ITERATOR_ADVANCE_HPP
#define BOOST_ITERATOR_ADVANCE_HPP
#include <boost/config.hpp>
#include <boost/iterator/iterator_categories.hpp>
namespace boost {
namespace iterators {
namespace detail {
template <typename InputIterator, typename Distance>
inline BOOST_CXX14_CONSTEXPR void
advance_impl(
InputIterator& it
, Distance n
, incrementable_traversal_tag
)
{
while (n > 0) {
++it;
--n;
}
}
template <typename BidirectionalIterator, typename Distance>
inline BOOST_CXX14_CONSTEXPR void
advance_impl(
BidirectionalIterator& it
, Distance n
, bidirectional_traversal_tag
)
{
if (n >= 0) {
while (n > 0) {
++it;
--n;
}
}
else {
while (n < 0) {
--it;
++n;
}
}
}
template <typename RandomAccessIterator, typename Distance>
inline BOOST_CXX14_CONSTEXPR void
advance_impl(
RandomAccessIterator& it
, Distance n
, random_access_traversal_tag
)
{
it += n;
}
}
namespace advance_adl_barrier {
template <typename InputIterator, typename Distance>
inline BOOST_CXX14_CONSTEXPR void
advance(InputIterator& it, Distance n)
{
detail::advance_impl(
it, n, typename iterator_traversal<InputIterator>::type()
);
}
}
using namespace advance_adl_barrier;
} // namespace iterators
using iterators::advance;
} // namespace boost
#endif

View File

@ -0,0 +1,65 @@
// Copyright (C) 2017 Michel Morin.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_ITERATOR_DISTANCE_HPP
#define BOOST_ITERATOR_DISTANCE_HPP
#include <boost/config.hpp>
#include <boost/iterator/iterator_categories.hpp>
#include <boost/iterator/iterator_traits.hpp>
namespace boost {
namespace iterators {
namespace detail {
template <typename SinglePassIterator>
inline BOOST_CXX14_CONSTEXPR typename iterator_difference<SinglePassIterator>::type
distance_impl(
SinglePassIterator first
, SinglePassIterator last
, single_pass_traversal_tag
)
{
typename iterator_difference<SinglePassIterator>::type n = 0;
while (first != last) {
++first;
++n;
}
return n;
}
template <typename RandomAccessIterator>
inline BOOST_CXX14_CONSTEXPR typename iterator_difference<RandomAccessIterator>::type
distance_impl(
RandomAccessIterator first
, RandomAccessIterator last
, random_access_traversal_tag
)
{
return last - first;
}
}
namespace distance_adl_barrier {
template <typename SinglePassIterator>
inline BOOST_CXX14_CONSTEXPR typename iterator_difference<SinglePassIterator>::type
distance(SinglePassIterator first, SinglePassIterator last)
{
return detail::distance_impl(
first, last, typename iterator_traversal<SinglePassIterator>::type()
);
}
}
using namespace distance_adl_barrier;
} // namespace iterators
using iterators::distance;
} // namespace boost
#endif

View File

@ -7,7 +7,6 @@
#ifndef BOOST_FILTER_ITERATOR_23022003THW_HPP
#define BOOST_FILTER_ITERATOR_23022003THW_HPP
#include <boost/iterator.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/iterator_categories.hpp>

View File

@ -9,14 +9,20 @@
#ifndef BOOST_FUNCTION_INPUT_ITERATOR
#define BOOST_FUNCTION_INPUT_ITERATOR
#include <boost/config.hpp>
#include <boost/assert.hpp>
#include <boost/core/addressof.hpp>
#include <boost/mpl/if.hpp>
#include <boost/function_types/is_function_pointer.hpp>
#include <boost/function_types/is_function_reference.hpp>
#include <boost/function_types/result_type.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/none.hpp>
#include <boost/optional/optional.hpp>
#include <boost/utility/result_of.hpp>
#ifdef BOOST_RESULT_OF_USE_TR1
#include <boost/type_traits/is_function.hpp>
#endif
namespace boost {
@ -24,19 +30,34 @@ namespace iterators {
namespace impl {
// Computes the return type of an lvalue-call with an empty argument,
// i.e. decltype(declval<F&>()()). F should be a nullary lvalue-callable
// or function.
template <class F>
struct result_of_nullary_lvalue_call
{
typedef typename result_of<
#ifdef BOOST_RESULT_OF_USE_TR1
typename mpl::if_<is_function<F>, F&, F>::type()
#else
F&()
#endif
>::type type;
};
template <class Function, class Input>
class function_input_iterator
: public iterator_facade<
function_input_iterator<Function, Input>,
typename Function::result_type,
typename result_of_nullary_lvalue_call<Function>::type,
single_pass_traversal_tag,
typename Function::result_type const &
typename result_of_nullary_lvalue_call<Function>::type const &
>
{
public:
function_input_iterator() {}
function_input_iterator(Function & f_, Input state_ = Input())
: f(&f_), state(state_) {}
: f(boost::addressof(f_)), state(state_) {}
void increment() {
if(value)
@ -46,7 +67,7 @@ namespace iterators {
++state;
}
typename Function::result_type const &
typename result_of_nullary_lvalue_call<Function>::type const &
dereference() const {
return (value ? value : value = (*f)()).get();
}
@ -58,7 +79,7 @@ namespace iterators {
private:
Function * f;
Input state;
mutable optional<typename Function::result_type> value;
mutable optional<typename result_of_nullary_lvalue_call<Function>::type> value;
};
template <class Function, class Input>
@ -98,16 +119,6 @@ namespace iterators {
mutable optional<typename function_types::result_type<Function>::type> value;
};
template <class Function, class Input>
class function_reference_input_iterator
: public function_pointer_input_iterator<Function*,Input>
{
public:
function_reference_input_iterator(Function & f_, Input state_ = Input())
: function_pointer_input_iterator<Function*,Input>(&f_, state_)
{}
};
} // namespace impl
template <class Function, class Input>
@ -115,21 +126,13 @@ namespace iterators {
: public mpl::if_<
function_types::is_function_pointer<Function>,
impl::function_pointer_input_iterator<Function,Input>,
typename mpl::if_<
function_types::is_function_reference<Function>,
impl::function_reference_input_iterator<Function,Input>,
impl::function_input_iterator<Function,Input>
>::type
impl::function_input_iterator<Function,Input>
>::type
{
typedef typename mpl::if_<
function_types::is_function_pointer<Function>,
impl::function_pointer_input_iterator<Function,Input>,
typename mpl::if_<
function_types::is_function_reference<Function>,
impl::function_reference_input_iterator<Function,Input>,
impl::function_input_iterator<Function,Input>
>::type
impl::function_input_iterator<Function,Input>
>::type base_type;
public:
function_input_iterator(Function & f, Input i)

View File

@ -0,0 +1,62 @@
// (C) Copyright Jeremy Siek 2001.
// 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)
// Revision History:
// 27 Feb 2001 Jeremy Siek
// Initial checkin.
#ifndef BOOST_ITERATOR_FUNCTION_OUTPUT_ITERATOR_HPP
#define BOOST_ITERATOR_FUNCTION_OUTPUT_ITERATOR_HPP
#include <iterator>
namespace boost {
namespace iterators {
template <class UnaryFunction>
class function_output_iterator {
typedef function_output_iterator self;
public:
typedef std::output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
explicit function_output_iterator() {}
explicit function_output_iterator(const UnaryFunction& 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); }
self& operator++() { return *this; }
self& operator++(int) { return *this; }
private:
UnaryFunction m_f;
};
template <class UnaryFunction>
inline function_output_iterator<UnaryFunction>
make_function_output_iterator(const UnaryFunction& f = UnaryFunction()) {
return function_output_iterator<UnaryFunction>(f);
}
} // namespace iterators
using iterators::function_output_iterator;
using iterators::make_function_output_iterator;
} // namespace boost
#endif // BOOST_ITERATOR_FUNCTION_OUTPUT_ITERATOR_HPP

View File

@ -7,12 +7,10 @@
#ifndef BOOST_INDIRECT_ITERATOR_23022003THW_HPP
#define BOOST_INDIRECT_ITERATOR_23022003THW_HPP
#include <boost/iterator.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/pointee.hpp>
#include <boost/indirect_reference.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/detail/indirect_traits.hpp>
@ -25,6 +23,8 @@
#include <boost/mpl/not.hpp>
#include <boost/mpl/has_xxx.hpp>
#include <iterator>
#ifdef BOOST_MPL_CFG_NO_HAS_XXX
# include <boost/shared_ptr.hpp>
# include <boost/scoped_ptr.hpp>
@ -45,7 +45,7 @@ namespace iterators {
template <class Iter, class Value, class Category, class Reference, class Difference>
struct indirect_base
{
typedef typename boost::detail::iterator_traits<Iter>::value_type dereferenceable;
typedef typename std::iterator_traits<Iter>::value_type dereferenceable;
typedef iterator_adaptor<
indirect_iterator<Iter, Value, Category, Reference, Difference>

View File

@ -4,16 +4,15 @@
#ifndef IS_LVALUE_ITERATOR_DWA2003112_HPP
# define IS_LVALUE_ITERATOR_DWA2003112_HPP
#include <boost/iterator.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/type_traits/add_lvalue_reference.hpp>
#include <boost/iterator/detail/any_conversion_eater.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/aux_/lambda_support.hpp>
#include <iterator>
// should be the last #includes
#include <boost/type_traits/integral_constant.hpp>
#include <boost/iterator/detail/config_def.hpp>
@ -125,14 +124,14 @@ namespace detail
template <class It>
struct is_readable_lvalue_iterator_impl
: is_lvalue_iterator_impl<
BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<It>::value_type const
BOOST_DEDUCED_TYPENAME std::iterator_traits<It>::value_type const
>::template rebind<It>
{};
template <class It>
struct is_non_const_lvalue_iterator_impl
: is_lvalue_iterator_impl<
BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<It>::value_type
BOOST_DEDUCED_TYPENAME std::iterator_traits<It>::value_type
>::template rebind<It>
{};
} // namespace detail

View File

@ -6,11 +6,12 @@
#include <boost/mpl/bool.hpp>
#include <boost/mpl/aux_/lambda_support.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/type_traits/add_lvalue_reference.hpp>
#include <boost/iterator/detail/any_conversion_eater.hpp>
#include <iterator>
// should be the last #include
#include <boost/type_traits/integral_constant.hpp>
#include <boost/iterator/detail/config_def.hpp>
@ -93,7 +94,7 @@ namespace detail
template <class It>
struct is_readable_iterator_impl2
: is_readable_iterator_impl<
BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<It>::value_type const
BOOST_DEDUCED_TYPENAME std::iterator_traits<It>::value_type const
>::template rebind<It>
{};
} // namespace detail

View File

@ -8,8 +8,6 @@
#define BOOST_ITERATOR_ADAPTOR_23022003THW_HPP
#include <boost/static_assert.hpp>
#include <boost/iterator.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/iterator/iterator_categories.hpp>
#include <boost/iterator/iterator_facade.hpp>

View File

@ -9,7 +9,6 @@
#include <boost/iterator/iterator_categories.hpp>
#include <boost/operators.hpp>
#include <boost/static_assert.hpp>
#include <boost/iterator.hpp>
#include <boost/iterator/detail/facade_iterator_category.hpp>

View File

@ -7,7 +7,6 @@
# define BOOST_ITERATOR_CATEGORIES_HPP
# include <boost/config.hpp>
# include <boost/detail/iterator.hpp>
# include <boost/iterator/detail/config_def.hpp>
# include <boost/detail/workaround.hpp>
@ -21,6 +20,8 @@
# include <boost/static_assert.hpp>
#include <iterator>
namespace boost {
namespace iterators {
@ -116,7 +117,7 @@ struct iterator_category_to_traversal
template <class Iterator = mpl::_1>
struct iterator_traversal
: iterator_category_to_traversal<
typename boost::detail::iterator_traits<Iterator>::iterator_category
typename std::iterator_traits<Iterator>::iterator_category
>
{};

View File

@ -9,9 +9,6 @@
#include <boost/concept_check.hpp>
#include <boost/iterator/iterator_categories.hpp>
// Use boost::detail::iterator_traits to work around some MSVC/Dinkumware problems.
#include <boost/detail/iterator.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_integral.hpp>
@ -27,6 +24,7 @@
#include <boost/config.hpp>
#include <algorithm>
#include <iterator>
#include <boost/concept/detail/concept_def.hpp>
@ -44,8 +42,8 @@ namespace boost_concepts
, boost::CopyConstructible<Iterator>
{
typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::value_type value_type;
typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference reference;
typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::value_type value_type;
typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::reference reference;
BOOST_CONCEPT_USAGE(ReadableIterator)
{
@ -59,7 +57,7 @@ namespace boost_concepts
template <
typename Iterator
, typename ValueType = BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::value_type
, typename ValueType = BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::value_type
>
struct WritableIterator
: boost::CopyConstructible<Iterator>
@ -75,7 +73,7 @@ namespace boost_concepts
template <
typename Iterator
, typename ValueType = BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::value_type
, typename ValueType = BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::value_type
>
struct WritableIteratorConcept : WritableIterator<Iterator,ValueType> {};
@ -92,7 +90,7 @@ namespace boost_concepts
BOOST_concept(LvalueIterator,(Iterator))
{
typedef typename boost::detail::iterator_traits<Iterator>::value_type value_type;
typedef typename std::iterator_traits<Iterator>::value_type value_type;
BOOST_CONCEPT_USAGE(LvalueIterator)
{
@ -144,7 +142,7 @@ namespace boost_concepts
: SinglePassIterator<Iterator>
, boost::DefaultConstructible<Iterator>
{
typedef typename boost::detail::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_MPL_ASSERT_RELATION(std::numeric_limits<difference_type>::is_signed, ==, true);
@ -221,7 +219,7 @@ namespace boost_concepts
boost::random_access_traversal_tag, boost::random_access_traversal_tag)
{
bool b;
typename boost::detail::iterator_traits<Iterator2>::difference_type n;
typename std::iterator_traits<Iterator2>::difference_type n;
b = i1 < i2;
b = i1 <= i2;
b = i1 > i2;

View File

@ -8,7 +8,6 @@
#define BOOST_ITERATOR_FACADE_23022003THW_HPP
#include <boost/config.hpp>
#include <boost/iterator.hpp>
#include <boost/iterator/interoperable.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/iterator/iterator_categories.hpp>
@ -37,6 +36,8 @@
#include <boost/mpl/apply.hpp>
#include <boost/mpl/identity.hpp>
#include <cstddef>
#include <boost/iterator/detail/config_def.hpp> // this goes last
namespace boost {

View File

@ -5,9 +5,10 @@
#ifndef ITERATOR_TRAITS_DWA200347_HPP
# define ITERATOR_TRAITS_DWA200347_HPP
# include <boost/detail/iterator.hpp>
# include <boost/detail/workaround.hpp>
#include <iterator>
namespace boost {
namespace iterators {
@ -19,32 +20,32 @@ namespace iterators {
template <class Iterator>
struct iterator_value
{
typedef typename boost::detail::iterator_traits<Iterator>::value_type type;
typedef typename std::iterator_traits<Iterator>::value_type type;
};
template <class Iterator>
struct iterator_reference
{
typedef typename boost::detail::iterator_traits<Iterator>::reference type;
typedef typename std::iterator_traits<Iterator>::reference type;
};
template <class Iterator>
struct iterator_pointer
{
typedef typename boost::detail::iterator_traits<Iterator>::pointer type;
typedef typename std::iterator_traits<Iterator>::pointer type;
};
template <class Iterator>
struct iterator_difference
{
typedef typename boost::detail::iterator_traits<Iterator>::difference_type type;
typedef typename std::iterator_traits<Iterator>::difference_type type;
};
template <class Iterator>
struct iterator_category
{
typedef typename boost::detail::iterator_traits<Iterator>::iterator_category type;
typedef typename std::iterator_traits<Iterator>::iterator_category type;
};
} // namespace iterators

View File

@ -29,17 +29,18 @@
// (David Abrahams)
# include <iterator>
# include <boost/type_traits.hpp>
# include <boost/static_assert.hpp>
# include <boost/concept_archetype.hpp> // for detail::dummy_constructor
# include <boost/detail/iterator.hpp>
# include <boost/pending/iterator_tests.hpp>
# include <boost/iterator/is_readable_iterator.hpp>
# include <boost/iterator/is_lvalue_iterator.hpp>
# include <boost/type_traits/is_same.hpp>
# include <boost/mpl/bool.hpp>
# include <boost/mpl/and.hpp>
# include <boost/iterator/detail/config_def.hpp>
# include <boost/detail/is_incrementable.hpp>
# include <boost/detail/lightweight_test.hpp>
# include <boost/core/lightweight_test.hpp>
namespace boost {
@ -76,7 +77,7 @@ template <class Iterator, class T>
void readable_iterator_test(const Iterator i1, T v)
{
Iterator i2(i1); // Copy Constructible
typedef typename detail::iterator_traits<Iterator>::reference ref_t;
typedef typename std::iterator_traits<Iterator>::reference ref_t;
ref_t r1 = *i1;
ref_t r2 = *i2;
T v1 = r1;
@ -112,9 +113,9 @@ template <class Iterator>
void swappable_iterator_test(Iterator i, Iterator j)
{
Iterator i2(i), j2(j);
typename detail::iterator_traits<Iterator>::value_type bi = *i, bj = *j;
typename std::iterator_traits<Iterator>::value_type bi = *i, bj = *j;
iter_swap(i2, j2);
typename detail::iterator_traits<Iterator>::value_type ai = *i, aj = *j;
typename std::iterator_traits<Iterator>::value_type ai = *i, aj = *j;
BOOST_TEST(bi == aj && bj == ai);
}
@ -122,8 +123,8 @@ template <class Iterator, class T>
void constant_lvalue_iterator_test(Iterator i, T v1)
{
Iterator i2(i);
typedef typename detail::iterator_traits<Iterator>::value_type value_type;
typedef typename detail::iterator_traits<Iterator>::reference reference;
typedef typename std::iterator_traits<Iterator>::value_type value_type;
typedef typename std::iterator_traits<Iterator>::reference reference;
BOOST_STATIC_ASSERT((is_same<const value_type&, reference>::value));
const T& v2 = *i2;
BOOST_TEST(v1 == v2);
@ -137,8 +138,8 @@ template <class Iterator, class T>
void non_const_lvalue_iterator_test(Iterator i, T v1, T v2)
{
Iterator i2(i);
typedef typename detail::iterator_traits<Iterator>::value_type value_type;
typedef typename detail::iterator_traits<Iterator>::reference reference;
typedef typename std::iterator_traits<Iterator>::value_type value_type;
typedef typename std::iterator_traits<Iterator>::reference reference;
BOOST_STATIC_ASSERT((is_same<value_type&, reference>::value));
T& v3 = *i2;
BOOST_TEST(v1 == v3);
@ -229,7 +230,7 @@ void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals)
{
BOOST_TEST(i == j + c);
BOOST_TEST(*i == vals[c]);
typename detail::iterator_traits<Iterator>::value_type x = j[c];
typename std::iterator_traits<Iterator>::value_type x = j[c];
BOOST_TEST(*i == x);
BOOST_TEST(*i == *(j + c));
BOOST_TEST(*i == *(c + j));
@ -245,7 +246,7 @@ void random_access_readable_iterator_test(Iterator i, int N, TrueVals vals)
{
BOOST_TEST(i == k - c);
BOOST_TEST(*i == vals[N - 1 - c]);
typename detail::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);
Iterator q = k - c;
BOOST_TEST(*i == *q);

View File

@ -21,13 +21,13 @@ template< class ElementIterator
class permutation_iterator
: public iterator_adaptor<
permutation_iterator<ElementIterator, IndexIterator>
, IndexIterator, typename boost::detail::iterator_traits<ElementIterator>::value_type
, use_default, typename boost::detail::iterator_traits<ElementIterator>::reference>
, IndexIterator, typename std::iterator_traits<ElementIterator>::value_type
, use_default, typename std::iterator_traits<ElementIterator>::reference>
{
typedef iterator_adaptor<
permutation_iterator<ElementIterator, IndexIterator>
, IndexIterator, typename boost::detail::iterator_traits<ElementIterator>::value_type
, use_default, typename boost::detail::iterator_traits<ElementIterator>::reference> super_t;
, IndexIterator, typename std::iterator_traits<ElementIterator>::value_type
, use_default, typename std::iterator_traits<ElementIterator>::reference> super_t;
friend class iterator_core_access;

View File

@ -7,8 +7,6 @@
#ifndef BOOST_REVERSE_ITERATOR_23022003THW_HPP
#define BOOST_REVERSE_ITERATOR_23022003THW_HPP
#include <boost/next_prior.hpp>
#include <boost/iterator.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
namespace boost {
@ -40,14 +38,19 @@ namespace iterators {
{}
private:
typename super_t::reference dereference() const { return *boost::prior(this->base()); }
typename super_t::reference dereference() const
{
Iterator it = this->base_reference();
--it;
return *it;
}
void increment() { --this->base_reference(); }
void decrement() { ++this->base_reference(); }
void advance(typename super_t::difference_type n)
{
this->base_reference() += -n;
this->base_reference() -= n;
}
template <class OtherIterator>

View File

@ -7,7 +7,6 @@
#ifndef BOOST_TRANSFORM_ITERATOR_23022003THW_HPP
#define BOOST_TRANSFORM_ITERATOR_23022003THW_HPP
#include <boost/iterator.hpp>
#include <boost/iterator/detail/enable_if.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/iterator/iterator_categories.hpp>
@ -22,11 +21,12 @@
#include <boost/type_traits/remove_reference.hpp>
#include <boost/utility/result_of.hpp>
#include <iterator>
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
# include <boost/type_traits/is_base_and_derived.hpp>
#endif
#include <boost/iterator/detail/config_def.hpp>
@ -47,7 +47,11 @@ namespace iterators {
// the function.
typedef typename ia_dflt_help<
Reference
#ifdef BOOST_RESULT_OF_USE_TR1
, result_of<const UnaryFunc(typename std::iterator_traits<Iterator>::reference)>
#else
, result_of<const UnaryFunc&(typename std::iterator_traits<Iterator>::reference)>
#endif
>::type reference;
// To get the default for Value: remove any reference on the

View File

@ -9,7 +9,6 @@
# define BOOST_ZIP_ITERATOR_TMB_07_13_2003_HPP_
#include <stddef.h>
#include <boost/iterator.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/iterator/iterator_adaptor.hpp> // for enable_if_convertible
@ -84,7 +83,7 @@ namespace iterators {
struct result<This(Iterator)>
{
typedef typename
remove_reference<typename remove_cv<Iterator>::type>::type
remove_cv<typename remove_reference<Iterator>::type>::type
iterator;
typedef typename iterator_reference<iterator>::type type;

View File

@ -0,0 +1,195 @@
// Boost next_prior.hpp header file ---------------------------------------//
// (C) Copyright Dave Abrahams and Daniel Walker 1999-2003.
// Copyright (c) Andrey Semashev 2017
//
// 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)
// See http://www.boost.org/libs/utility for documentation.
// Revision History
// 13 Dec 2003 Added next(x, n) and prior(x, n) (Daniel Walker)
#ifndef BOOST_NEXT_PRIOR_HPP_INCLUDED
#define BOOST_NEXT_PRIOR_HPP_INCLUDED
#include <iterator>
#include <boost/config.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/type_traits/has_plus.hpp>
#include <boost/type_traits/has_plus_assign.hpp>
#include <boost/type_traits/has_minus.hpp>
#include <boost/type_traits/has_minus_assign.hpp>
#include <boost/iterator/advance.hpp>
#include <boost/iterator/reverse_iterator.hpp>
namespace boost {
// Helper functions for classes like bidirectional iterators not supporting
// operator+ and operator-
//
// Usage:
// const std::list<T>::iterator p = get_some_iterator();
// const std::list<T>::iterator prev = boost::prior(p);
// const std::list<T>::iterator next = boost::next(prev, 2);
// Contributed by Dave Abrahams
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 >
struct next_plus_impl;
template< typename T, typename Distance >
struct next_plus_impl< T, Distance, true >
{
static T call(T x, Distance n)
{
return x + n;
}
};
template< typename T, typename Distance, bool HasPlusAssign = has_plus_assign< T, Distance >::value >
struct next_plus_assign_impl :
public next_plus_impl< T, Distance >
{
};
template< typename T, typename Distance >
struct next_plus_assign_impl< T, Distance, true >
{
static T call(T x, Distance n)
{
x += n;
return x;
}
};
template< typename T, typename Distance, bool IsIterator = is_iterator< T >::value >
struct next_advance_impl :
public next_plus_assign_impl< T, Distance >
{
};
template< typename T, typename Distance >
struct next_advance_impl< T, Distance, true >
{
static T call(T x, Distance n)
{
boost::iterators::advance(x, n);
return x;
}
};
template< typename T, typename Distance, bool HasMinus = has_minus< T, Distance >::value >
struct prior_minus_impl;
template< typename T, typename Distance >
struct prior_minus_impl< T, Distance, true >
{
static T call(T x, Distance n)
{
return x - n;
}
};
template< typename T, typename Distance, bool HasMinusAssign = has_minus_assign< T, Distance >::value >
struct prior_minus_assign_impl :
public prior_minus_impl< T, Distance >
{
};
template< typename T, typename Distance >
struct prior_minus_assign_impl< T, Distance, true >
{
static T call(T x, Distance n)
{
x -= n;
return x;
}
};
template< typename T, typename Distance, bool IsIterator = is_iterator< T >::value >
struct prior_advance_impl :
public prior_minus_assign_impl< T, Distance >
{
};
template< typename T, typename Distance >
struct prior_advance_impl< T, Distance, true >
{
static T call(T x, Distance n)
{
// Avoid negating n to sidestep possible integer overflow
boost::iterators::reverse_iterator< T > rx(x);
boost::iterators::advance(rx, n);
return rx.base();
}
};
} // namespace next_prior_detail
template <class T>
inline T next(T x) { return ++x; }
template <class T, class Distance>
inline T next(T x, Distance n)
{
return next_prior_detail::next_advance_impl< T, Distance >::call(x, n);
}
template <class T>
inline T prior(T x) { return --x; }
template <class T, class Distance>
inline T prior(T x, Distance n)
{
return next_prior_detail::prior_advance_impl< T, Distance >::call(x, n);
}
} // namespace boost
#endif // BOOST_NEXT_PRIOR_HPP_INCLUDED

View File

@ -6,11 +6,12 @@
#ifndef BOOST_INT_ITERATOR_H
#define BOOST_INT_ITERATOR_H
#include <boost/iterator.hpp>
#if !defined BOOST_MSVC
#include <boost/operators.hpp>
#endif
#include <iostream>
#include <iterator>
#include <cstddef>
//using namespace std;
#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE

View File

@ -20,11 +20,14 @@
// (David Abrahams)
# include <iterator>
# include <assert.h>
# include <boost/type_traits.hpp>
# include <boost/static_assert.hpp>
# include <boost/concept_archetype.hpp> // for detail::dummy_constructor
# include <boost/implicit_cast.hpp>
# include <boost/core/ignore_unused.hpp>
# include <boost/core/lightweight_test.hpp>
# include <boost/type_traits/is_same.hpp>
# include <boost/type_traits/is_pointer.hpp>
# include <boost/type_traits/is_reference.hpp>
namespace boost {
@ -50,27 +53,29 @@ template <class Iterator, class T>
void trivial_iterator_test(const Iterator i, const Iterator j, T val)
{
Iterator k;
assert(i == i);
assert(j == j);
assert(i != j);
BOOST_TEST(i == i);
BOOST_TEST(j == j);
BOOST_TEST(i != j);
#ifdef BOOST_NO_STD_ITERATOR_TRAITS
T v = *i;
#else
typename std::iterator_traits<Iterator>::value_type v = *i;
#endif
assert(v == val);
BOOST_TEST(v == val);
boost::ignore_unused(v);
#if 0
// hmm, this will give a warning for transform_iterator... perhaps
// this should be separated out into a stand-alone test since there
// are several situations where it can't be used, like for
// integer_range::iterator.
assert(v == i->foo());
BOOST_TEST(v == i->foo());
#endif
k = i;
assert(k == k);
assert(k == i);
assert(k != j);
assert(*k == val);
BOOST_TEST(k == k);
BOOST_TEST(k == i);
BOOST_TEST(k != j);
BOOST_TEST(*k == val);
boost::ignore_unused(k);
}
@ -89,8 +94,8 @@ void input_iterator_test(Iterator i, T v1, T v2)
{
Iterator i1(i);
assert(i == i1);
assert(!(i != i1));
BOOST_TEST(i == i1);
BOOST_TEST(!(i != i1));
// I can see no generic way to create an input iterator
// that is in the domain of== of i and != i.
@ -99,23 +104,25 @@ void input_iterator_test(Iterator i, T v1, T v2)
//
// Iterator i2;
//
// assert(i != i2);
// assert(!(i == i2));
// BOOST_TEST(i != i2);
// BOOST_TEST(!(i == i2));
assert(*i1 == v1);
assert(*i == v1);
BOOST_TEST(*i1 == v1);
BOOST_TEST(*i == v1);
// we cannot test for equivalence of (void)++i & (void)i++
// as i is only guaranteed to be single pass.
assert(*i++ == v1);
BOOST_TEST(*i++ == v1);
boost::ignore_unused(i1);
i1 = i;
assert(i == i1);
assert(!(i != i1));
BOOST_TEST(i == i1);
BOOST_TEST(!(i != i1));
assert(*i1 == v2);
assert(*i == v2);
BOOST_TEST(*i1 == v2);
BOOST_TEST(*i == v2);
boost::ignore_unused(i1);
// i is dereferencable, so it must be incrementable.
++i;
@ -157,15 +164,15 @@ void forward_iterator_test(Iterator i, T v1, T v2)
Iterator i1 = i, i2 = i;
assert(i == i1++);
assert(i != ++i2);
BOOST_TEST(i == i1++);
BOOST_TEST(i != ++i2);
trivial_iterator_test(i, i1, v1);
trivial_iterator_test(i, i2, v1);
++i;
assert(i == i1);
assert(i == i2);
BOOST_TEST(i == i1);
BOOST_TEST(i == i2);
++i1;
++i2;
@ -187,15 +194,15 @@ void bidirectional_iterator_test(Iterator i, T v1, T v2)
Iterator i1 = i, i2 = i;
assert(i == i1--);
assert(i != --i2);
BOOST_TEST(i == i1--);
BOOST_TEST(i != --i2);
trivial_iterator_test(i, i1, v2);
trivial_iterator_test(i, i2, v2);
--i;
assert(i == i1);
assert(i == i2);
BOOST_TEST(i == i1);
BOOST_TEST(i == i2);
++i1;
++i2;
@ -215,32 +222,34 @@ void random_access_iterator_test(Iterator i, int N, TrueVals vals)
const Iterator j = i;
int c;
typedef typename boost::detail::iterator_traits<Iterator>::value_type value_type;
typedef typename std::iterator_traits<Iterator>::value_type value_type;
boost::ignore_unused<value_type>();
for (c = 0; c < N-1; ++c) {
assert(i == j + c);
assert(*i == vals[c]);
assert(*i == boost::implicit_cast<value_type>(j[c]));
assert(*i == *(j + c));
assert(*i == *(c + j));
BOOST_TEST(i == j + c);
BOOST_TEST(*i == vals[c]);
BOOST_TEST(*i == boost::implicit_cast<value_type>(j[c]));
BOOST_TEST(*i == *(j + c));
BOOST_TEST(*i == *(c + j));
++i;
assert(i > j);
assert(i >= j);
assert(j <= i);
assert(j < i);
BOOST_TEST(i > j);
BOOST_TEST(i >= j);
BOOST_TEST(j <= i);
BOOST_TEST(j < i);
}
Iterator k = j + N - 1;
for (c = 0; c < N-1; ++c) {
assert(i == k - c);
assert(*i == vals[N - 1 - c]);
assert(*i == boost::implicit_cast<value_type>(j[N - 1 - c]));
BOOST_TEST(i == k - c);
BOOST_TEST(*i == vals[N - 1 - c]);
BOOST_TEST(*i == boost::implicit_cast<value_type>(j[N - 1 - c]));
Iterator q = k - c;
assert(*i == *q);
assert(i > j);
assert(i >= j);
assert(j <= i);
assert(j < i);
boost::ignore_unused(q);
BOOST_TEST(*i == *q);
BOOST_TEST(i > j);
BOOST_TEST(i >= j);
BOOST_TEST(j <= i);
BOOST_TEST(j < i);
--i;
}
}
@ -249,16 +258,17 @@ void random_access_iterator_test(Iterator i, int N, TrueVals vals)
template <class Iterator, class ConstIterator>
void const_nonconst_iterator_test(Iterator i, ConstIterator j)
{
assert(i != j);
assert(j != i);
BOOST_TEST(i != j);
BOOST_TEST(j != i);
ConstIterator k(i);
assert(k == i);
assert(i == k);
BOOST_TEST(k == i);
BOOST_TEST(i == k);
k = i;
assert(k == i);
assert(i == k);
BOOST_TEST(k == i);
BOOST_TEST(i == k);
boost::ignore_unused(k);
}
} // namespace iterators

View File

@ -20,6 +20,8 @@
# include <boost/mpl/if.hpp>
# include <boost/mpl/eval_if.hpp>
#include <iterator>
namespace boost {
namespace detail
@ -33,7 +35,7 @@ namespace detail
template <class Iterator>
struct iterator_pointee
{
typedef typename iterator_traits<Iterator>::value_type value_type;
typedef typename std::iterator_traits<Iterator>::value_type value_type;
struct impl
{

View File

@ -55,4 +55,10 @@ test-suite iterator
[ run minimum_category.cpp ]
[ compile-fail minimum_category_compile_fail.cpp ]
[ run next_prior_test.cpp ]
[ run advance_test.cpp ]
[ run distance_test.cpp ]
[ run shared_iterator_test.cpp ]
;

91
test/advance_test.cpp Normal file
View File

@ -0,0 +1,91 @@
// Copyright (C) 2017 Michel Morin.
//
// 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 <vector>
#include <list>
#include <boost/container/slist.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/iterator/advance.hpp>
#include <boost/iterator/transform_iterator.hpp>
int twice(int x) { return x + x; }
template <typename Iterator>
void test_advance(Iterator it_from, Iterator it_to, int n)
{
boost::advance(it_from, n);
BOOST_TEST(it_from == it_to);
}
int main()
{
int array[3] = {1, 2, 3};
int* ptr1 = array;
int* ptr2 = array + 3;
{
test_advance(ptr1, ptr2, 3);
test_advance(ptr2, ptr1, -3);
test_advance(
boost::make_transform_iterator(ptr1, twice)
, boost::make_transform_iterator(ptr2, twice)
, 3
);
test_advance(
boost::make_transform_iterator(ptr2, twice)
, boost::make_transform_iterator(ptr1, twice)
, -3
);
}
{
std::vector<int> ints(ptr1, ptr2);
test_advance(ints.begin(), ints.end(), 3);
test_advance(ints.end(), ints.begin(), -3);
test_advance(
boost::make_transform_iterator(ints.begin(), twice)
, boost::make_transform_iterator(ints.end(), twice)
, 3
);
test_advance(
boost::make_transform_iterator(ints.end(), twice)
, boost::make_transform_iterator(ints.begin(), twice)
, -3
);
}
{
std::list<int> ints(ptr1, ptr2);
test_advance(ints.begin(), ints.end(), 3);
test_advance(ints.end(), ints.begin(), -3);
test_advance(
boost::make_transform_iterator(ints.begin(), twice)
, boost::make_transform_iterator(ints.end(), twice)
, 3
);
test_advance(
boost::make_transform_iterator(ints.end(), twice)
, boost::make_transform_iterator(ints.begin(), twice)
, -3
);
}
{
boost::container::slist<int> ints(ptr1, ptr2);
test_advance(ints.begin(), ints.end(), 3);
test_advance(
boost::make_transform_iterator(ints.begin(), twice)
, boost::make_transform_iterator(ints.end(), twice)
, 3
);
}
return boost::report_errors();
}

View File

@ -7,13 +7,16 @@
#include <boost/iterator/iterator_categories.hpp>
#include <boost/operators.hpp>
#include <iterator>
#include <cstddef>
struct new_random_access
: std::random_access_iterator_tag
, boost::random_access_traversal_tag
{};
struct new_iterator
: public boost::iterator< new_random_access, int >
: public std::iterator< new_random_access, int >
{
int& operator*() const { return *m_x; }
new_iterator& operator++() { return *this; }
@ -33,7 +36,7 @@ struct new_iterator
new_iterator operator+(std::ptrdiff_t, new_iterator x) { return x; }
struct old_iterator
: public boost::iterator<std::random_access_iterator_tag, int>
: public std::iterator<std::random_access_iterator_tag, int>
{
int& operator*() const { return *m_x; }
old_iterator& operator++() { return *this; }

View File

@ -153,7 +153,6 @@ template <class CountingIterator, class Value>
void test_aux(CountingIterator start, CountingIterator finish, Value v1)
{
typedef typename CountingIterator::iterator_category category;
typedef typename CountingIterator::value_type value_type;
// If it's a RandomAccessIterator we can do a few delicate tests
category_test(start, finish, v1, category());

View File

@ -58,6 +58,18 @@ int main()
BOOST_TEST(boost::fusion::at_c<1>(*(i + 1)) == "pyonpyon");
}
{
// Trac #12895
boost::zip_iterator<
TUPLE<int*, std::string*>
> i(MAKE_TUPLE(&vi[0], &vs[0]));
BOOST_TEST(boost::fusion::at_c<0>(* i ) == 42);
BOOST_TEST(boost::fusion::at_c<1>(* i ) == "kokoro");
BOOST_TEST(boost::fusion::at_c<0>(*(i + 1)) == 72);
BOOST_TEST(boost::fusion::at_c<1>(*(i + 1)) == "pyonpyon");
}
{
boost::zip_iterator<iterator_tuple> i1(MAKE_TUPLE(vi.begin(), vs.begin()));
boost::zip_iterator<iterator_tuple> i2(MAKE_TUPLE(vi.end(), vs.end()));

84
test/distance_test.cpp Normal file
View File

@ -0,0 +1,84 @@
// Copyright (C) 2017 Michel Morin.
//
// 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 <vector>
#include <list>
#include <boost/container/slist.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/iterator/distance.hpp>
#include <boost/iterator/transform_iterator.hpp>
int twice(int x) { return x + x; }
template <typename Iterator>
void test_distance(Iterator it_from, Iterator it_to, int n)
{
BOOST_TEST(boost::distance(it_from, it_to) == n);
}
int main()
{
int array[3] = {1, 2, 3};
int* ptr1 = array;
int* ptr2 = array + 3;
{
test_distance(ptr1, ptr2, 3);
test_distance(ptr2, ptr1, -3);
test_distance(
boost::make_transform_iterator(ptr1, twice)
, boost::make_transform_iterator(ptr2, twice)
, 3
);
test_distance(
boost::make_transform_iterator(ptr2, twice)
, boost::make_transform_iterator(ptr1, twice)
, -3
);
}
{
std::vector<int> ints(ptr1, ptr2);
test_distance(ints.begin(), ints.end(), 3);
test_distance(ints.end(), ints.begin(), -3);
test_distance(
boost::make_transform_iterator(ints.begin(), twice)
, boost::make_transform_iterator(ints.end(), twice)
, 3
);
test_distance(
boost::make_transform_iterator(ints.end(), twice)
, boost::make_transform_iterator(ints.begin(), twice)
, -3
);
}
{
std::list<int> ints(ptr1, ptr2);
test_distance(ints.begin(), ints.end(), 3);
test_distance(
boost::make_transform_iterator(ints.begin(), twice)
, boost::make_transform_iterator(ints.end(), twice)
, 3
);
}
{
boost::container::slist<int> ints(ptr1, ptr2);
test_distance(ints.begin(), ints.end(), 3);
test_distance(
boost::make_transform_iterator(ints.begin(), twice)
, boost::make_transform_iterator(ints.end(), twice)
, 3
);
}
return boost::report_errors();
}

View File

@ -3,14 +3,24 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <cassert>
#include <cstddef>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_DECLTYPE)
// Force boost::result_of use decltype, even on compilers that don't support N3276.
// This enables this test to also verify if the iterator works with lambdas
// on such compilers with this config macro. Note that without the macro result_of
// (and consequently the iterator) is guaranteed to _not_ work, so this case is not
// worth testing anyway.
#define BOOST_RESULT_OF_USE_DECLTYPE
#endif
#include <boost/core/lightweight_test.hpp>
#include <boost/iterator/function_input_iterator.hpp>
namespace {
@ -39,7 +49,7 @@ struct counter {
using namespace std;
int main(int argc, char * argv[])
int main()
{
// test the iterator with function objects
ones ones_generator;
@ -53,9 +63,7 @@ int main(int argc, char * argv[])
back_inserter(generated)
);
assert(values.size() == generated.size());
assert(equal(values.begin(), values.end(), generated.begin()));
cout << "function iterator test with function objects successful." << endl;
BOOST_TEST_ALL_EQ(values.begin(), values.end(), generated.begin(), generated.end());
// test the iterator with normal functions
vector<int>().swap(generated);
@ -65,9 +73,7 @@ int main(int argc, char * argv[])
back_inserter(generated)
);
assert(values.size() == generated.size());
assert(equal(values.begin(), values.end(), generated.begin()));
cout << "function iterator test with pointer to function successful." << endl;
BOOST_TEST_ALL_EQ(values.begin(), values.end(), generated.begin(), generated.end());
// test the iterator with a reference to a function
vector<int>().swap(generated);
@ -77,9 +83,7 @@ int main(int argc, char * argv[])
back_inserter(generated)
);
assert(values.size() == generated.size());
assert(equal(values.begin(), values.end(), generated.begin()));
cout << "function iterator test with reference to function successful." << endl;
BOOST_TEST_ALL_EQ(values.begin(), values.end(), generated.begin(), generated.end());
// test the iterator with a stateful function object
counter counter_generator(42);
@ -90,12 +94,27 @@ int main(int argc, char * argv[])
back_inserter(generated)
);
assert(generated.size() == 10);
assert(counter_generator.n == 42 + 10);
BOOST_TEST_EQ(generated.size(), 10u);
BOOST_TEST_EQ(counter_generator.n, 42 + 10);
for(std::size_t i = 0; i != 10; ++i)
assert(generated[i] == 42 + i);
cout << "function iterator test with stateful function object successful." << endl;
BOOST_TEST_EQ(generated[i], static_cast<int>(42 + i));
return 0;
#if !defined(BOOST_NO_CXX11_LAMBDAS) && !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) \
&& defined(BOOST_RESULT_OF_USE_DECLTYPE)
// test the iterator with lambda expressions
int num = 42;
auto lambda_generator = [&num] { return num++; };
vector<int>().swap(generated);
copy(
boost::make_function_input_iterator(lambda_generator, 0),
boost::make_function_input_iterator(lambda_generator, 10),
back_inserter(generated)
);
BOOST_TEST_EQ(generated.size(), 10u);
for(std::size_t i = 0; i != 10; ++i)
BOOST_TEST_EQ(generated[i], static_cast<int>(42 + i));
#endif // BOOST_NO_CXX11_LAMBDAS
return boost::report_errors();
}

View File

@ -24,6 +24,7 @@
#include <boost/concept_check.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
#include <boost/next_prior.hpp>
#include <boost/mpl/has_xxx.hpp>
@ -32,6 +33,7 @@
#include <vector>
#include <stdlib.h>
#include <set>
#include <iterator>
#if !defined(__SGI_STL_PORT) \
&& (defined(BOOST_MSVC_STD_ITERATOR) \
@ -164,7 +166,7 @@ main()
BOOST_STATIC_ASSERT(
has_element_type<
boost::detail::iterator_traits<shared_t::iterator>::value_type
std::iterator_traits<shared_t::iterator>::value_type
>::value
);

View File

@ -33,37 +33,6 @@
using boost::dummyT;
struct mult_functor {
typedef int result_type;
typedef int argument_type;
// Functors used with transform_iterator must be
// DefaultConstructible, as the transform_iterator must be
// DefaultConstructible to satisfy the requirements for
// TrivialIterator.
mult_functor() { }
mult_functor(int aa) : a(aa) { }
int operator()(int b) const { return a * b; }
int a;
};
template <class Pair>
struct select1st_
: public std::unary_function<Pair, typename Pair::first_type>
{
const typename Pair::first_type& operator()(const Pair& x) const {
return x.first;
}
typename Pair::first_type& operator()(Pair& x) const {
return x.first;
}
};
struct one_or_four {
bool operator()(dummyT x) const {
return x.foo() == 1 || x.foo() == 4;
}
};
typedef std::deque<int> storage;
typedef std::deque<int*> pointer_deque;
typedef std::set<storage::iterator> iterator_set;

View File

@ -86,7 +86,7 @@ struct input_iter
return value();
}
bool equal(input_iter const& y) const
bool equal(input_iter const&) const
{
return false;
}

112
test/next_prior_test.cpp Normal file
View File

@ -0,0 +1,112 @@
// Boost test program for next() and prior() utilities.
// Copyright 2003 Daniel Walker. Use, modification, and distribution
// are subject to the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or a copy at
// http://www.boost.org/LICENSE_1_0.txt.)
// See http://www.boost.org/libs/utility for documentation.
// Revision History 13 Dec 2003 Initial Version (Daniel Walker)
// next() and prior() are replacements for operator+ and operator- for
// non-random-access iterators. The semantics of these operators are
// such that after executing j = i + n, std::distance(i, j) equals
// n. Tests are provided to ensure next() has the same
// result. Parallel tests are provided for prior(). The tests call
// next() and prior() several times. next() and prior() are very
// simple functions, though, and it would be very strange if these
// tests were to fail.
#include <boost/core/lightweight_test.hpp>
#include <list>
#include <vector>
#include <boost/next_prior.hpp>
template<class RandomAccessIterator, class ForwardIterator>
bool plus_one_test(RandomAccessIterator first, RandomAccessIterator last, ForwardIterator first2)
{
RandomAccessIterator i = first;
ForwardIterator j = first2;
while(i != last)
i = i + 1, j = boost::next(j);
return std::distance(first, i) == std::distance(first2, j);
}
template<class RandomAccessIterator, class ForwardIterator>
bool plus_n_test(RandomAccessIterator first, RandomAccessIterator last, ForwardIterator first2)
{
RandomAccessIterator i = first;
ForwardIterator j = first2;
for(int n = 0; i != last; ++n)
i = first + n, j = boost::next(first2, n);
return std::distance(first, i) == std::distance(first2, j);
}
template<class RandomAccessIterator, class BidirectionalIterator>
bool minus_one_test(RandomAccessIterator first, RandomAccessIterator last, BidirectionalIterator last2)
{
RandomAccessIterator i = last;
BidirectionalIterator j = last2;
while(i != first)
i = i - 1, j = boost::prior(j);
return std::distance(i, last) == std::distance(j, last2);
}
template<class RandomAccessIterator, class BidirectionalIterator>
bool minus_n_test(RandomAccessIterator first, RandomAccessIterator last, BidirectionalIterator last2)
{
RandomAccessIterator i = last;
BidirectionalIterator j = last2;
for(int n = 0; i != first; ++n)
i = last - n, j = boost::prior(last2, n);
return std::distance(i, last) == std::distance(j, last2);
}
template<class Iterator, class Distance>
bool minus_n_unsigned_test(Iterator first, Iterator last, Distance size)
{
Iterator i = boost::prior(last, size);
return i == first;
}
int main(int, char*[])
{
std::vector<int> x(8);
std::list<int> y(x.begin(), x.end());
// Tests with iterators
BOOST_TEST(plus_one_test(x.begin(), x.end(), y.begin()));
BOOST_TEST(plus_n_test(x.begin(), x.end(), y.begin()));
BOOST_TEST(minus_one_test(x.begin(), x.end(), y.end()));
BOOST_TEST(minus_n_test(x.begin(), x.end(), y.end()));
BOOST_TEST(minus_n_unsigned_test(x.begin(), x.end(), x.size()));
BOOST_TEST(minus_n_unsigned_test(y.begin(), y.end(), y.size()));
BOOST_TEST(plus_one_test(x.rbegin(), x.rend(), y.begin()));
BOOST_TEST(plus_n_test(x.rbegin(), x.rend(), y.begin()));
BOOST_TEST(minus_one_test(x.rbegin(), x.rend(), y.end()));
BOOST_TEST(minus_n_test(x.rbegin(), x.rend(), y.end()));
BOOST_TEST(minus_n_unsigned_test(x.rbegin(), x.rend(), x.size()));
BOOST_TEST(minus_n_unsigned_test(x.rbegin(), x.rend(), y.size()));
// Test with pointers
std::vector<int> z(x.size());
int* p = &z[0];
BOOST_TEST(plus_one_test(x.begin(), x.end(), p));
BOOST_TEST(plus_n_test(x.begin(), x.end(), p));
BOOST_TEST(minus_one_test(x.begin(), x.end(), p + z.size()));
BOOST_TEST(minus_n_test(x.begin(), x.end(), p + z.size()));
BOOST_TEST(minus_n_unsigned_test(p, p + z.size(), z.size()));
// Tests with integers
BOOST_TEST(boost::next(5) == 6);
BOOST_TEST(boost::next(5, 7) == 12);
BOOST_TEST(boost::prior(5) == 4);
BOOST_TEST(boost::prior(5, 7) == -2);
BOOST_TEST(boost::prior(5, 7u) == -2);
return boost::report_errors();
}

View File

@ -56,12 +56,24 @@ int main()
STATIC_ASSERT_SAME(boost::pointee<X*>::type, X);
STATIC_ASSERT_SAME(boost::pointee<X const*>::type, X const);
#if defined(BOOST_NO_CXX11_SMART_PTR)
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<int const> >::type, int const);
STATIC_ASSERT_SAME(boost::pointee<std::auto_ptr<X const> >::type, X const);
#else
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<int const> >::type, int const);
STATIC_ASSERT_SAME(boost::pointee<std::unique_ptr<X const> >::type, X const);
#endif
STATIC_ASSERT_SAME(boost::pointee<std::list<int>::iterator >::type, int);
STATIC_ASSERT_SAME(boost::pointee<std::list<X>::iterator >::type, X);

View File

@ -0,0 +1,64 @@
// Copyright 2003 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Shared container iterator adaptor
// Author: Ronald Garcia
// See http://boost.org/libs/utility/shared_container_iterator.html
// for documentation.
//
// shared_iterator_test.cpp - Regression tests for shared_container_iterator.
//
#include "boost/shared_container_iterator.hpp"
#include "boost/shared_ptr.hpp"
#include <boost/core/lightweight_test.hpp>
#include <vector>
struct resource {
static int count;
resource() { ++count; }
resource(resource const&) { ++count; }
~resource() { --count; }
};
int resource::count = 0;
typedef std::vector<resource> resources_t;
typedef boost::shared_container_iterator< resources_t > iterator;
void set_range(iterator& i, iterator& end) {
boost::shared_ptr< resources_t > objs(new resources_t());
for (int j = 0; j != 6; ++j)
objs->push_back(resource());
i = iterator(objs->begin(),objs);
end = iterator(objs->end(),objs);
BOOST_TEST_EQ(resource::count, 6);
}
int main() {
BOOST_TEST_EQ(resource::count, 0);
{
iterator i;
{
iterator end;
set_range(i,end);
BOOST_TEST_EQ(resource::count, 6);
}
BOOST_TEST_EQ(resource::count, 6);
}
BOOST_TEST_EQ(resource::count, 0);
return boost::report_errors();
}

View File

@ -1,6 +1,6 @@
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_HDR_TUPLE)
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <tuple>
#include <boost/fusion/adapted/std_tuple.hpp>

View File

@ -6,6 +6,22 @@
//
// See http://www.boost.org for most recent version including documentation.
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <boost/config/pragma_message.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, < 1600)
BOOST_PRAGMA_MESSAGE("Skipping test on msvc-9.0 and below")
int main() {}
#elif defined(BOOST_GCC) && __cplusplus < 201100
BOOST_PRAGMA_MESSAGE("Skipping test on g++ in C++03 mode")
int main() {}
#else
#include <utility>
#include <boost/fusion/adapted/std_pair.hpp>
@ -14,3 +30,4 @@
#include "detail/zip_iterator_test.ipp"
#endif