├── .gitattributes ├── .github └── workflows │ └── ci.yml ├── CMakeLists.txt ├── README.md ├── appveyor.yml ├── build.jam ├── doc ├── BidirectionalTraversal.html ├── BidirectionalTraversal.rst ├── ForwardTraversal.html ├── ForwardTraversal.rst ├── GNUmakefile ├── IncrementableIterator.html ├── IncrementableIterator.rst ├── InteroperableIterator.rst ├── Jamfile.v2 ├── LvalueIterator.html ├── LvalueIterator.rst ├── RandomAccessTraversal.html ├── RandomAccessTraversal.rst ├── ReadableIterator.html ├── ReadableIterator.rst ├── SinglePassIterator.html ├── SinglePassIterator.rst ├── SwappableIterator.html ├── SwappableIterator.rst ├── WritableIterator.html ├── WritableIterator.rst ├── access.png ├── access2old.png ├── advance.rst ├── counting_iterator.html ├── counting_iterator.pdf ├── counting_iterator.rst ├── counting_iterator_abstract.rst ├── counting_iterator_eg.rst ├── counting_iterator_ref.rst ├── default.css ├── distance.rst ├── docutils.sty ├── facade-and-adaptor.html ├── facade-and-adaptor.pdf ├── facade-and-adaptor.rst ├── facade_iterator_category.rst ├── filter_iterator.html ├── filter_iterator.pdf ├── filter_iterator.rst ├── filter_iterator_abstract.rst ├── filter_iterator_eg.rst ├── filter_iterator_ref.rst ├── func_output_iter_abstract.rst ├── func_output_iter_ref.rst ├── function_input_iterator.html ├── function_input_iterator.rst ├── function_output_iterator.html ├── function_output_iterator.pdf ├── function_output_iterator.rst ├── function_output_iterator_eg.rst ├── generate.py ├── generator_iterator.htm ├── index.html ├── index.rst ├── indirect_iterator.html ├── indirect_iterator.pdf ├── indirect_iterator.rst ├── indirect_iterator_abstract.rst ├── indirect_iterator_eg.rst ├── indirect_iterator_ref.rst ├── indirect_reference_ref.rst ├── interoperability-revisited.rst ├── issues.rst ├── iterator_adaptor.html ├── iterator_adaptor.pdf ├── iterator_adaptor.rst ├── iterator_adaptor_abstract.rst ├── iterator_adaptor_body.rst ├── iterator_adaptor_ref.rst ├── iterator_adaptor_tutorial.rst ├── iterator_archetypes.html ├── iterator_archetypes.pdf ├── iterator_archetypes.rst ├── iterator_concepts.html ├── iterator_concepts.pdf ├── iterator_concepts.rst ├── iterator_facade.html ├── iterator_facade.pdf ├── iterator_facade.rst ├── iterator_facade_abstract.rst ├── iterator_facade_body.rst ├── iterator_facade_ref.rst ├── iterator_facade_tutorial.rst ├── iterator_traits.html ├── iterator_traits.pdf ├── iterator_traits.rst ├── make_counting_iterator.rst ├── make_filter_iterator.rst ├── make_reverse_iterator.rst ├── make_transform_iterator.rst ├── make_zip_iterator.rst ├── new-iter-concepts.html ├── new-iter-concepts.pdf ├── new-iter-concepts.rst ├── oldeqnew.png ├── permutation_iter_abstract.rst ├── permutation_iterator.html ├── permutation_iterator.pdf ├── permutation_iterator.rst ├── permutation_iterator_body.rst ├── permutation_iterator_eg.rst ├── permutation_iterator_ref.rst ├── pointee.html ├── pointee.pdf ├── pointee.rst ├── pointee_ref.rst ├── quickbook │ ├── adaptor.qbk │ ├── algorithms.qbk │ ├── archetypes.qbk │ ├── concept_checking.qbk │ ├── concepts.qbk │ ├── counting_iterator.qbk │ ├── facade.qbk │ ├── facade_tutorial.qbk │ ├── filter_iterator.qbk │ ├── function_output_iterator.qbk │ ├── indirect_iterator.qbk │ ├── iterator.qbk │ ├── iterator_traits.qbk │ ├── permutation_iterator.qbk │ ├── reverse_iterator.qbk │ ├── shared_container_iterator.qbk │ ├── specialized_adaptors.qbk │ ├── transform_iterator.qbk │ ├── type_traits.qbk │ └── zip_iterator.qbk ├── ref_problem.rst ├── reverse_iterator.html ├── reverse_iterator.pdf ├── reverse_iterator.rst ├── reverse_iterator_abstract.rst ├── reverse_iterator_eg.rst ├── reverse_iterator_ref.rst ├── rst2html.sh ├── rst2latex.sh ├── scanrst.py ├── sources.py ├── syscmd.py ├── transform_iterator.html ├── transform_iterator.pdf ├── transform_iterator.rst ├── transform_iterator_abstract.rst ├── transform_iterator_eg.rst ├── transform_iterator_ref.rst ├── traversal.png ├── zip_iterator.html ├── zip_iterator.pdf ├── zip_iterator.rst ├── zip_iterator_abstract.rst ├── zip_iterator_eg.rst └── zip_iterator_ref.rst ├── example ├── counting_iterator_example.cpp ├── filter_iterator_example.cpp ├── func_output_iter_example.cpp ├── indirect_iterator_example.cpp ├── node.hpp ├── node_iterator1.cpp ├── node_iterator1.hpp ├── node_iterator2.cpp ├── node_iterator2.hpp ├── node_iterator3.cpp ├── node_iterator3.hpp ├── permutation_iter_example.cpp ├── reverse_iterator.cpp ├── reverse_iterator_example.cpp ├── shared_iterator_example1.cpp ├── shared_iterator_example2.cpp ├── shared_iterator_example3.cpp └── transform_iterator_example.cpp ├── include └── boost │ ├── function_output_iterator.hpp │ ├── generator_iterator.hpp │ ├── indirect_reference.hpp │ ├── iterator │ ├── advance.hpp │ ├── counting_iterator.hpp │ ├── detail │ │ ├── config_def.hpp │ │ ├── config_undef.hpp │ │ ├── eval_if_default.hpp │ │ ├── facade_iterator_category.hpp │ │ ├── if_default.hpp │ │ └── type_traits │ │ │ ├── conjunction.hpp │ │ │ ├── disjunction.hpp │ │ │ ├── negation.hpp │ │ │ └── type_identity.hpp │ ├── distance.hpp │ ├── enable_if_convertible.hpp │ ├── filter_iterator.hpp │ ├── function_input_iterator.hpp │ ├── function_output_iterator.hpp │ ├── generator_iterator.hpp │ ├── indirect_iterator.hpp │ ├── interoperable.hpp │ ├── is_iterator.hpp │ ├── is_lvalue_iterator.hpp │ ├── is_readable_iterator.hpp │ ├── iterator_adaptor.hpp │ ├── iterator_archetypes.hpp │ ├── iterator_categories.hpp │ ├── iterator_concepts.hpp │ ├── iterator_facade.hpp │ ├── iterator_traits.hpp │ ├── min_category.hpp │ ├── minimum_category.hpp │ ├── new_iterator_tests.hpp │ ├── permutation_iterator.hpp │ ├── reverse_iterator.hpp │ ├── shared_container_iterator.hpp │ ├── transform_iterator.hpp │ └── zip_iterator.hpp │ ├── iterator_adaptors.hpp │ ├── next_prior.hpp │ ├── pending │ ├── detail │ │ └── int_iterator.hpp │ ├── iterator_adaptors.hpp │ └── iterator_tests.hpp │ ├── pointee.hpp │ └── shared_container_iterator.hpp ├── index.html ├── meta └── libraries.json └── test ├── Jamfile.v2 ├── adl_test.cpp ├── advance_test.cpp ├── concept_tests.cpp ├── constant_iter_arrow.cpp ├── constant_iter_arrow_fail.cpp ├── counting_iterator_test.cpp ├── detail ├── zip_iterator_test.ipp └── zip_iterator_test_original.ipp ├── distance_test.cpp ├── filter_iterator_test.cpp ├── function_input_iterator_test.cpp ├── function_output_iterator_cf.cpp ├── function_output_iterator_def_ctor_cf.cpp ├── function_output_iterator_test.cpp ├── generator_iterator_test.cpp ├── indirect_iter_member_types.cpp ├── indirect_iterator_test.cpp ├── interoperable.cpp ├── interoperable_fail.cpp ├── is_convertible_fail.cpp ├── is_iterator.cpp ├── is_lvalue_iterator.cpp ├── is_readable_iterator.cpp ├── iter_archetype_default_ctor.cpp ├── iterator_adaptor_cc.cpp ├── iterator_adaptor_test.cpp ├── iterator_archetype_cc.cpp ├── iterator_facade.cpp ├── iterator_traits_test.cpp ├── lvalue_concept_fail.cpp ├── min_category.cpp ├── min_category_compile_fail1.cpp ├── min_category_compile_fail2.cpp ├── minimum_category.cpp ├── minimum_category_compile_fail.cpp ├── next_prior_test.cpp ├── permutation_iterator_test.cpp ├── pointee.cpp ├── range_distance_compat_test.cpp ├── reverse_iterator_test.cpp ├── shared_iterator_test.cpp ├── static_assert_same.hpp ├── test_cmake ├── CMakeLists.txt └── main.cpp ├── transform_iterator_test.cpp ├── unit_tests.cpp ├── zip_iterator_test.cpp ├── zip_iterator_test2_fusion_deque.cpp ├── zip_iterator_test2_fusion_list.cpp ├── zip_iterator_test2_fusion_vector.cpp ├── zip_iterator_test2_std_tuple.cpp ├── zip_iterator_test_fusion.cpp ├── zip_iterator_test_std_pair.cpp └── zip_iterator_test_std_tuple.cpp /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Peter Dimov 2 | # Copyright 2018 Andrey Semashev 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt 5 | 6 | cmake_minimum_required(VERSION 3.5...3.20) 7 | 8 | project(boost_iterator VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) 9 | 10 | add_library(boost_iterator INTERFACE) 11 | add_library(Boost::iterator ALIAS boost_iterator) 12 | 13 | target_include_directories(boost_iterator INTERFACE include) 14 | 15 | target_link_libraries(boost_iterator 16 | INTERFACE 17 | Boost::assert 18 | Boost::concept_check 19 | Boost::config 20 | Boost::core 21 | Boost::detail 22 | Boost::fusion 23 | Boost::mpl 24 | Boost::optional 25 | Boost::type_traits 26 | Boost::utility 27 | ) 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Boost.Iterator 2 | 3 | Boost.Iterator, part of collection of the [Boost C++ Libraries](https://github.com/boostorg), provides tools for building and working with iterators in C++. The library also provides a number of iterator classes that can be used out of the box. 4 | 5 | ### Directories 6 | 7 | * **doc** - Documentation sources 8 | * **include** - Interface headers of Boost.Iterator 9 | * **test** - Boost.Iterator unit tests 10 | * **example** - Boost.Iterator usage examples 11 | 12 | ### More information 13 | 14 | * [Documentation](https://boost.org/libs/iterator) 15 | * [Report bugs](https://github.com/boostorg/iterator/issues/new). Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well. 16 | * Submit your patches as [pull requests](https://github.com/boostorg/iterator/compare) against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt). 17 | 18 | ### Build status 19 | 20 | Branch | GitHub Actions | AppVeyor | Test Matrix | Dependencies | 21 | :-------------: | -------------- | -------- | ----------- | ------------ | 22 | [`master`](https://github.com/boostorg/iterator/tree/master) | [![GitHub Actions](https://github.com/boostorg/iterator/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/iterator/actions?query=branch%3Amaster) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/ud8ug5aai8vd30hg/branch/master?svg=true)](https://ci.appveyor.com/project/Lastique/iterator/branch/master) | [![Tests](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/iterator.html) | [![Dependencies](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/iterator.html) 23 | [`develop`](https://github.com/boostorg/iterator/tree/develop) | [![GitHub Actions](https://github.com/boostorg/iterator/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/iterator/actions?query=branch%3Adevelop) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/ud8ug5aai8vd30hg/branch/develop?svg=true)](https://ci.appveyor.com/project/Lastique/iterator/branch/develop) | [![Tests](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/iterator.html) | [![Dependencies](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/iterator.html) 24 | 25 | ### License 26 | 27 | Distributed under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt). 28 | -------------------------------------------------------------------------------- /build.jam: -------------------------------------------------------------------------------- 1 | # Copyright René Ferdinand Rivera Morell 2023-2024 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE_1_0.txt or copy at 4 | # http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | require-b2 5.2 ; 7 | 8 | constant boost_dependencies : 9 | /boost/assert//boost_assert 10 | /boost/concept_check//boost_concept_check 11 | /boost/config//boost_config 12 | /boost/core//boost_core 13 | /boost/detail//boost_detail 14 | /boost/fusion//boost_fusion 15 | /boost/mpl//boost_mpl 16 | /boost/optional//boost_optional 17 | /boost/type_traits//boost_type_traits 18 | /boost/utility//boost_utility ; 19 | 20 | project /boost/iterator 21 | : common-requirements 22 | include 23 | ; 24 | 25 | explicit 26 | [ alias boost_iterator : : : : $(boost_dependencies) ] 27 | [ alias all : boost_iterator test ] 28 | ; 29 | 30 | call-if : boost-library iterator 31 | ; 32 | 33 | -------------------------------------------------------------------------------- /doc/ForwardTraversal.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | Forward Traversal Concept 6 | ......................... 7 | 8 | A class or built-in type ``X`` models the *Forward Traversal* 9 | concept if, in addition to ``X`` meeting the requirements of Default 10 | Constructible and Single Pass Iterator, the following expressions are 11 | valid and respect the stated semantics. 12 | 13 | +--------------------------------------------------------------------------------------------------------+ 14 | |Forward Traversal Iterator Requirements (in addition to Default Constructible and Single Pass Iterator) | 15 | +---------------------------------------+-----------------------------------+----------------------------+ 16 | |Expression |Return Type |Assertion/Note | 17 | +=======================================+===================================+============================+ 18 | |``X u;`` |``X&`` |note: ``u`` may have a | 19 | | | |singular value. | 20 | +---------------------------------------+-----------------------------------+----------------------------+ 21 | |``++r`` |``X&`` |``r == s`` and ``r`` is | 22 | | | |dereferenceable implies | 23 | | | |``++r == ++s.`` | 24 | +---------------------------------------+-----------------------------------+----------------------------+ 25 | |``iterator_traits::difference_type``|A signed integral type representing| | 26 | | |the distance between iterators | | 27 | | | | | 28 | +---------------------------------------+-----------------------------------+----------------------------+ 29 | |``iterator_traversal::type`` |Convertible to | | 30 | | |``forward_traversal_tag`` | | 31 | +---------------------------------------+-----------------------------------+----------------------------+ 32 | -------------------------------------------------------------------------------- /doc/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright David Abrahams 2004. Distributed under the Boost 2 | # Software License, Version 1.0. (See accompanying 3 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | ECHO = /bin/echo 6 | 7 | all: 8 | @${ECHO} "/libs/iterator/doc/GNUmakefile should be replaced by" 9 | @${ECHO} 10 | @${ECHO} " http://www.boost-consulting.com/writing/GNUmakefile," 11 | @${ECHO} 12 | @${ECHO} "before proceeding. That file is not included in the Boost" 13 | @${ECHO} "distribution because it is licensed under the GPL, which violates" 14 | @${ECHO} "Boost license requirements." 15 | 16 | -------------------------------------------------------------------------------- /doc/IncrementableIterator.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | Incrementable Iterator Concept 6 | .............................. 7 | 8 | A class or built-in type ``X`` models the *Incrementable Iterator* 9 | concept if, in addition to ``X`` being Assignable and Copy 10 | Constructible, the following expressions are valid and respect the 11 | stated semantics. 12 | 13 | 14 | +-------------------------------------------------------------------------------------+ 15 | |Incrementable Iterator Requirements (in addition to Assignable, Copy Constructible) | 16 | | | 17 | +--------------------------------+-------------------------------+--------------------+ 18 | |Expression |Return Type |Assertion/Semantics | 19 | +================================+===============================+====================+ 20 | |``++r`` |``X&`` |``&r == &++r`` | 21 | +--------------------------------+-------------------------------+--------------------+ 22 | |``r++`` |``X`` |:: | 23 | | | | | 24 | | | | { | 25 | | | | X tmp = r; | 26 | | | | ++r; | 27 | | | | return tmp; | 28 | | | | } | 29 | +--------------------------------+-------------------------------+--------------------+ 30 | |``iterator_traversal::type`` |Convertible to | | 31 | | |``incrementable_traversal_tag``| | 32 | +--------------------------------+-------------------------------+--------------------+ 33 | -------------------------------------------------------------------------------- /doc/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # Copyright Thomas Witt 2005. Use, modification, and distribution are 2 | # subject to the Boost Software License, Version 1.0. (See accompanying 3 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | using quickbook ; 6 | 7 | xml iterator 8 | : 9 | quickbook/iterator.qbk 10 | ; 11 | 12 | boostbook standalone 13 | : 14 | iterator 15 | : 16 | "boost.root=../../../.." 17 | toc.max.depth=3 18 | toc.section.depth=3 19 | chunk.section.depth=2 20 | pdf:"boost.url.prefix=http://www.boost.org/doc/libs/release/libs/iterator/doc/html" 21 | ; 22 | 23 | ############################################################################### 24 | alias boostdoc ; 25 | explicit boostdoc ; 26 | alias boostrelease : standalone ; 27 | explicit boostrelease ; 28 | -------------------------------------------------------------------------------- /doc/LvalueIterator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Lvalue Iterator Concept 8 | 9 | 10 | 11 |
12 |

Lvalue Iterator Concept

13 | 14 | 15 | 16 | 17 |

The Lvalue Iterator concept adds the requirement that the return 18 | type of operator* type be a reference to the value type of the 19 | iterator.

20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 45 | 46 | 47 |
Lvalue Iterator Requirements
ExpressionReturn TypeNote/Assertion
*aT&T is cv 38 | iterator_traits<X>::value_type 39 | where cv is an optional 40 | cv-qualification. 41 | pre: a is 42 | dereferenceable. If a 43 | == b then *a is 44 | equivalent to *b.
48 |
49 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /doc/LvalueIterator.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | Lvalue Iterator Concept 6 | ....................... 7 | 8 | The *Lvalue Iterator* concept adds the requirement that the return 9 | type of ``operator*`` type be a reference to the value type of the 10 | iterator. 11 | 12 | +-------------------------------------------------------------+ 13 | | Lvalue Iterator Requirements | 14 | +-------------+-----------+-----------------------------------+ 15 | |Expression |Return Type|Note/Assertion | 16 | +=============+===========+===================================+ 17 | |``*a`` | ``T&`` |``T`` is *cv* | 18 | | | |``iterator_traits::value_type`` | 19 | | | |where *cv* is an optional | 20 | | | |cv-qualification. | 21 | | | |pre: ``a`` is | 22 | | | |dereferenceable. If ``a | 23 | | | |== b`` then ``*a`` is | 24 | | | |equivalent to ``*b``. | 25 | +-------------+-----------+-----------------------------------+ 26 | -------------------------------------------------------------------------------- /doc/ReadableIterator.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | Readable Iterator Concept 6 | ......................... 7 | 8 | A class or built-in type ``X`` models the *Readable Iterator* concept 9 | for value type ``T`` if, in addition to ``X`` being Assignable and 10 | Copy Constructible, the following expressions are valid and respect 11 | the stated semantics. ``U`` is the type of any specified member of 12 | type ``T``. 13 | 14 | +-----------------------------------------------------------------------------------------------------------------------------+ 15 | |Readable Iterator Requirements (in addition to Assignable and Copy Constructible) | 16 | +-----------------------------------+------------------------+----------------------------------------------------------------+ 17 | |Expression |Return Type |Note/Precondition | 18 | +===================================+========================+================================================================+ 19 | |``iterator_traits::value_type`` |``T`` |Any non-reference, | 20 | | | |non-cv-qualified type | 21 | +-----------------------------------+------------------------+----------------------------------------------------------------+ 22 | |``*a`` | Convertible to ``T`` |pre: ``a`` is dereferenceable. If ``a == b`` then ``*a`` | 23 | | | | is equivalent to ``*b``. | 24 | +-----------------------------------+------------------------+----------------------------------------------------------------+ 25 | |``a->m`` |``U&`` |pre: ``pre: (*a).m`` is well-defined. Equivalent to ``(*a).m``. | 26 | +-----------------------------------+------------------------+----------------------------------------------------------------+ 27 | -------------------------------------------------------------------------------- /doc/SinglePassIterator.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | Single Pass Iterator Concept 6 | ............................ 7 | 8 | A class or built-in type ``X`` models the *Single Pass Iterator* 9 | concept if the following expressions are valid and respect the stated 10 | semantics. 11 | 12 | 13 | +------------------------------------------------------------------------------------------+ 14 | |Single Pass Iterator Requirements (in addition to Incrementable Iterator and Equality | 15 | |Comparable) | 16 | +--------------------------------+-----------------------------+---------------------------+ 17 | |Expression |Return Type |Assertion/Semantics / | 18 | | | |Pre-/Post-condition | 19 | +================================+=============================+===========================+ 20 | |``++r`` |``X&`` |pre: ``r`` is | 21 | | | |dereferenceable; post: | 22 | | | |``r`` is dereferenceable or| 23 | | | |``r`` is past-the-end | 24 | +--------------------------------+-----------------------------+---------------------------+ 25 | |``a == b`` |convertible to ``bool`` |``==`` is an equivalence | 26 | | | |relation over its domain | 27 | +--------------------------------+-----------------------------+---------------------------+ 28 | |``a != b`` |convertible to ``bool`` |``!(a == b)`` | 29 | +--------------------------------+-----------------------------+---------------------------+ 30 | |``iterator_traversal::type`` |Convertible to | | 31 | | |``single_pass_traversal_tag``| | 32 | +--------------------------------+-----------------------------+---------------------------+ 33 | -------------------------------------------------------------------------------- /doc/SwappableIterator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Swappable Iterator Concept 8 | 9 | 10 | 11 |
12 |

Swappable Iterator Concept

13 | 14 | 15 | 16 | 17 |

A class or built-in type X models the Swappable Iterator concept 18 | if, in addition to X being Copy Constructible, the following 19 | expressions are valid and respect the stated semantics.

20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 39 | 40 | 41 |
Swappable Iterator Requirements (in addition to Copy Constructible)
ExpressionReturn TypePostcondition
iter_swap(a, b)voidthe pointed to values are 38 | exchanged
42 |
43 |
[Note: An iterator that is a model of the Readable and Writable Iterator concepts
44 |
is also a model of Swappable Iterator. --end note]
45 |
46 |
47 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /doc/SwappableIterator.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | Swappable Iterator Concept 6 | .......................... 7 | 8 | A class or built-in type ``X`` models the *Swappable Iterator* concept 9 | if, in addition to ``X`` being Copy Constructible, the following 10 | expressions are valid and respect the stated semantics. 11 | 12 | +---------------------------------------------------------------------+ 13 | |Swappable Iterator Requirements (in addition to Copy Constructible) | 14 | +-------------------------+-------------+-----------------------------+ 15 | |Expression |Return Type |Postcondition | 16 | +=========================+=============+=============================+ 17 | |``iter_swap(a, b)`` |``void`` |the pointed to values are | 18 | | | |exchanged | 19 | +-------------------------+-------------+-----------------------------+ 20 | 21 | [*Note:* An iterator that is a model of the *Readable* and *Writable Iterator* concepts 22 | is also a model of *Swappable Iterator*. *--end note*] 23 | 24 | -------------------------------------------------------------------------------- /doc/WritableIterator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Writable Iterator Concept 8 | 9 | 10 | 11 |
12 |

Writable Iterator Concept

13 | 14 | 15 | 16 | 17 |

A class or built-in type X models the Writable Iterator concept 18 | if, in addition to X being Copy Constructible, the following 19 | expressions are valid and respect the stated semantics. Writable 20 | Iterators have an associated set of value types.

21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 41 | 42 | 43 |
Writable Iterator Requirements (in addition to Copy Constructible)
ExpressionReturn TypePrecondition
*a = o pre: The type of o 39 | is in the set of 40 | value types of X
44 |
45 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /doc/WritableIterator.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | Writable Iterator Concept 6 | ......................... 7 | 8 | A class or built-in type ``X`` models the *Writable Iterator* concept 9 | if, in addition to ``X`` being Copy Constructible, the following 10 | expressions are valid and respect the stated semantics. Writable 11 | Iterators have an associated *set of value types*. 12 | 13 | +---------------------------------------------------------------------+ 14 | |Writable Iterator Requirements (in addition to Copy Constructible) | 15 | +-------------------------+--------------+----------------------------+ 16 | |Expression |Return Type |Precondition | 17 | +=========================+==============+============================+ 18 | |``*a = o`` | | pre: The type of ``o`` | 19 | | | | is in the set of | 20 | | | | value types of ``X`` | 21 | +-------------------------+--------------+----------------------------+ 22 | -------------------------------------------------------------------------------- /doc/access.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/access.png -------------------------------------------------------------------------------- /doc/access2old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/access2old.png -------------------------------------------------------------------------------- /doc/advance.rst: -------------------------------------------------------------------------------- 1 | .. Copyright (C) 2017 Michel Morin. 2 | Distributed under the Boost Software License, Version 1.0. 3 | (See accompanying file LICENSE_1_0.txt or copy at 4 | http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | ======= 7 | advance 8 | ======= 9 | 10 | ``boost::iterators::advance`` is an adapted version of ``std::advance`` for 11 | the Boost iterator traversal concepts. 12 | 13 | 14 | Header 15 | ------ 16 | 17 | ```` 18 | 19 | 20 | Synopsis 21 | -------- 22 | 23 | :: 24 | 25 | template 26 | constexpr void advance(Iterator& it, Distance n); 27 | 28 | 29 | Description 30 | ----------- 31 | 32 | Moves ``it`` forward by ``n`` increments 33 | (or backward by ``|n|`` decrements if ``n`` is negative). 34 | 35 | 36 | Requirements 37 | ------------ 38 | 39 | ``Iterator`` should model Incrementable Iterator. 40 | 41 | 42 | Preconditions 43 | ------------- 44 | 45 | Let ``it``\ :sub:`i` be the iterator obtained by incrementing 46 | (or decrementing if ``n`` is negative) ``it`` by *i*. All the iterators 47 | ``it``\ :sub:`i` for *i* = 0, 1, 2, ..., ``|n|`` should be valid. 48 | 49 | If ``Iterator`` does not model Bidirectional Traversal Iterator, 50 | ``n`` should be non-negative. 51 | 52 | 53 | Complexity 54 | ---------- 55 | 56 | If ``Iterator`` models Random Access Traversal Iterator, it takes constant time; 57 | otherwise it takes linear time. 58 | 59 | 60 | Notes 61 | ----- 62 | 63 | - This function is not a customization point and is protected against 64 | being found by argument-dependent lookup (ADL). 65 | - This function is ``constexpr`` only in C++14 or later. 66 | 67 | 68 | -------------------------------------------------------------------------------- 69 | 70 | | Author: Michel Morin 71 | | Copyright |C| 2017 Michel Morin 72 | | Distributed under the `Boost Software License, Version 1.0 73 | `_. 74 | 75 | .. |C| unicode:: U+00A9 .. COPYRIGHT SIGN 76 | -------------------------------------------------------------------------------- /doc/counting_iterator.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/counting_iterator.pdf -------------------------------------------------------------------------------- /doc/counting_iterator.rst: -------------------------------------------------------------------------------- 1 | .. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | +++++++++++++++++++ 6 | Counting Iterator 7 | +++++++++++++++++++ 8 | 9 | :Author: David Abrahams, Jeremy Siek, Thomas Witt 10 | :Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de 11 | :organization: `Boost Consulting`_, Indiana University `Open Systems 12 | Lab`_, University of Hanover `Institute for Transport 13 | Railway Operation and Construction`_ 14 | :copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. 15 | 16 | .. _`Boost Consulting`: http://www.boost-consulting.com 17 | .. _`Open Systems Lab`: http://www.osl.iu.edu 18 | .. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de 19 | 20 | :abstract: How would you fill up a vector with the numbers zero 21 | through one hundred using ``std::copy()``? The only iterator 22 | operation missing from builtin integer types is an 23 | ``operator*()`` that returns the current value of the integer. 24 | The counting iterator adaptor adds this crucial piece of 25 | functionality to whatever type it wraps. One can use the 26 | counting iterator adaptor not only with integer types, but with 27 | any incrementable type. 28 | 29 | .. include:: counting_iterator_abstract.rst 30 | 31 | .. contents:: Table of Contents 32 | 33 | ``counting_iterator`` synopsis 34 | .............................. 35 | 36 | .. include:: counting_iterator_ref.rst 37 | .. include:: make_counting_iterator.rst 38 | 39 | .. include:: counting_iterator_eg.rst 40 | 41 | .. _iterator-category: iterator_facade.html#iterator-category 42 | .. |iterator-category| replace:: *iterator-category* 43 | -------------------------------------------------------------------------------- /doc/counting_iterator_abstract.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | ``counting_iterator`` adapts an object by adding an ``operator*`` that 6 | returns the current value of the object. All other iterator operations 7 | are forwarded to the adapted object. 8 | 9 | -------------------------------------------------------------------------------- /doc/counting_iterator_eg.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | Example 6 | ....... 7 | 8 | This example fills an array with numbers and a second array with 9 | pointers into the first array, using ``counting_iterator`` for both 10 | tasks. Finally ``indirect_iterator`` is used to print out the numbers 11 | into the first array via indirection through the second array. 12 | 13 | :: 14 | 15 | int N = 7; 16 | std::vector numbers; 17 | typedef std::vector::iterator n_iter; 18 | std::copy(boost::counting_iterator(0), 19 | boost::counting_iterator(N), 20 | std::back_inserter(numbers)); 21 | 22 | std::vector::iterator> pointers; 23 | std::copy(boost::make_counting_iterator(numbers.begin()), 24 | boost::make_counting_iterator(numbers.end()), 25 | std::back_inserter(pointers)); 26 | 27 | std::cout << "indirectly printing out the numbers from 0 to " 28 | << N << std::endl; 29 | std::copy(boost::make_indirect_iterator(pointers.begin()), 30 | boost::make_indirect_iterator(pointers.end()), 31 | std::ostream_iterator(std::cout, " ")); 32 | std::cout << std::endl; 33 | 34 | 35 | The output is:: 36 | 37 | indirectly printing out the numbers from 0 to 7 38 | 0 1 2 3 4 5 6 39 | 40 | The source code for this example can be found `here`__. 41 | 42 | __ ../example/counting_iterator_example.cpp 43 | 44 | -------------------------------------------------------------------------------- /doc/distance.rst: -------------------------------------------------------------------------------- 1 | .. Copyright (C) 2017 Michel Morin. 2 | Distributed under the Boost Software License, Version 1.0. 3 | (See accompanying file LICENSE_1_0.txt or copy at 4 | http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | ======== 7 | distance 8 | ======== 9 | 10 | ``boost::iterators::distance`` is an adapted version of ``std::distance`` for 11 | the Boost iterator traversal concepts. 12 | 13 | 14 | Header 15 | ------ 16 | 17 | ```` 18 | 19 | 20 | Synopsis 21 | -------- 22 | 23 | :: 24 | 25 | template 26 | constexpr typename iterator_difference::type 27 | distance(Iterator first, Iterator last); 28 | 29 | 30 | Description 31 | ----------- 32 | 33 | Computes the (signed) distance from ``first`` to ``last``. 34 | 35 | 36 | Requirements 37 | ------------ 38 | 39 | ``Iterator`` should model Single Pass Iterator. 40 | 41 | 42 | Preconditions 43 | ------------- 44 | 45 | If ``Iterator`` models Random Access Traversal Iterator, 46 | ``[first, last)`` or ``[last, first)`` should be valid; 47 | otherwise ``[first, last)`` should be valid. 48 | 49 | 50 | Complexity 51 | ---------- 52 | 53 | If ``Iterator`` models Random Access Traversal Iterator, it takes constant time; 54 | otherwise it takes linear time. 55 | 56 | 57 | Notes 58 | ----- 59 | 60 | - This function is not a customization point and is protected against 61 | being found by argument-dependent lookup (ADL). 62 | - This function is ``constexpr`` only in C++14 or later. 63 | 64 | 65 | -------------------------------------------------------------------------------- 66 | 67 | | Author: Michel Morin 68 | | Copyright |C| 2017 Michel Morin 69 | | Distributed under the `Boost Software License, Version 1.0 70 | `_. 71 | 72 | .. |C| unicode:: U+00A9 .. COPYRIGHT SIGN 73 | -------------------------------------------------------------------------------- /doc/docutils.sty: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | %%%%%%%%%%%%%% docutils.sty: A style for docutils latex output %%%%%%%%%%%%%%% 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | %% 5 | %% o author: Alexander Schmolck (a.schmolck@gmx.net) 6 | %% o created: 2002-07-07 10:50:31+00:40 7 | %% o keywords: 8 | %% o license: 9 | %XXX titlesec 10 | %% XXX geometry 11 | \usepackage{graphicx} 12 | \usepackage{latexsym} % extra symbols 13 | \usepackage{url} % !!!: pay attention when using in other commands!!! 14 | \usepackage{verbatim} % normal verbatim has lenght-limit 15 | \usepackage{enumerate} % easy style choice with e.g: ``\begin{enumerate}[Ex i.]`` 16 | \usepackage{hyperref} %href, htarget and hlink XXX: pdfauthor, pdfcreator etc. 17 | \usepackage{xr} %XXX do we need this? 18 | % need this to have ``fboxes`` in ``enviroments``, as well as ``verbatim``s 19 | \usepackage{fancybox} 20 | \usepackage{mdwtab} % better tables and arrays (fixes spacing and adds 21 | % vertical align and multirows (m)) 22 | \usepackage{ltxtable} % long and autoscaling tables (use X for autoscaled 23 | % columns) 24 | \newcommand{\transition}{\vspace{2em}\par\hrule{}\par\vspace{2em}} 25 | \newcommand{\classifier}[1]{(\textit{#1})} 26 | \newenvironment{topic}[1]% 27 | {\begin{Sbox}% 28 | \begin{minipage}{.8\textwidth}% 29 | \protect{\large{\textbf{#1}}}\par\vspace{.5em}}% 30 | {\end{minipage}\end{Sbox}\fbox{\TheSbox}\par\vspace{.5em}} 31 | %XXX shadow box for warnings? 32 | \newenvironment{admonition}[1]% 33 | {\begin{center}% 34 | \begin{Sbox}% 35 | \begin{minipage}{.9\textwidth}% 36 | \protect{\textsc{#1}}\par\vspace{.2em}}% 37 | {\end{minipage}\end{Sbox}\fbox{\TheSbox}\par\vspace{.5em}\end{center}} 38 | 39 | \newenvironment{doctest}% 40 | {\VerbatimEnvironment 41 | \begin{Verbatim}}% 42 | {\end{Verbatim}} 43 | % {% 44 | % \begin{Sbox}% 45 | % \begin{minipage}{.8\textwidth}% 46 | % \protect{\large{\textsc{#1}}\par\vspace{.5em}}}% 47 | % {\end{minipage}\end{Sbox}\fbox{\TheSbox}\par\vspace{.5em}} 48 | %{\end{minipage}\end{Sbox}\fbox{\TheSbox}} 49 | 50 | 51 | %% just a piece of example code 52 | % \newcommand{\vitem}% 53 | % {\SaveVerb[{\item[\UseVerb{\MyTemp}]}]{\MyTemp}} 54 | -------------------------------------------------------------------------------- /doc/facade-and-adaptor.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/facade-and-adaptor.pdf -------------------------------------------------------------------------------- /doc/facade_iterator_category.rst: -------------------------------------------------------------------------------- 1 | .. |iterator-category| replace:: *iterator-category* 2 | .. _iterator-category: 3 | 4 | .. parsed-literal:: 5 | 6 | *iterator-category*\ (C,R,V) := 7 | if (C is convertible to std::input_iterator_tag 8 | || C is convertible to std::output_iterator_tag 9 | ) 10 | return C 11 | 12 | else if (C is not convertible to incrementable_traversal_tag) 13 | *the program is ill-formed* 14 | 15 | else return a type X satisfying the following two constraints: 16 | 17 | 1. X is convertible to X1, and not to any more-derived 18 | type, where X1 is defined by: 19 | 20 | if (R is a reference type 21 | && C is convertible to forward_traversal_tag) 22 | { 23 | if (C is convertible to random_access_traversal_tag) 24 | X1 = random_access_iterator_tag 25 | else if (C is convertible to bidirectional_traversal_tag) 26 | X1 = bidirectional_iterator_tag 27 | else 28 | X1 = forward_iterator_tag 29 | } 30 | else 31 | { 32 | if (C is convertible to single_pass_traversal_tag 33 | && R is convertible to V) 34 | X1 = input_iterator_tag 35 | else 36 | X1 = C 37 | } 38 | 39 | 2. |category-to-traversal|_\ (X) is convertible to the most 40 | derived traversal tag type to which X is also 41 | convertible, and not to any more-derived traversal tag 42 | type. 43 | 44 | .. |category-to-traversal| replace:: *category-to-traversal* 45 | .. _`category-to-traversal`: new-iter-concepts.html#category-to-traversal 46 | 47 | [Note: the intention is to allow ``iterator_category`` to be one of 48 | the five original category tags when convertibility to one of the 49 | traversal tags would add no information] 50 | 51 | .. Copyright David Abrahams 2004. Use, modification and distribution is 52 | .. subject to the Boost Software License, Version 1.0. (See accompanying 53 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 54 | -------------------------------------------------------------------------------- /doc/filter_iterator.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/filter_iterator.pdf -------------------------------------------------------------------------------- /doc/filter_iterator.rst: -------------------------------------------------------------------------------- 1 | .. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | +++++++++++++++++ 6 | Filter Iterator 7 | +++++++++++++++++ 8 | 9 | :Author: David Abrahams, Jeremy Siek, Thomas Witt 10 | :Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de 11 | :organization: `Boost Consulting`_, Indiana University `Open Systems 12 | Lab`_, University of Hanover `Institute for Transport 13 | Railway Operation and Construction`_ 14 | :copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. 15 | 16 | .. _`Boost Consulting`: http://www.boost-consulting.com 17 | .. _`Open Systems Lab`: http://www.osl.iu.edu 18 | .. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de 19 | 20 | :abstract: 21 | 22 | .. include:: filter_iterator_abstract.rst 23 | 24 | .. contents:: Table of Contents 25 | 26 | ``filter_iterator`` synopsis 27 | ............................ 28 | 29 | .. include:: filter_iterator_ref.rst 30 | .. include:: make_filter_iterator.rst 31 | 32 | .. include:: filter_iterator_eg.rst 33 | -------------------------------------------------------------------------------- /doc/filter_iterator_abstract.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | The filter iterator adaptor creates a view of an iterator range in 6 | which some elements of the range are skipped. A predicate function 7 | object controls which elements are skipped. When the predicate is 8 | applied to an element, if it returns ``true`` then the element is 9 | retained and if it returns ``false`` then the element is skipped 10 | over. When skipping over elements, it is necessary for the filter 11 | adaptor to know when to stop so as to avoid going past the end of the 12 | underlying range. A filter iterator is therefore constructed with pair 13 | of iterators indicating the range of elements in the unfiltered 14 | sequence to be traversed. 15 | 16 | -------------------------------------------------------------------------------- /doc/filter_iterator_eg.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | Example 6 | ....... 7 | 8 | This example uses ``filter_iterator`` and then 9 | ``make_filter_iterator`` to output only the positive integers from an 10 | array of integers. Then ``make_filter_iterator`` is is used to output 11 | the integers greater than ``-2``. 12 | 13 | :: 14 | 15 | struct is_positive_number { 16 | bool operator()(int x) { return 0 < x; } 17 | }; 18 | 19 | int main() 20 | { 21 | int numbers_[] = { 0, -1, 4, -3, 5, 8, -2 }; 22 | const int N = sizeof(numbers_)/sizeof(int); 23 | 24 | typedef int* base_iterator; 25 | base_iterator numbers(numbers_); 26 | 27 | // Example using filter_iterator 28 | typedef boost::filter_iterator 29 | FilterIter; 30 | 31 | is_positive_number predicate; 32 | FilterIter filter_iter_first(predicate, numbers, numbers + N); 33 | FilterIter filter_iter_last(predicate, numbers + N, numbers + N); 34 | 35 | std::copy(filter_iter_first, filter_iter_last, std::ostream_iterator(std::cout, " ")); 36 | std::cout << std::endl; 37 | 38 | // Example using make_filter_iterator() 39 | std::copy(boost::make_filter_iterator(numbers, numbers + N), 40 | boost::make_filter_iterator(numbers + N, numbers + N), 41 | std::ostream_iterator(std::cout, " ")); 42 | std::cout << std::endl; 43 | 44 | // Another example using make_filter_iterator() 45 | std::copy( 46 | boost::make_filter_iterator( 47 | std::bind2nd(std::greater(), -2) 48 | , numbers, numbers + N) 49 | 50 | , boost::make_filter_iterator( 51 | std::bind2nd(std::greater(), -2) 52 | , numbers + N, numbers + N) 53 | 54 | , std::ostream_iterator(std::cout, " ") 55 | ); 56 | 57 | std::cout << std::endl; 58 | 59 | return boost::exit_success; 60 | } 61 | 62 | 63 | The output is:: 64 | 65 | 4 5 8 66 | 4 5 8 67 | 0 -1 4 5 8 68 | 69 | 70 | The source code for this example can be found `here`__. 71 | 72 | __ ../example/filter_iterator_example.cpp 73 | -------------------------------------------------------------------------------- /doc/func_output_iter_abstract.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | The function output iterator adaptor makes it easier to create custom 6 | output iterators. The adaptor takes a unary function and creates a 7 | model of Output Iterator. Each item assigned to the output iterator is 8 | passed as an argument to the unary function. The motivation for this 9 | iterator is that creating a conforming output iterator is non-trivial, 10 | particularly because the proper implementation usually requires a 11 | proxy object. 12 | 13 | -------------------------------------------------------------------------------- /doc/func_output_iter_ref.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | Header 6 | ...... 7 | 8 | :: 9 | 10 | #include 11 | 12 | :: 13 | 14 | template 15 | class function_output_iterator { 16 | public: 17 | typedef std::output_iterator_tag iterator_category; 18 | typedef void value_type; 19 | typedef void difference_type; 20 | typedef void pointer; 21 | typedef void reference; 22 | 23 | explicit function_output_iterator(); 24 | 25 | explicit function_output_iterator(const UnaryFunction& f); 26 | 27 | /* see below */ operator*(); 28 | function_output_iterator& operator++(); 29 | function_output_iterator& operator++(int); 30 | private: 31 | UnaryFunction m_f; // exposition only 32 | }; 33 | 34 | 35 | 36 | ``function_output_iterator`` requirements 37 | ......................................... 38 | 39 | ``UnaryFunction`` must be Assignable and Copy Constructible. 40 | 41 | 42 | 43 | ``function_output_iterator`` models 44 | ................................... 45 | 46 | ``function_output_iterator`` is a model of the Writable and 47 | Incrementable Iterator concepts. 48 | 49 | 50 | 51 | ``function_output_iterator`` operations 52 | ....................................... 53 | 54 | ``explicit function_output_iterator(const UnaryFunction& f = UnaryFunction());`` 55 | 56 | :Effects: Constructs an instance of ``function_output_iterator`` 57 | with ``m_f`` constructed from ``f``. 58 | 59 | 60 | ``operator*();`` 61 | 62 | :Returns: An object ``r`` of unspecified type such that ``r = t`` 63 | is equivalent to ``m_f(t)`` for all ``t``. 64 | 65 | 66 | ``function_output_iterator& operator++();`` 67 | 68 | :Returns: ``*this`` 69 | 70 | 71 | ``function_output_iterator& operator++(int);`` 72 | 73 | :Returns: ``*this`` 74 | -------------------------------------------------------------------------------- /doc/function_output_iterator.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/function_output_iterator.pdf -------------------------------------------------------------------------------- /doc/function_output_iterator.rst: -------------------------------------------------------------------------------- 1 | .. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | ++++++++++++++++++++++++++ 6 | Function Output Iterator 7 | ++++++++++++++++++++++++++ 8 | 9 | :Author: David Abrahams, Jeremy Siek, Thomas Witt 10 | :Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de 11 | :organization: `Boost Consulting`_, Indiana University `Open Systems 12 | Lab`_, University of Hanover `Institute for Transport 13 | Railway Operation and Construction`_ 14 | :copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. 15 | 16 | .. _`Boost Consulting`: http://www.boost-consulting.com 17 | .. _`Open Systems Lab`: http://www.osl.iu.edu 18 | .. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de 19 | 20 | :abstract: 21 | 22 | .. include:: func_output_iter_abstract.rst 23 | 24 | .. contents:: Table of Contents 25 | 26 | .. include:: func_output_iter_ref.rst 27 | .. include:: function_output_iterator_eg.rst -------------------------------------------------------------------------------- /doc/function_output_iterator_eg.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | Example 6 | ....... 7 | 8 | :: 9 | 10 | struct string_appender 11 | { 12 | string_appender(std::string& s) 13 | : m_str(&s) 14 | {} 15 | 16 | void operator()(const std::string& x) const 17 | { 18 | *m_str += x; 19 | } 20 | 21 | std::string* m_str; 22 | }; 23 | 24 | int main(int, char*[]) 25 | { 26 | std::vector x; 27 | x.push_back("hello"); 28 | x.push_back(" "); 29 | x.push_back("world"); 30 | x.push_back("!"); 31 | 32 | std::string s = ""; 33 | std::copy(x.begin(), x.end(), 34 | boost::make_function_output_iterator(string_appender(s))); 35 | 36 | std::cout << s << std::endl; 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /doc/generate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Copyright David Abrahams 2004. Use, modification and distribution is 3 | # subject to the Boost Software License, Version 1.0. (See accompanying 4 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | # 7 | # Generate html, TeX, and PDF versions of all the source files 8 | # 9 | import os 10 | import sys 11 | 12 | from syscmd import syscmd 13 | from sources import sources 14 | 15 | if 0: 16 | for s in sources: 17 | syscmd('boosthtml %s' % s) 18 | else: 19 | extensions = ('html', 'pdf') 20 | 21 | if len(sys.argv) > 1: 22 | extensions = sys.argv[1:] 23 | 24 | all = [ '%s.%s' % (os.path.splitext(s)[0],ext) 25 | for ext in extensions 26 | for s in sources 27 | ] 28 | 29 | print 'make %s' % ' '.join(all) 30 | syscmd('make %s' % ' '.join(all)) 31 | 32 | 33 | -------------------------------------------------------------------------------- /doc/indirect_iterator.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/indirect_iterator.pdf -------------------------------------------------------------------------------- /doc/indirect_iterator.rst: -------------------------------------------------------------------------------- 1 | .. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | +++++++++++++++++++ 6 | Indirect Iterator 7 | +++++++++++++++++++ 8 | 9 | :Author: David Abrahams, Jeremy Siek, Thomas Witt 10 | :Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de 11 | :organization: `Boost Consulting`_, Indiana University `Open Systems 12 | Lab`_, University of Hanover `Institute for Transport 13 | Railway Operation and Construction`_ 14 | :copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. 15 | 16 | .. _`Boost Consulting`: http://www.boost-consulting.com 17 | .. _`Open Systems Lab`: http://www.osl.iu.edu 18 | .. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de 19 | 20 | :abstract: 21 | 22 | .. include:: indirect_iterator_abstract.rst 23 | 24 | .. contents:: Table of Contents 25 | 26 | ``indirect_iterator`` synopsis 27 | .............................. 28 | 29 | .. include:: indirect_iterator_ref.rst 30 | .. include:: indirect_iterator_eg.rst 31 | 32 | .. _iterator-category: iterator_facade.html#iterator-category 33 | .. |iterator-category| replace:: *iterator-category* 34 | -------------------------------------------------------------------------------- /doc/indirect_iterator_abstract.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | ``indirect_iterator`` adapts an iterator by applying an 6 | *extra* dereference inside of ``operator*()``. For example, this 7 | iterator adaptor makes it possible to view a container of pointers 8 | (e.g. ``list``) as if it were a container of the pointed-to type 9 | (e.g. ``list``). ``indirect_iterator`` depends on two 10 | auxiliary traits, ``pointee`` and ``indirect_reference``, to 11 | provide support for underlying iterators whose ``value_type`` is 12 | not an iterator. 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /doc/indirect_iterator_eg.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | Example 6 | ....... 7 | 8 | This example prints an array of characters, using 9 | ``indirect_iterator`` to access the array of characters through an 10 | array of pointers. Next ``indirect_iterator`` is used with the 11 | ``transform`` algorithm to copy the characters (incremented by one) to 12 | another array. A constant indirect iterator is used for the source and 13 | a mutable indirect iterator is used for the destination. The last part 14 | of the example prints the original array of characters, but this time 15 | using the ``make_indirect_iterator`` helper function. 16 | 17 | 18 | :: 19 | 20 | char characters[] = "abcdefg"; 21 | const int N = sizeof(characters)/sizeof(char) - 1; // -1 since characters has a null char 22 | char* pointers_to_chars[N]; // at the end. 23 | for (int i = 0; i < N; ++i) 24 | pointers_to_chars[i] = &characters[i]; 25 | 26 | // Example of using indirect_iterator 27 | 28 | boost::indirect_iterator 29 | indirect_first(pointers_to_chars), indirect_last(pointers_to_chars + N); 30 | 31 | std::copy(indirect_first, indirect_last, std::ostream_iterator(std::cout, ",")); 32 | std::cout << std::endl; 33 | 34 | 35 | // Example of making mutable and constant indirect iterators 36 | 37 | char mutable_characters[N]; 38 | char* pointers_to_mutable_chars[N]; 39 | for (int j = 0; j < N; ++j) 40 | pointers_to_mutable_chars[j] = &mutable_characters[j]; 41 | 42 | boost::indirect_iterator mutable_indirect_first(pointers_to_mutable_chars), 43 | mutable_indirect_last(pointers_to_mutable_chars + N); 44 | boost::indirect_iterator const_indirect_first(pointers_to_chars), 45 | const_indirect_last(pointers_to_chars + N); 46 | 47 | std::transform(const_indirect_first, const_indirect_last, 48 | mutable_indirect_first, std::bind1st(std::plus(), 1)); 49 | 50 | std::copy(mutable_indirect_first, mutable_indirect_last, 51 | std::ostream_iterator(std::cout, ",")); 52 | std::cout << std::endl; 53 | 54 | 55 | // Example of using make_indirect_iterator() 56 | 57 | std::copy(boost::make_indirect_iterator(pointers_to_chars), 58 | boost::make_indirect_iterator(pointers_to_chars + N), 59 | std::ostream_iterator(std::cout, ",")); 60 | std::cout << std::endl; 61 | 62 | 63 | The output is:: 64 | 65 | a,b,c,d,e,f,g, 66 | b,c,d,e,f,g,h, 67 | a,b,c,d,e,f,g, 68 | 69 | 70 | The source code for this example can be found `here`__. 71 | 72 | __ ../example/indirect_iterator_example.cpp 73 | 74 | -------------------------------------------------------------------------------- /doc/indirect_reference_ref.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2004. Use, modification and distribution is 2 | .. subject to the Boost Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | :: 6 | 7 | template 8 | struct indirect_reference 9 | { 10 | typedef /* see below */ type; 11 | }; 12 | 13 | :Requires: For an object ``x`` of type ``Dereferenceable``, ``*x`` 14 | is well-formed. If ``++x`` is ill-formed it shall neither be 15 | ambiguous nor shall it violate access control, and 16 | ``pointee::type&`` shall be well-formed. 17 | Otherwise ``iterator_traits::reference`` shall 18 | be well formed. [Note: These requirements need not apply to 19 | explicit or partial specializations of ``indirect_reference``] 20 | 21 | ``type`` is determined according to the following algorithm, where 22 | ``x`` is an object of type ``Dereferenceable``:: 23 | 24 | if ( ++x is ill-formed ) 25 | return ``pointee::type&`` 26 | else 27 | std::iterator_traits::reference 28 | 29 | -------------------------------------------------------------------------------- /doc/iterator_adaptor.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/iterator_adaptor.pdf -------------------------------------------------------------------------------- /doc/iterator_adaptor.rst: -------------------------------------------------------------------------------- 1 | .. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | +++++++++++++++++ 6 | Iterator Adaptor 7 | +++++++++++++++++ 8 | 9 | :Author: David Abrahams, Jeremy Siek, Thomas Witt 10 | :Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de 11 | :organization: `Boost Consulting`_, Indiana University `Open Systems 12 | Lab`_, University of Hanover `Institute for Transport 13 | Railway Operation and Construction`_ 14 | :copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. 15 | 16 | .. _`Boost Consulting`: http://www.boost-consulting.com 17 | .. _`Open Systems Lab`: http://www.osl.iu.edu 18 | .. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de 19 | 20 | :abstract: 21 | 22 | .. include:: iterator_adaptor_abstract.rst 23 | 24 | .. contents:: Table of Contents 25 | 26 | Overview 27 | ======== 28 | 29 | .. include:: iterator_adaptor_body.rst 30 | 31 | 32 | Reference 33 | ========= 34 | 35 | .. include:: iterator_adaptor_ref.rst 36 | 37 | Tutorial Example 38 | ================ 39 | 40 | .. include:: iterator_adaptor_tutorial.rst 41 | -------------------------------------------------------------------------------- /doc/iterator_adaptor_abstract.rst: -------------------------------------------------------------------------------- 1 | .. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | .. Version 1.1 of this ReStructuredText document corresponds to 6 | n1530_, the paper accepted by the LWG. 7 | 8 | .. Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. 9 | 10 | Each specialization of the ``iterator_adaptor`` class template is derived from 11 | a specialization of ``iterator_facade``. The core interface functions 12 | expected by ``iterator_facade`` are implemented in terms of the 13 | ``iterator_adaptor``\ 's ``Base`` template parameter. A class derived 14 | from ``iterator_adaptor`` typically redefines some of the core 15 | interface functions to adapt the behavior of the ``Base`` type. 16 | Whether the derived class models any of the standard iterator concepts 17 | depends on the operations supported by the ``Base`` type and which 18 | core interface functions of ``iterator_facade`` are redefined in the 19 | ``Derived`` class. 20 | -------------------------------------------------------------------------------- /doc/iterator_adaptor_body.rst: -------------------------------------------------------------------------------- 1 | .. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | .. Version 1.2 of this ReStructuredText document corresponds to 6 | n1530_, the paper accepted by the LWG for TR1. 7 | 8 | .. Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. 9 | 10 | The ``iterator_adaptor`` class template adapts some ``Base`` [#base]_ 11 | type to create a new iterator. Instantiations of ``iterator_adaptor`` 12 | are derived from a corresponding instantiation of ``iterator_facade`` 13 | and implement the core behaviors in terms of the ``Base`` type. In 14 | essence, ``iterator_adaptor`` merely forwards all operations to an 15 | instance of the ``Base`` type, which it stores as a member. 16 | 17 | .. [#base] The term "Base" here does not refer to a base class and is 18 | not meant to imply the use of derivation. We have followed the lead 19 | of the standard library, which provides a base() function to access 20 | the underlying iterator object of a ``reverse_iterator`` adaptor. 21 | 22 | The user of ``iterator_adaptor`` creates a class derived from an 23 | instantiation of ``iterator_adaptor`` and then selectively 24 | redefines some of the core member functions described in the 25 | ``iterator_facade`` core requirements table. The ``Base`` type need 26 | not meet the full requirements for an iterator; it need only 27 | support the operations used by the core interface functions of 28 | ``iterator_adaptor`` that have not been redefined in the user's 29 | derived class. 30 | 31 | Several of the template parameters of ``iterator_adaptor`` default 32 | to ``use_default``. This allows the 33 | user to make use of a default parameter even when she wants to 34 | specify a parameter later in the parameter list. Also, the 35 | defaults for the corresponding associated types are somewhat 36 | complicated, so metaprogramming is required to compute them, and 37 | ``use_default`` can help to simplify the implementation. Finally, 38 | the identity of the ``use_default`` type is not left unspecified 39 | because specification helps to highlight that the ``Reference`` 40 | template parameter may not always be identical to the iterator's 41 | ``reference`` type, and will keep users from making mistakes based on 42 | that assumption. 43 | 44 | -------------------------------------------------------------------------------- /doc/iterator_archetypes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/iterator_archetypes.pdf -------------------------------------------------------------------------------- /doc/iterator_concepts.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/iterator_concepts.pdf -------------------------------------------------------------------------------- /doc/iterator_facade.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/iterator_facade.pdf -------------------------------------------------------------------------------- /doc/iterator_facade.rst: -------------------------------------------------------------------------------- 1 | .. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | ++++++++++++++++ 6 | Iterator Facade 7 | ++++++++++++++++ 8 | 9 | :Author: David Abrahams, Jeremy Siek, Thomas Witt 10 | :Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de 11 | :organization: `Boost Consulting`_, Indiana University `Open Systems 12 | Lab`_, University of Hanover `Institute for Transport 13 | Railway Operation and Construction`_ 14 | :copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. 15 | 16 | .. _`Boost Consulting`: http://www.boost-consulting.com 17 | .. _`Open Systems Lab`: http://www.osl.iu.edu 18 | .. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de 19 | 20 | :abstract: 21 | 22 | .. include:: iterator_facade_abstract.rst 23 | 24 | .. contents:: Table of Contents 25 | 26 | Overview 27 | ======== 28 | 29 | .. include:: iterator_facade_body.rst 30 | 31 | 32 | Reference 33 | ========= 34 | 35 | .. include:: iterator_facade_ref.rst 36 | 37 | .. _counting: counting_iterator.html 38 | 39 | Tutorial Example 40 | ================ 41 | 42 | .. include:: iterator_facade_tutorial.rst 43 | 44 | -------------------------------------------------------------------------------- /doc/iterator_facade_abstract.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | ``iterator_facade`` is a base class template that implements the 6 | interface of standard iterators in terms of a few core functions 7 | and associated types, to be supplied by a derived iterator class. 8 | 9 | -------------------------------------------------------------------------------- /doc/iterator_facade_tutorial.rst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/iterator_facade_tutorial.rst -------------------------------------------------------------------------------- /doc/iterator_traits.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/iterator_traits.pdf -------------------------------------------------------------------------------- /doc/iterator_traits.rst: -------------------------------------------------------------------------------- 1 | .. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | +++++++++++++++++ 6 | Iterator Traits 7 | +++++++++++++++++ 8 | 9 | :Author: David Abrahams 10 | :Contact: dave@boost-consulting.com 11 | :organization: `Boost Consulting`_ 12 | :copyright: Copyright David Abrahams 2004. 13 | 14 | .. _`Boost Consulting`: http://www.boost-consulting.com 15 | 16 | :abstract: Header ```` provides 17 | the ability to access an iterator's associated types using 18 | MPL-compatible metafunctions_. 19 | 20 | .. _metafunctions: ../../mpl/doc/index.html#metafunctions 21 | 22 | Overview 23 | ======== 24 | 25 | ``std::iterator_traits`` provides access to five associated types 26 | of any iterator: its ``value_type``, ``reference``, ``pointer``, 27 | ``iterator_category``, and ``difference_type``. Unfortunately, 28 | such a "multi-valued" traits template can be difficult to use in a 29 | metaprogramming context. ```` 30 | provides access to these types using a standard metafunctions_. 31 | 32 | Summary 33 | ======= 34 | 35 | Header ````:: 36 | 37 | template 38 | struct iterator_value 39 | { 40 | typedef typename 41 | std::iterator_traits::value_type 42 | type; 43 | }; 44 | 45 | template 46 | struct iterator_reference 47 | { 48 | typedef typename 49 | std::iterator_traits::reference 50 | type; 51 | }; 52 | 53 | 54 | template 55 | struct iterator_pointer 56 | { 57 | typedef typename 58 | std::iterator_traits::pointer 59 | type; 60 | }; 61 | 62 | template 63 | struct iterator_difference 64 | { 65 | typedef typename 66 | detail::iterator_traits::difference_type 67 | type; 68 | }; 69 | 70 | template 71 | struct iterator_category 72 | { 73 | typedef typename 74 | detail::iterator_traits::iterator_category 75 | type; 76 | }; 77 | -------------------------------------------------------------------------------- /doc/make_counting_iterator.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | :: 6 | 7 | template 8 | counting_iterator make_counting_iterator(Incrementable x); 9 | 10 | :Returns: An instance of ``counting_iterator`` 11 | with ``current`` constructed from ``x``. 12 | 13 | -------------------------------------------------------------------------------- /doc/make_filter_iterator.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | :: 6 | 7 | template 8 | filter_iterator 9 | make_filter_iterator(Predicate f, Iterator x, Iterator end = Iterator()); 10 | 11 | :Returns: filter_iterator(f, x, end) 12 | 13 | :: 14 | 15 | template 16 | filter_iterator 17 | make_filter_iterator(Iterator x, Iterator end = Iterator()); 18 | 19 | :Returns: filter_iterator(x, end) 20 | -------------------------------------------------------------------------------- /doc/make_reverse_iterator.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | :: 6 | 7 | template 8 | reverse_iteratorn 9 | make_reverse_iterator(BidirectionalIterator x); 10 | 11 | :Returns: An instance of ``reverse_iterator`` 12 | with a ``current`` constructed from ``x``. 13 | 14 | -------------------------------------------------------------------------------- /doc/make_transform_iterator.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | :: 6 | 7 | template 8 | transform_iterator 9 | make_transform_iterator(Iterator it, UnaryFunction fun); 10 | 11 | :Returns: An instance of ``transform_iterator`` with ``m_f`` 12 | initialized to ``f`` and ``m_iterator`` initialized to ``x``. 13 | 14 | 15 | 16 | :: 17 | 18 | template 19 | transform_iterator 20 | make_transform_iterator(Iterator it); 21 | 22 | :Returns: An instance of ``transform_iterator`` with ``m_f`` 23 | default constructed and ``m_iterator`` initialized to ``x``. 24 | -------------------------------------------------------------------------------- /doc/make_zip_iterator.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | :: 6 | 7 | template 8 | zip_iterator 9 | make_zip_iterator(IteratorTuple t); 10 | 11 | :Returns: An instance of ``zip_iterator`` with ``m_iterator_tuple`` 12 | initialized to ``t``. 13 | -------------------------------------------------------------------------------- /doc/new-iter-concepts.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/new-iter-concepts.pdf -------------------------------------------------------------------------------- /doc/oldeqnew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/oldeqnew.png -------------------------------------------------------------------------------- /doc/permutation_iter_abstract.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | The permutation iterator adaptor provides a permuted view of a given 6 | range. That is, the view includes every element of the given range but 7 | in a potentially different order. 8 | 9 | -------------------------------------------------------------------------------- /doc/permutation_iterator.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/permutation_iterator.pdf -------------------------------------------------------------------------------- /doc/permutation_iterator.rst: -------------------------------------------------------------------------------- 1 | .. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | ++++++++++++++++++++++ 6 | Permutation Iterator 7 | ++++++++++++++++++++++ 8 | 9 | :Author: Toon Knapen, David Abrahams, Roland Richter, Jeremy Siek 10 | :Contact: dave@boost-consulting.com, jsiek@osl.iu.edu 11 | :organization: `Boost Consulting`_, Indiana University `Open Systems 12 | Lab`_ 13 | :copyright: Copyright Toon Knapen, David Abrahams, Roland Richter, and Jeremy Siek 2003. 14 | 15 | .. _`Boost Consulting`: http://www.boost-consulting.com 16 | .. _`Open Systems Lab`: http://www.osl.iu.edu 17 | 18 | :abstract: 19 | 20 | .. include:: permutation_iter_abstract.rst 21 | 22 | .. contents:: Table of Contents 23 | 24 | 25 | Introduction 26 | ============ 27 | 28 | .. include:: permutation_iterator_body.rst 29 | 30 | 31 | Reference 32 | ========= 33 | 34 | .. include:: permutation_iterator_ref.rst 35 | 36 | 37 | Example 38 | ======= 39 | 40 | .. include:: permutation_iterator_eg.rst 41 | -------------------------------------------------------------------------------- /doc/permutation_iterator_body.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | The adaptor takes two arguments: 6 | 7 | * an iterator to the range V on which the permutation 8 | will be applied 9 | * the reindexing scheme that defines how the 10 | elements of V will be permuted. 11 | 12 | Note that the permutation iterator is not limited to strict 13 | permutations of the given range V. The distance between begin and end 14 | of the reindexing iterators is allowed to be smaller compared to the 15 | size of the range V, in which case the permutation iterator only 16 | provides a permutation of a subrange of V. The indexes neither need 17 | to be unique. In this same context, it must be noted that the past the 18 | end permutation iterator is completely defined by means of the 19 | past-the-end iterator to the indices. 20 | -------------------------------------------------------------------------------- /doc/permutation_iterator_eg.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | :: 6 | 7 | using namespace boost; 8 | int i = 0; 9 | 10 | typedef std::vector< int > element_range_type; 11 | typedef std::list< int > index_type; 12 | 13 | static const int element_range_size = 10; 14 | static const int index_size = 4; 15 | 16 | element_range_type elements( element_range_size ); 17 | for(element_range_type::iterator el_it = elements.begin() ; el_it != elements.end() ; ++el_it) 18 | *el_it = std::distance(elements.begin(), el_it); 19 | 20 | index_type indices( index_size ); 21 | for(index_type::iterator i_it = indices.begin() ; i_it != indices.end() ; ++i_it ) 22 | *i_it = element_range_size - index_size + std::distance(indices.begin(), i_it); 23 | std::reverse( indices.begin(), indices.end() ); 24 | 25 | typedef permutation_iterator< element_range_type::iterator, index_type::iterator > permutation_type; 26 | permutation_type begin = make_permutation_iterator( elements.begin(), indices.begin() ); 27 | permutation_type it = begin; 28 | permutation_type end = make_permutation_iterator( elements.begin(), indices.end() ); 29 | 30 | std::cout << "The original range is : "; 31 | std::copy( elements.begin(), elements.end(), std::ostream_iterator< int >( std::cout, " " ) ); 32 | std::cout << "\n"; 33 | 34 | std::cout << "The reindexing scheme is : "; 35 | std::copy( indices.begin(), indices.end(), std::ostream_iterator< int >( std::cout, " " ) ); 36 | std::cout << "\n"; 37 | 38 | std::cout << "The permutated range is : "; 39 | std::copy( begin, end, std::ostream_iterator< int >( std::cout, " " ) ); 40 | std::cout << "\n"; 41 | 42 | std::cout << "Elements at even indices in the permutation : "; 43 | it = begin; 44 | for(i = 0; i < index_size / 2 ; ++i, it+=2 ) std::cout << *it << " "; 45 | std::cout << "\n"; 46 | 47 | std::cout << "Permutation backwards : "; 48 | it = begin + (index_size); 49 | assert( it != begin ); 50 | for( ; it-- != begin ; ) std::cout << *it << " "; 51 | std::cout << "\n"; 52 | 53 | std::cout << "Iterate backward with stride 2 : "; 54 | it = begin + (index_size - 1); 55 | for(i = 0 ; i < index_size / 2 ; ++i, it-=2 ) std::cout << *it << " "; 56 | std::cout << "\n"; 57 | 58 | 59 | The output is:: 60 | 61 | The original range is : 0 1 2 3 4 5 6 7 8 9 62 | The reindexing scheme is : 9 8 7 6 63 | The permutated range is : 9 8 7 6 64 | Elements at even indices in the permutation : 9 7 65 | Permutation backwards : 6 7 8 9 66 | Iterate backward with stride 2 : 6 8 67 | 68 | 69 | The source code for this example can be found `here`__. 70 | 71 | __ ../example/permutation_iter_example.cpp 72 | -------------------------------------------------------------------------------- /doc/pointee.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/pointee.pdf -------------------------------------------------------------------------------- /doc/pointee.rst: -------------------------------------------------------------------------------- 1 | .. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | ++++++++++++++++++++++++++++++++++++++++ 6 | ``pointee`` and ``indirect_reference`` 7 | ++++++++++++++++++++++++++++++++++++++++ 8 | 9 | :Author: David Abrahams 10 | :Contact: dave@boost-consulting.com 11 | :organization: `Boost Consulting`_ 12 | :copyright: Copyright David Abrahams 2004. 13 | 14 | .. _`Boost Consulting`: http://www.boost-consulting.com 15 | 16 | :abstract: Provides the capability to deduce the referent types of 17 | pointers, smart pointers and iterators in generic code. 18 | 19 | Overview 20 | ======== 21 | 22 | Have you ever wanted to write a generic function that can operate 23 | on any kind of dereferenceable object? If you have, you've 24 | probably run into the problem of how to determine the type that the 25 | object "points at": 26 | 27 | .. parsed-literal:: 28 | 29 | template 30 | void f(Dereferenceable p) 31 | { 32 | *what-goes-here?* value = \*p; 33 | ... 34 | } 35 | 36 | 37 | ``pointee`` 38 | ----------- 39 | 40 | It turns out to be impossible to come up with a fully-general 41 | algorithm to do determine *what-goes-here* directly, but it is 42 | possible to require that ``pointee::type`` is 43 | correct. Naturally, ``pointee`` has the same difficulty: it can't 44 | determine the appropriate ``::type`` reliably for all 45 | ``Dereferenceable``\ s, but it makes very good guesses (it works 46 | for all pointers, standard and boost smart pointers, and 47 | iterators), and when it guesses wrongly, it can be specialized as 48 | necessary:: 49 | 50 | namespace boost 51 | { 52 | template 53 | struct pointee > 54 | { 55 | typedef T type; 56 | }; 57 | } 58 | 59 | ``indirect_reference`` 60 | ---------------------- 61 | 62 | ``indirect_reference::type`` is rather more specialized than 63 | ``pointee``, and is meant to be used to forward the result of 64 | dereferencing an object of its argument type. Most dereferenceable 65 | types just return a reference to their pointee, but some return 66 | proxy references or return the pointee by value. When that 67 | information is needed, call on ``indirect_reference``. 68 | 69 | Both of these templates are essential to the correct functioning of 70 | |indirect_iterator|_. 71 | 72 | .. |indirect_iterator| replace:: ``indirect_iterator`` 73 | .. _indirect_iterator: indirect_iterator.html 74 | 75 | Reference 76 | ========= 77 | 78 | ``pointee`` 79 | ----------- 80 | 81 | .. include:: pointee_ref.rst 82 | 83 | ``indirect_reference`` 84 | ---------------------- 85 | 86 | .. include:: indirect_reference_ref.rst 87 | 88 | -------------------------------------------------------------------------------- /doc/pointee_ref.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2004. Use, modification and distribution is 2 | .. subject to the Boost Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | :: 6 | 7 | template 8 | struct pointee 9 | { 10 | typedef /* see below */ type; 11 | }; 12 | 13 | :Requires: For an object ``x`` of type ``Dereferenceable``, ``*x`` 14 | is well-formed. If ``++x`` is ill-formed it shall neither be 15 | ambiguous nor shall it violate access control, and 16 | ``Dereferenceable::element_type`` shall be an accessible type. 17 | Otherwise ``iterator_traits::value_type`` shall 18 | be well formed. [Note: These requirements need not apply to 19 | explicit or partial specializations of ``pointee``] 20 | 21 | ``type`` is determined according to the following algorithm, where 22 | ``x`` is an object of type ``Dereferenceable``:: 23 | 24 | if ( ++x is ill-formed ) 25 | { 26 | return ``Dereferenceable::element_type`` 27 | } 28 | else if (``*x`` is a mutable reference to 29 | std::iterator_traits::value_type) 30 | { 31 | return iterator_traits::value_type 32 | } 33 | else 34 | { 35 | return iterator_traits::value_type const 36 | } 37 | 38 | -------------------------------------------------------------------------------- /doc/quickbook/concept_checking.qbk: -------------------------------------------------------------------------------- 1 | [section:concept_checking Concept Checking] 2 | 3 | The iterator concept checking classes provide a mechanism for a 4 | template to report better error messages when a user instantiates the 5 | template with a type that does not meet the requirements of the 6 | template. For an introduction to using concept checking classes, see 7 | the documentation for the _concept_check_ library. 8 | 9 | [h2 `iterator_concepts.hpp` Synopsis] 10 | 11 | namespace boost_concepts { 12 | 13 | // Iterator Access Concepts 14 | 15 | template 16 | class ReadableIteratorConcept; 17 | 18 | template < 19 | typename Iterator 20 | , typename ValueType = std::iterator_traits::value_type 21 | > 22 | class WritableIteratorConcept; 23 | 24 | template 25 | class SwappableIteratorConcept; 26 | 27 | template 28 | class LvalueIteratorConcept; 29 | 30 | // Iterator Traversal Concepts 31 | 32 | template 33 | class IncrementableIteratorConcept; 34 | 35 | template 36 | class SinglePassIteratorConcept; 37 | 38 | template 39 | class ForwardTraversalConcept; 40 | 41 | template 42 | class BidirectionalTraversalConcept; 43 | 44 | template 45 | class RandomAccessTraversalConcept; 46 | 47 | // Interoperability 48 | 49 | template 50 | class InteroperableIteratorConcept; 51 | 52 | } 53 | 54 | [endsect] 55 | -------------------------------------------------------------------------------- /doc/quickbook/function_output_iterator.qbk: -------------------------------------------------------------------------------- 1 | [section:function_output Function Output Iterator] 2 | 3 | The function output iterator adaptor makes it easier to create custom 4 | output iterators. The adaptor takes a unary function and creates a 5 | model of Output Iterator. Each item assigned to the output iterator is 6 | passed as an argument to the unary function. The motivation for this 7 | iterator is that creating a conforming output iterator is non-trivial, 8 | particularly because the proper implementation usually requires a 9 | proxy object. 10 | 11 | [h2 Example] 12 | 13 | struct string_appender 14 | { 15 | string_appender(std::string& s) 16 | : m_str(&s) 17 | {} 18 | 19 | void operator()(const std::string& x) const 20 | { 21 | *m_str += x; 22 | } 23 | 24 | std::string* m_str; 25 | }; 26 | 27 | int main(int, char*[]) 28 | { 29 | std::vector x; 30 | x.push_back("hello"); 31 | x.push_back(" "); 32 | x.push_back("world"); 33 | x.push_back("!"); 34 | 35 | std::string s = ""; 36 | std::copy(x.begin(), x.end(), 37 | boost::make_function_output_iterator(string_appender(s))); 38 | 39 | std::cout << s << std::endl; 40 | 41 | return 0; 42 | } 43 | 44 | [h2 Reference] 45 | 46 | [h3 Synopsis] 47 | 48 | template 49 | class function_output_iterator { 50 | public: 51 | typedef std::output_iterator_tag iterator_category; 52 | typedef void value_type; 53 | typedef void difference_type; 54 | typedef void pointer; 55 | typedef void reference; 56 | 57 | explicit function_output_iterator(); 58 | 59 | explicit function_output_iterator(const UnaryFunction& f); 60 | 61 | /* see below */ operator*(); 62 | function_output_iterator& operator++(); 63 | function_output_iterator& operator++(int); 64 | private: 65 | UnaryFunction m_f; // exposition only 66 | }; 67 | 68 | [h3 Requirements] 69 | 70 | `UnaryFunction` must be Assignable and Copy Constructible. 71 | 72 | [h3 Concepts] 73 | 74 | `function_output_iterator` is a model of the Writable and 75 | Incrementable Iterator concepts. 76 | 77 | [h3 Operations] 78 | 79 | explicit function_output_iterator(const UnaryFunction& f = UnaryFunction()); 80 | 81 | [*Effects: ] Constructs an instance of `function_output_iterator` 82 | with `m_f` constructed from `f`. 83 | 84 | unspecified_type operator*(); 85 | 86 | [*Returns: ] An object `r` of unspecified type such that `r = t` 87 | is equivalent to `m_f(t)` for all `t`. 88 | 89 | 90 | function_output_iterator& operator++(); 91 | 92 | [*Returns: ] `*this`. 93 | 94 | 95 | function_output_iterator& operator++(int); 96 | 97 | [*Returns: ] `*this`. 98 | 99 | [endsect] 100 | -------------------------------------------------------------------------------- /doc/quickbook/iterator_traits.qbk: -------------------------------------------------------------------------------- 1 | [section:iterator_traits Iterator Traits] 2 | 3 | `std::iterator_traits` provides access to five associated types 4 | of any iterator: its `value_type`, `reference`, `pointer`, 5 | `iterator_category`, and `difference_type`. Unfortunately, 6 | such a "multi-valued" traits template can be difficult to use in a 7 | metaprogramming context. `` 8 | provides access to these types using a standard metafunctions_. 9 | 10 | [h2 Synopsis] 11 | 12 | Header ``: 13 | 14 | template 15 | struct iterator_value 16 | { 17 | typedef typename 18 | std::iterator_traits::value_type 19 | type; 20 | }; 21 | 22 | template 23 | struct iterator_reference 24 | { 25 | typedef typename 26 | std::iterator_traits::reference 27 | type; 28 | }; 29 | 30 | template 31 | struct iterator_pointer 32 | { 33 | typedef typename 34 | std::iterator_traits::pointer 35 | type; 36 | }; 37 | 38 | template 39 | struct iterator_difference 40 | { 41 | typedef typename 42 | detail::iterator_traits::difference_type 43 | type; 44 | }; 45 | 46 | template 47 | struct iterator_category 48 | { 49 | typedef typename 50 | detail::iterator_traits::iterator_category 51 | type; 52 | }; 53 | 54 | [endsect] 55 | -------------------------------------------------------------------------------- /doc/quickbook/specialized_adaptors.qbk: -------------------------------------------------------------------------------- 1 | [section:specialized Specialized Adaptors] 2 | 3 | [include ./counting_iterator.qbk] 4 | 5 | [include ./filter_iterator.qbk] 6 | 7 | [include ./function_output_iterator.qbk] 8 | 9 | [include ./indirect_iterator.qbk] 10 | 11 | [include ./permutation_iterator.qbk] 12 | 13 | [include ./reverse_iterator.qbk] 14 | 15 | [include ./shared_container_iterator.qbk] 16 | 17 | [include ./transform_iterator.qbk] 18 | 19 | [include ./zip_iterator.qbk] 20 | 21 | [endsect] 22 | -------------------------------------------------------------------------------- /doc/ref_problem.rst: -------------------------------------------------------------------------------- 1 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 | Problem with ``reference`` and old/new iterator category correspondance 3 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 | 5 | .. _N1550: http://www.boost-consulting.com/writing/n1550.html 6 | .. _N1530: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1530.html 7 | 8 | :Author: David Abrahams and Jeremy Siek 9 | :Contact: dave@boost-consulting.com, jsiek@osl.iu.edu 10 | :Organization: `Boost Consulting`_, Indiana University Bloomington 11 | :Copyright: Copyright David Abrahams, Jeremy Siek 2003. Use, modification and 12 | distribution is subject to the Boost Software License, 13 | Version 1.0. (See accompanying file LICENSE_1_0.txt or copy 14 | at http://www.boost.org/LICENSE_1_0.txt) 15 | 16 | .. _`Boost Consulting`: http://www.boost-consulting.com 17 | 18 | ============== 19 | Introduction 20 | ============== 21 | 22 | The new iterator categories are intended to correspond to the old 23 | iterator categories, as specified in a diagram in N1550_. For example, 24 | an iterator categorized as a mutable Forward Iterator under the old 25 | scheme is now a Writable, Lvalue, and Foward Traversal iterator. 26 | However, there is a problem with this correspondance, the new iterator 27 | categories place requirements on the ``iterator_traits::reference`` 28 | type whereas the standard iterator requirements say nothing about the 29 | ``reference`` type . In particular, the new Readable Iterator 30 | requirements say that the return type of ``*a`` must be 31 | ``iterator_traits::reference`` and the Lvalue Iterator requirements 32 | says that ``iterator_traits::reference`` must be ``T&`` or ``const 33 | T&``. 34 | 35 | 36 | ==================== 37 | Proposed Resolution 38 | ==================== 39 | 40 | Change the standard requirements to match the requirements of the new 41 | iterators. (more details to come) 42 | 43 | 44 | ========== 45 | Rationale 46 | ========== 47 | 48 | The lack of specification in the standard of the ``reference`` type is 49 | certainly a defect. Without specification, it is entirely useless in a 50 | generic function. The current practice in the community is generally 51 | to assume there are requirements on the ``reference`` type, such as 52 | those proposed in the new iterator categories. 53 | 54 | There is some danger in *adding* requirements to existing concepts. 55 | This will mean that some existing iterator types will no longer meet 56 | the iterator requirements. However, we feel that the impact of this is 57 | small enough to warrant going ahead with this change. 58 | 59 | An alternative solution would be to leave the standard requirements as 60 | is, and to remove the requirements for the ``reference`` type in the 61 | new iterator concepts. We are not in favor of this approach because it 62 | extends what we see as a defect further into the future. 63 | -------------------------------------------------------------------------------- /doc/reverse_iterator.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/reverse_iterator.pdf -------------------------------------------------------------------------------- /doc/reverse_iterator.rst: -------------------------------------------------------------------------------- 1 | .. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | ++++++++++++++++++ 6 | Reverse Iterator 7 | ++++++++++++++++++ 8 | 9 | :Author: David Abrahams, Jeremy Siek, Thomas Witt 10 | :Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de 11 | :organization: `Boost Consulting`_, Indiana University `Open Systems 12 | Lab`_, University of Hanover `Institute for Transport 13 | Railway Operation and Construction`_ 14 | :copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. 15 | 16 | .. _`Boost Consulting`: http://www.boost-consulting.com 17 | .. _`Open Systems Lab`: http://www.osl.iu.edu 18 | .. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de 19 | 20 | :abstract: 21 | 22 | .. include:: reverse_iterator_abstract.rst 23 | 24 | .. contents:: Table of Contents 25 | 26 | ``reverse_iterator`` synopsis 27 | ............................. 28 | 29 | .. include:: reverse_iterator_ref.rst 30 | .. include:: make_reverse_iterator.rst 31 | 32 | .. include:: reverse_iterator_eg.rst 33 | -------------------------------------------------------------------------------- /doc/reverse_iterator_abstract.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | The reverse iterator adaptor iterates through the adapted iterator 6 | range in the opposite direction. 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /doc/reverse_iterator_eg.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | Example 6 | ....... 7 | 8 | The following example prints an array of characters in reverse order 9 | using ``reverse_iterator``. 10 | 11 | :: 12 | 13 | char letters_[] = "hello world!"; 14 | const int N = sizeof(letters_)/sizeof(char) - 1; 15 | typedef char* base_iterator; 16 | base_iterator letters(letters_); 17 | std::cout << "original sequence of letters:\t\t\t" << letters_ << std::endl; 18 | 19 | boost::reverse_iterator 20 | reverse_letters_first(letters + N), 21 | reverse_letters_last(letters); 22 | 23 | std::cout << "sequence in reverse order:\t\t\t"; 24 | std::copy(reverse_letters_first, reverse_letters_last, 25 | std::ostream_iterator(std::cout)); 26 | std::cout << std::endl; 27 | 28 | std::cout << "sequence in double-reversed (normal) order:\t"; 29 | std::copy(boost::make_reverse_iterator(reverse_letters_last), 30 | boost::make_reverse_iterator(reverse_letters_first), 31 | std::ostream_iterator(std::cout)); 32 | std::cout << std::endl; 33 | 34 | 35 | 36 | The output is:: 37 | 38 | original sequence of letters: hello world! 39 | sequence in reverse order: !dlrow olleh 40 | sequence in double-reversed (normal) order: hello world! 41 | 42 | 43 | The source code for this example can be found `here`__. 44 | 45 | __ ../example/reverse_iterator_example.cpp 46 | -------------------------------------------------------------------------------- /doc/rst2html.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright David Abrahams 2006. Distributed under the Boost 3 | # Software License, Version 1.0. (See accompanying 4 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | PYTHONPATH="c:/src/docutils;c:/src/docutils/extras" 6 | export PYTHONPATH 7 | rst2html.py -gs --link-stylesheet --traceback --trim-footnote-reference-space --footnote-references=superscript --stylesheet=../../../rst.css $1 `echo $1 | sed 's/\(.*\)\..*/\1.html/'` 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /doc/rst2latex.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright David Abrahams 2006. Distributed under the Boost 3 | # Software License, Version 1.0. (See accompanying 4 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 | PYTHONPATH="c:/src/docutils;c:/src/docutils/extras" 6 | export PYTHONPATH 7 | python c:/src/docutils/tools/rst2latex.py --documentoptions pdftex --stylesheet=docutils.sty $1 `echo $1 | sed 's/\(.*\)\..*/\1.tex/'` 8 | -------------------------------------------------------------------------------- /doc/scanrst.py: -------------------------------------------------------------------------------- 1 | # Copyright David Abrahams 2004. Use, modification and distribution is 2 | # subject to the Boost Software License, Version 1.0. (See accompanying 3 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | # This script accepts a list of .rst files to be processed and 6 | # generates Makefile dependencies for .html and .rst files to stdout. 7 | import os,sys 8 | import re 9 | 10 | include = re.compile(r' *\.\. +(include|image):: +(.*)', re.MULTILINE) 11 | 12 | def deps(path, found): 13 | dir = os.path.split(path)[0] 14 | for m in re.findall(include, open(path).read()): 15 | 16 | dependency = os.path.normpath(os.path.join(dir,m[1])) 17 | if dependency not in found: 18 | found[dependency] = 1 19 | 20 | if m[0] == 'include': 21 | deps(dependency, found) 22 | 23 | return found 24 | 25 | for file in sys.argv[1:]: 26 | found = deps(file, {}) 27 | if found: 28 | base = os.path.splitext(os.path.basename(file))[0] 29 | print '%s.tex %s.html: %s' % (base, base, ' '.join(found.keys())) 30 | -------------------------------------------------------------------------------- /doc/sources.py: -------------------------------------------------------------------------------- 1 | # Copyright David Abrahams 2004. Use, modification and distribution is 2 | # subject to the Boost Software License, Version 1.0. (See accompanying 3 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | sources = [ 6 | 'counting_iterator.rst', 7 | 'facade-and-adaptor.rst', 8 | 'filter_iterator.rst', 9 | 'function_input_iterator.rst', 10 | 'function_output_iterator.rst', 11 | 'index.rst', 12 | 'indirect_iterator.rst', 13 | 'pointee.rst', 14 | 'iterator_adaptor.rst', 15 | 'iterator_facade.rst', 16 | 'new-iter-concepts.rst', 17 | 'permutation_iterator.rst', 18 | 'reverse_iterator.rst', 19 | 'transform_iterator.rst', 20 | 'zip_iterator.rst', 21 | 'iterator_archetypes.rst', 22 | 'iterator_concepts.rst', 23 | 'iterator_traits.rst' 24 | ] 25 | 26 | -------------------------------------------------------------------------------- /doc/syscmd.py: -------------------------------------------------------------------------------- 1 | # Copyright David Abrahams 2004. Use, modification and distribution is 2 | # subject to the Boost Software License, Version 1.0. (See accompanying 3 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | import os 6 | import sys 7 | 8 | def syscmd(s): 9 | print 'executing: ', repr(s) 10 | sys.stdout.flush() 11 | err = os.system(s) 12 | if err: 13 | raise SystemError, 'command: %s returned %s' % ( 14 | repr(s), err) 15 | -------------------------------------------------------------------------------- /doc/transform_iterator.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/transform_iterator.pdf -------------------------------------------------------------------------------- /doc/transform_iterator.rst: -------------------------------------------------------------------------------- 1 | .. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | ++++++++++++++++++++ 6 | Transform Iterator 7 | ++++++++++++++++++++ 8 | 9 | :Author: David Abrahams, Jeremy Siek, Thomas Witt 10 | :Contact: dave@boost-consulting.com, jsiek@osl.iu.edu, witt@ive.uni-hannover.de 11 | :organization: `Boost Consulting`_, Indiana University `Open Systems 12 | Lab`_, University of Hanover `Institute for Transport 13 | Railway Operation and Construction`_ 14 | :copyright: Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. 15 | 16 | .. _`Boost Consulting`: http://www.boost-consulting.com 17 | .. _`Open Systems Lab`: http://www.osl.iu.edu 18 | .. _`Institute for Transport Railway Operation and Construction`: http://www.ive.uni-hannover.de 19 | 20 | :abstract: 21 | 22 | .. include:: transform_iterator_abstract.rst 23 | 24 | .. contents:: Table of Contents 25 | 26 | ``transform_iterator`` synopsis 27 | ............................... 28 | 29 | .. include:: transform_iterator_ref.rst 30 | .. include:: make_transform_iterator.rst 31 | .. include:: transform_iterator_eg.rst 32 | -------------------------------------------------------------------------------- /doc/transform_iterator_abstract.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | The transform iterator adapts an iterator by modifying the 6 | ``operator*`` to apply a function object to the result of 7 | dereferencing the iterator and returning the result. 8 | -------------------------------------------------------------------------------- /doc/transform_iterator_eg.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | Example 6 | ....... 7 | 8 | This is a simple example of using the transform_iterators class to 9 | generate iterators that multiply (or add to) the value returned by 10 | dereferencing the iterator. It would be cooler to use lambda library 11 | in this example. 12 | 13 | :: 14 | 15 | int x[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; 16 | const int N = sizeof(x)/sizeof(int); 17 | 18 | typedef boost::binder1st< std::multiplies > Function; 19 | typedef boost::transform_iterator doubling_iterator; 20 | 21 | doubling_iterator i(x, boost::bind1st(std::multiplies(), 2)), 22 | i_end(x + N, boost::bind1st(std::multiplies(), 2)); 23 | 24 | std::cout << "multiplying the array by 2:" << std::endl; 25 | while (i != i_end) 26 | std::cout << *i++ << " "; 27 | std::cout << std::endl; 28 | 29 | std::cout << "adding 4 to each element in the array:" << std::endl; 30 | std::copy(boost::make_transform_iterator(x, boost::bind1st(std::plus(), 4)), 31 | boost::make_transform_iterator(x + N, boost::bind1st(std::plus(), 4)), 32 | std::ostream_iterator(std::cout, " ")); 33 | std::cout << std::endl; 34 | 35 | 36 | The output is:: 37 | 38 | multiplying the array by 2: 39 | 2 4 6 8 10 12 14 16 40 | adding 4 to each element in the array: 41 | 5 6 7 8 9 10 11 12 42 | 43 | 44 | The source code for this example can be found `here`__. 45 | 46 | __ ../example/transform_iterator_example.cpp 47 | -------------------------------------------------------------------------------- /doc/traversal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/traversal.png -------------------------------------------------------------------------------- /doc/zip_iterator.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/iterator/3767696513aedc14f45768fd402100d678895437/doc/zip_iterator.pdf -------------------------------------------------------------------------------- /doc/zip_iterator.rst: -------------------------------------------------------------------------------- 1 | .. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | +++++++++++++ 6 | Zip Iterator 7 | +++++++++++++ 8 | 9 | :Author: David Abrahams, Thomas Becker 10 | :Contact: dave@boost-consulting.com, thomas@styleadvisor.com 11 | :organization: `Boost Consulting`_, `Zephyr Associates, Inc.`_ 12 | :copyright: Copyright David Abrahams and Thomas Becker 2003. 13 | 14 | .. _`Boost Consulting`: http://www.boost-consulting.com 15 | .. _`Zephyr Associates, Inc.`: http://www.styleadvisor.com 16 | 17 | :abstract: 18 | 19 | .. include:: zip_iterator_abstract.rst 20 | 21 | .. contents:: Table of Contents 22 | 23 | ``zip_iterator`` synopsis 24 | ............................... 25 | 26 | .. include:: zip_iterator_ref.rst 27 | .. include:: make_zip_iterator.rst 28 | .. include:: zip_iterator_eg.rst 29 | -------------------------------------------------------------------------------- /doc/zip_iterator_abstract.rst: -------------------------------------------------------------------------------- 1 | .. Copyright David Abrahams 2006. Distributed under the Boost 2 | .. Software License, Version 1.0. (See accompanying 3 | .. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | The zip iterator provides the ability to parallel-iterate 6 | over several controlled sequences simultaneously. A zip 7 | iterator is constructed from a tuple of iterators. Moving 8 | the zip iterator moves all the iterators in parallel. 9 | Dereferencing the zip iterator returns a tuple that contains 10 | the results of dereferencing the individual iterators. 11 | 12 | The tuple of iterators is now implemented in terms of a Boost fusion sequence. 13 | Because of this the 'tuple' may be any Boost fusion sequence and, for backwards 14 | compatibility through a Boost fusion sequence adapter, a Boost tuple. Because the 15 | 'tuple' may be any boost::fusion sequence the 'tuple' may also be any type for which a 16 | Boost fusion adapter exists. This includes, among others, a std::tuple and a std::pair. 17 | Just remember to include the appropriate Boost fusion adapter header files for these 18 | other Boost fusion adapters. The zip_iterator header file already includes the 19 | Boost fusion adapter header file for Boost tuple, so you need not include it yourself 20 | to use a Boost tuple as your 'tuple'. 21 | -------------------------------------------------------------------------------- /example/counting_iterator_example.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Jeremy Siek 2000-2004. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | int main(int, char*[]) 17 | { 18 | // Example of using counting_iterator 19 | std::cout << "counting from 0 to 4:" << std::endl; 20 | boost::counting_iterator first(0), last(4); 21 | std::copy(first, last, std::ostream_iterator(std::cout, " ")); 22 | std::cout << std::endl; 23 | 24 | // Example of using counting iterator to create an array of pointers. 25 | int N = 7; 26 | std::vector numbers; 27 | typedef std::vector::iterator n_iter; 28 | // Fill "numbers" array with [0,N) 29 | std::copy( 30 | boost::counting_iterator(0) 31 | , boost::counting_iterator(N) 32 | , std::back_inserter(numbers)); 33 | 34 | std::vector::iterator> pointers; 35 | 36 | // Use counting iterator to fill in the array of pointers. 37 | // causes an ICE with MSVC6 38 | std::copy(boost::make_counting_iterator(numbers.begin()), 39 | boost::make_counting_iterator(numbers.end()), 40 | std::back_inserter(pointers)); 41 | 42 | // Use indirect iterator to print out numbers by accessing 43 | // them through the array of pointers. 44 | std::cout << "indirectly printing out the numbers from 0 to " 45 | << N << std::endl; 46 | std::copy(boost::make_indirect_iterator(pointers.begin()), 47 | boost::make_indirect_iterator(pointers.end()), 48 | std::ostream_iterator(std::cout, " ")); 49 | std::cout << std::endl; 50 | 51 | return boost::exit_success; 52 | } 53 | -------------------------------------------------------------------------------- /example/filter_iterator_example.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Jeremy Siek 1999-2004. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include // for exit_success 13 | 14 | struct is_positive_number { 15 | bool operator()(int x) { return 0 < x; } 16 | }; 17 | 18 | int main() 19 | { 20 | int numbers_[] = { 0, -1, 4, -3, 5, 8, -2 }; 21 | const int N = sizeof(numbers_)/sizeof(int); 22 | 23 | typedef int* base_iterator; 24 | base_iterator numbers(numbers_); 25 | 26 | // Example using make_filter_iterator() 27 | std::copy(boost::make_filter_iterator(numbers, numbers + N), 28 | boost::make_filter_iterator(numbers + N, numbers + N), 29 | std::ostream_iterator(std::cout, " ")); 30 | std::cout << std::endl; 31 | 32 | // Example using filter_iterator 33 | typedef boost::filter_iterator 34 | FilterIter; 35 | 36 | is_positive_number predicate; 37 | FilterIter filter_iter_first(predicate, numbers, numbers + N); 38 | FilterIter filter_iter_last(predicate, numbers + N, numbers + N); 39 | 40 | std::copy(filter_iter_first, filter_iter_last, std::ostream_iterator(std::cout, " ")); 41 | std::cout << std::endl; 42 | 43 | // Another example using make_filter_iterator() 44 | std::copy( 45 | boost::make_filter_iterator( 46 | boost::bind(std::greater(), boost::placeholders::_1, -2) 47 | , numbers, numbers + N) 48 | 49 | , boost::make_filter_iterator( 50 | boost::bind(std::greater(), boost::placeholders::_1, -2) 51 | , numbers + N, numbers + N) 52 | 53 | , std::ostream_iterator(std::cout, " ") 54 | ); 55 | 56 | std::cout << std::endl; 57 | 58 | return boost::exit_success; 59 | } 60 | -------------------------------------------------------------------------------- /example/func_output_iter_example.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Jeremy Siek 2001-2004. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // Revision History: 7 | 8 | // 27 Feb 2001 Jeremy Siek 9 | // Initial checkin. 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | struct string_appender 18 | { 19 | string_appender(std::string& s) 20 | : m_str(&s) 21 | {} 22 | 23 | void operator()(const std::string& x) const 24 | { 25 | *m_str += x; 26 | } 27 | 28 | std::string* m_str; 29 | }; 30 | 31 | int main(int, char*[]) 32 | { 33 | std::vector x; 34 | x.push_back("hello"); 35 | x.push_back(" "); 36 | x.push_back("world"); 37 | x.push_back("!"); 38 | 39 | std::string s = ""; 40 | std::copy(x.begin(), x.end(), 41 | boost::make_function_output_iterator(string_appender(s))); 42 | 43 | std::cout << s << std::endl; 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /example/indirect_iterator_example.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Jeremy Siek 2000-2004. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | int main(int, char*[]) 16 | { 17 | char characters[] = "abcdefg"; 18 | const int N = sizeof(characters)/sizeof(char) - 1; // -1 since characters has a null char 19 | char* pointers_to_chars[N]; // at the end. 20 | for (int i = 0; i < N; ++i) 21 | pointers_to_chars[i] = &characters[i]; 22 | 23 | // Example of using indirect_iterator 24 | 25 | boost::indirect_iterator 26 | indirect_first(pointers_to_chars), indirect_last(pointers_to_chars + N); 27 | 28 | std::copy(indirect_first, indirect_last, std::ostream_iterator(std::cout, ",")); 29 | std::cout << std::endl; 30 | 31 | 32 | // Example of making mutable and constant indirect iterators 33 | 34 | char mutable_characters[N]; 35 | char* pointers_to_mutable_chars[N]; 36 | for (int j = 0; j < N; ++j) 37 | pointers_to_mutable_chars[j] = &mutable_characters[j]; 38 | 39 | boost::indirect_iterator mutable_indirect_first(pointers_to_mutable_chars), 40 | mutable_indirect_last(pointers_to_mutable_chars + N); 41 | boost::indirect_iterator const_indirect_first(pointers_to_chars), 42 | const_indirect_last(pointers_to_chars + N); 43 | 44 | std::transform(const_indirect_first, const_indirect_last, 45 | mutable_indirect_first, boost::bind(std::plus(), 1, boost::placeholders::_1)); 46 | 47 | std::copy(mutable_indirect_first, mutable_indirect_last, 48 | std::ostream_iterator(std::cout, ",")); 49 | std::cout << std::endl; 50 | 51 | 52 | // Example of using make_indirect_iterator() 53 | 54 | std::copy(boost::make_indirect_iterator(pointers_to_chars), 55 | boost::make_indirect_iterator(pointers_to_chars + N), 56 | std::ostream_iterator(std::cout, ",")); 57 | std::cout << std::endl; 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /example/node.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2004. Use, modification and distribution is 2 | // subject to the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | #ifndef NODE_DWA2004110_HPP 5 | # define NODE_DWA2004110_HPP 6 | 7 | # include 8 | 9 | // Polymorphic list node base class 10 | 11 | struct node_base 12 | { 13 | node_base() : m_next(0) {} 14 | 15 | virtual ~node_base() 16 | { 17 | delete m_next; 18 | } 19 | 20 | node_base* next() const 21 | { 22 | return m_next; 23 | } 24 | 25 | virtual void print(std::ostream& s) const = 0; 26 | virtual void double_me() = 0; 27 | 28 | void append(node_base* p) 29 | { 30 | if (m_next) 31 | m_next->append(p); 32 | else 33 | m_next = p; 34 | } 35 | 36 | private: 37 | node_base* m_next; 38 | }; 39 | 40 | inline std::ostream& operator<<(std::ostream& s, node_base const& n) 41 | { 42 | n.print(s); 43 | return s; 44 | } 45 | 46 | template 47 | struct node : node_base 48 | { 49 | node(T x) 50 | : m_value(x) 51 | {} 52 | 53 | void print(std::ostream& s) const { s << this->m_value; } 54 | void double_me() { m_value += m_value; } 55 | 56 | private: 57 | T m_value; 58 | }; 59 | 60 | #endif // NODE_DWA2004110_HPP 61 | -------------------------------------------------------------------------------- /example/node_iterator1.cpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2004. Use, modification and distribution is 2 | // subject to the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include "node_iterator1.hpp" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main() 13 | { 14 | 15 | #if defined(BOOST_NO_CXX11_SMART_PTR) 16 | 17 | std::auto_ptr > nodes(new node(42)); 18 | 19 | #else 20 | 21 | std::unique_ptr > nodes(new node(42)); 22 | 23 | #endif 24 | 25 | nodes->append(new node(" is greater than ")); 26 | nodes->append(new node(13)); 27 | 28 | std::copy( 29 | node_iterator(nodes.get()), node_iterator() 30 | , std::ostream_iterator(std::cout, " ") 31 | ); 32 | std::cout << std::endl; 33 | 34 | std::for_each( 35 | node_iterator(nodes.get()), node_iterator() 36 | , std::mem_fun_ref(&node_base::double_me) 37 | ); 38 | 39 | std::copy( 40 | node_iterator(nodes.get()), node_iterator() 41 | , std::ostream_iterator(std::cout, "/") 42 | ); 43 | std::cout << std::endl; 44 | } 45 | -------------------------------------------------------------------------------- /example/node_iterator1.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2004. Use, modification and distribution is 2 | // subject to the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | #ifndef NODE_ITERATOR1_DWA2004110_HPP 5 | # define NODE_ITERATOR1_DWA2004110_HPP 6 | 7 | # include "node.hpp" 8 | # include 9 | 10 | class node_iterator 11 | : public boost::iterator_facade< 12 | node_iterator 13 | , node_base 14 | , boost::forward_traversal_tag 15 | > 16 | { 17 | public: 18 | node_iterator() 19 | : m_node(0) 20 | {} 21 | 22 | explicit node_iterator(node_base* p) 23 | : m_node(p) 24 | {} 25 | 26 | private: 27 | friend class boost::iterator_core_access; 28 | 29 | void increment() 30 | { m_node = m_node->next(); } 31 | 32 | bool equal(node_iterator const& other) const 33 | { return this->m_node == other.m_node; } 34 | 35 | node_base& dereference() const 36 | { return *m_node; } 37 | 38 | node_base* m_node; 39 | }; 40 | 41 | 42 | #endif // NODE_ITERATOR1_DWA2004110_HPP 43 | -------------------------------------------------------------------------------- /example/node_iterator2.cpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2004. Use, modification and distribution is 2 | // subject to the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include "node_iterator2.hpp" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | int main() 14 | { 15 | 16 | #if defined(BOOST_NO_CXX11_SMART_PTR) 17 | 18 | std::auto_ptr > nodes(new node(42)); 19 | 20 | #else 21 | 22 | std::unique_ptr > nodes(new node(42)); 23 | 24 | #endif 25 | 26 | nodes->append(new node(" is greater than ")); 27 | nodes->append(new node(13)); 28 | 29 | // Check interoperability 30 | assert(node_iterator(nodes.get()) == node_const_iterator(nodes.get())); 31 | assert(node_const_iterator(nodes.get()) == node_iterator(nodes.get())); 32 | 33 | assert(node_iterator(nodes.get()) != node_const_iterator()); 34 | assert(node_const_iterator(nodes.get()) != node_iterator()); 35 | 36 | std::copy( 37 | node_iterator(nodes.get()), node_iterator() 38 | , std::ostream_iterator(std::cout, " ") 39 | ); 40 | std::cout << std::endl; 41 | 42 | std::for_each( 43 | node_iterator(nodes.get()), node_iterator() 44 | , boost::mem_fn(&node_base::double_me) 45 | ); 46 | 47 | std::copy( 48 | node_const_iterator(nodes.get()), node_const_iterator() 49 | , std::ostream_iterator(std::cout, "/") 50 | ); 51 | std::cout << std::endl; 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /example/node_iterator2.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2004. Use, modification and distribution is 2 | // subject to the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | #ifndef NODE_ITERATOR2_DWA2004110_HPP 5 | # define NODE_ITERATOR2_DWA2004110_HPP 6 | 7 | # include "node.hpp" 8 | # include 9 | # include 10 | 11 | template 12 | class node_iter 13 | : public boost::iterator_facade< 14 | node_iter 15 | , Value 16 | , boost::forward_traversal_tag 17 | > 18 | { 19 | private: 20 | struct enabler {}; // a private type avoids misuse 21 | 22 | public: 23 | node_iter() 24 | : m_node(0) {} 25 | 26 | explicit node_iter(Value* p) 27 | : m_node(p) {} 28 | 29 | template 30 | node_iter( 31 | node_iter const& other 32 | , typename std::enable_if< 33 | std::is_convertible::value 34 | , enabler 35 | >::type = enabler() 36 | ) 37 | : m_node(other.m_node) {} 38 | 39 | template 40 | bool equal(node_iter const& other) const 41 | { 42 | return this->m_node == other.m_node; 43 | } 44 | 45 | void increment() { m_node = m_node->next(); } 46 | 47 | Value& dereference() const { return *m_node; } 48 | 49 | # ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS 50 | public: 51 | # else 52 | private: 53 | template friend class node_iter; 54 | # endif 55 | Value* m_node; 56 | }; 57 | 58 | typedef node_iter node_iterator; 59 | typedef node_iter node_const_iterator; 60 | 61 | #endif // NODE_ITERATOR2_DWA2004110_HPP 62 | -------------------------------------------------------------------------------- /example/node_iterator3.cpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2004. Use, modification and distribution is 2 | // subject to the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include "node_iterator3.hpp" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | int main() 14 | { 15 | 16 | #if defined(BOOST_NO_CXX11_SMART_PTR) 17 | 18 | std::auto_ptr > nodes(new node(42)); 19 | 20 | #else 21 | 22 | std::unique_ptr > nodes(new node(42)); 23 | 24 | #endif 25 | 26 | nodes->append(new node(" is greater than ")); 27 | nodes->append(new node(13)); 28 | 29 | // Check interoperability 30 | assert(node_iterator(nodes.get()) == node_const_iterator(nodes.get())); 31 | assert(node_const_iterator(nodes.get()) == node_iterator(nodes.get())); 32 | 33 | assert(node_iterator(nodes.get()) != node_const_iterator()); 34 | assert(node_const_iterator(nodes.get()) != node_iterator()); 35 | 36 | std::copy( 37 | node_iterator(nodes.get()), node_iterator() 38 | , std::ostream_iterator(std::cout, " ") 39 | ); 40 | std::cout << std::endl; 41 | 42 | std::for_each( 43 | node_iterator(nodes.get()), node_iterator() 44 | , boost::mem_fn(&node_base::double_me) 45 | ); 46 | 47 | std::copy( 48 | node_const_iterator(nodes.get()), node_const_iterator() 49 | , std::ostream_iterator(std::cout, "/") 50 | ); 51 | std::cout << std::endl; 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /example/node_iterator3.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2004. Use, modification and distribution is 2 | // subject to the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | #ifndef NODE_ITERATOR3_DWA2004110_HPP 5 | # define NODE_ITERATOR3_DWA2004110_HPP 6 | 7 | # include "node.hpp" 8 | # include 9 | # include 10 | 11 | template 12 | class node_iter 13 | : public boost::iterator_adaptor< 14 | node_iter // Derived 15 | , Value* // Base 16 | , boost::use_default // Value 17 | , boost::forward_traversal_tag // CategoryOrTraversal 18 | > 19 | { 20 | private: 21 | struct enabler {}; // a private type avoids misuse 22 | 23 | typedef boost::iterator_adaptor< 24 | node_iter, Value*, boost::use_default, boost::forward_traversal_tag 25 | > super_t; 26 | 27 | public: 28 | node_iter() 29 | : super_t(0) {} 30 | 31 | explicit node_iter(Value* p) 32 | : super_t(p) {} 33 | 34 | template 35 | node_iter( 36 | node_iter const& other 37 | , typename std::enable_if< 38 | std::is_convertible::value 39 | , enabler 40 | >::type = enabler() 41 | ) 42 | : super_t(other.base()) {} 43 | 44 | # if !BOOST_WORKAROUND(__GNUC__, == 2) 45 | private: // GCC2 can't grant friendship to template member functions 46 | friend class boost::iterator_core_access; 47 | # endif 48 | void increment() { this->base_reference() = this->base()->next(); } 49 | }; 50 | 51 | typedef node_iter node_iterator; 52 | typedef node_iter node_const_iterator; 53 | 54 | #endif // NODE_ITERATOR3_DWA2004110_HPP 55 | -------------------------------------------------------------------------------- /example/permutation_iter_example.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2004 Jeremy Siek 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | int main() { 16 | using namespace boost; 17 | int i = 0; 18 | 19 | typedef std::vector< int > element_range_type; 20 | typedef std::deque< int > index_type; 21 | 22 | static const int element_range_size = 10; 23 | static const int index_size = 4; 24 | 25 | element_range_type elements( element_range_size ); 26 | for(element_range_type::iterator el_it = elements.begin() ; el_it != elements.end() ; ++el_it) 27 | *el_it = std::distance(elements.begin(), el_it); 28 | 29 | index_type indices( index_size ); 30 | for(index_type::iterator i_it = indices.begin() ; i_it != indices.end() ; ++i_it ) 31 | *i_it = element_range_size - index_size + std::distance(indices.begin(), i_it); 32 | std::reverse( indices.begin(), indices.end() ); 33 | 34 | typedef permutation_iterator< element_range_type::iterator, index_type::iterator > permutation_type; 35 | permutation_type begin = make_permutation_iterator( elements.begin(), indices.begin() ); 36 | permutation_type it = begin; 37 | permutation_type end = make_permutation_iterator( elements.begin(), indices.end() ); 38 | 39 | std::cout << "The original range is : "; 40 | std::copy( elements.begin(), elements.end(), std::ostream_iterator< int >( std::cout, " " ) ); 41 | std::cout << "\n"; 42 | 43 | std::cout << "The reindexing scheme is : "; 44 | std::copy( indices.begin(), indices.end(), std::ostream_iterator< int >( std::cout, " " ) ); 45 | std::cout << "\n"; 46 | 47 | std::cout << "The permutated range is : "; 48 | std::copy( begin, end, std::ostream_iterator< int >( std::cout, " " ) ); 49 | std::cout << "\n"; 50 | 51 | std::cout << "Elements at even indices in the permutation : "; 52 | it = begin; 53 | for(i = 0; i < index_size / 2 ; ++i, it+=2 ) std::cout << *it << " "; 54 | std::cout << "\n"; 55 | 56 | std::cout << "Permutation backwards : "; 57 | it = begin + (index_size); 58 | assert( it != begin ); 59 | for( ; it-- != begin ; ) std::cout << *it << " "; 60 | std::cout << "\n"; 61 | 62 | std::cout << "Iterate backward with stride 2 : "; 63 | it = begin + (index_size - 1); 64 | for(i = 0 ; i < index_size / 2 ; ++i, it-=2 ) std::cout << *it << " "; 65 | std::cout << "\n"; 66 | 67 | return boost::exit_success; 68 | } 69 | -------------------------------------------------------------------------------- /example/reverse_iterator.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2004 Jeremy Siek 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main() 13 | { 14 | int x[] = { 1, 2, 3, 4 }; 15 | boost::reverse_iterator first(x + 4), last(x); 16 | std::copy(first, last, std::ostream_iterator(std::cout, " ")); 17 | std::cout << std::endl; 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /example/reverse_iterator_example.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Jeremy Siek 2000-2004. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int, char*[]) 13 | { 14 | char letters_[] = "hello world!"; 15 | const int N = sizeof(letters_)/sizeof(char) - 1; 16 | typedef char* base_iterator; 17 | base_iterator letters(letters_); 18 | 19 | std::cout << "original sequence of letters:\t\t\t" 20 | << letters_ << std::endl; 21 | 22 | // Use reverse_iterator to print a sequence of letters in reverse 23 | // order. 24 | 25 | boost::reverse_iterator 26 | reverse_letters_first(letters + N), 27 | reverse_letters_last(letters); 28 | 29 | std::cout << "sequence in reverse order:\t\t\t"; 30 | std::copy(reverse_letters_first, reverse_letters_last, 31 | std::ostream_iterator(std::cout)); 32 | std::cout << std::endl; 33 | 34 | std::cout << "sequence in double-reversed (normal) order:\t"; 35 | std::copy(boost::make_reverse_iterator(reverse_letters_last), 36 | boost::make_reverse_iterator(reverse_letters_first), 37 | std::ostream_iterator(std::cout)); 38 | std::cout << std::endl; 39 | 40 | return boost::exit_success; 41 | } 42 | -------------------------------------------------------------------------------- /example/shared_iterator_example1.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2003 The Trustees of Indiana University. 2 | 3 | // Use, modification and distribution is subject to the Boost Software 4 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #include "boost/shared_container_iterator.hpp" 8 | #include "boost/shared_ptr.hpp" 9 | #include 10 | #include 11 | #include 12 | 13 | typedef boost::shared_container_iterator< std::vector > iterator; 14 | 15 | 16 | void set_range(iterator& i, iterator& end) { 17 | 18 | boost::shared_ptr< std::vector > ints(new std::vector()); 19 | 20 | ints->push_back(0); 21 | ints->push_back(1); 22 | ints->push_back(2); 23 | ints->push_back(3); 24 | ints->push_back(4); 25 | ints->push_back(5); 26 | 27 | i = iterator(ints->begin(),ints); 28 | end = iterator(ints->end(),ints); 29 | } 30 | 31 | 32 | int main() { 33 | 34 | iterator i,end; 35 | 36 | set_range(i,end); 37 | 38 | std::copy(i,end,std::ostream_iterator(std::cout,",")); 39 | std::cout.put('\n'); 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /example/shared_iterator_example2.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2003 The Trustees of Indiana University. 2 | 3 | // Use, modification and distribution is subject to the Boost Software 4 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #include "boost/shared_container_iterator.hpp" 8 | #include "boost/shared_ptr.hpp" 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | template 16 | void print_range_nl (Iterator begin, Iterator end) { 17 | typedef typename std::iterator_traits::value_type val; 18 | std::copy(begin,end,std::ostream_iterator(std::cout,",")); 19 | std::cout.put('\n'); 20 | } 21 | 22 | 23 | int main() { 24 | 25 | typedef boost::shared_ptr< std::vector > ints_t; 26 | { 27 | ints_t ints(new std::vector()); 28 | 29 | ints->push_back(0); 30 | ints->push_back(1); 31 | ints->push_back(2); 32 | ints->push_back(3); 33 | ints->push_back(4); 34 | ints->push_back(5); 35 | 36 | print_range_nl(boost::make_shared_container_iterator(ints->begin(),ints), 37 | boost::make_shared_container_iterator(ints->end(),ints)); 38 | } 39 | 40 | 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /example/shared_iterator_example3.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2003 The Trustees of Indiana University. 2 | 3 | // Use, modification and distribution is subject to the Boost Software 4 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #include "boost/shared_container_iterator.hpp" 8 | #include "boost/shared_ptr.hpp" 9 | #include "boost/tuple/tuple.hpp" // for boost::tie 10 | #include // for std::copy 11 | #include 12 | #include 13 | 14 | 15 | typedef boost::shared_container_iterator< std::vector > iterator; 16 | 17 | std::pair 18 | return_range() { 19 | boost::shared_ptr< std::vector > range(new std::vector()); 20 | range->push_back(0); 21 | range->push_back(1); 22 | range->push_back(2); 23 | range->push_back(3); 24 | range->push_back(4); 25 | range->push_back(5); 26 | return boost::make_shared_container_range(range); 27 | } 28 | 29 | 30 | int main() { 31 | 32 | 33 | iterator i,end; 34 | 35 | boost::tie(i,end) = return_range(); 36 | 37 | std::copy(i,end,std::ostream_iterator(std::cout,",")); 38 | std::cout.put('\n'); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /example/transform_iterator_example.cpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Jeremy Siek 2000-2004. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | // What a bummer. We can't use std::binder1st with transform iterator 13 | // because it does not have a default constructor. Here's a version 14 | // that does. 15 | 16 | namespace boost { 17 | 18 | template 19 | class binder1st { 20 | public: 21 | typedef typename Operation::result_type result_type; 22 | typedef typename Operation::second_argument_type argument_type; 23 | protected: 24 | Operation op; 25 | typename Operation::first_argument_type value; 26 | public: 27 | binder1st() { } // this had to be added! 28 | binder1st(const Operation& x, 29 | const typename Operation::first_argument_type& y) 30 | : op(x), value(y) {} 31 | typename Operation::result_type 32 | operator()(const typename Operation::second_argument_type& x) const { 33 | return op(value, x); 34 | } 35 | }; 36 | 37 | template 38 | inline binder1st bind1st(const Operation& op, const T& x) { 39 | typedef typename Operation::first_argument_type arg1_type; 40 | return binder1st(op, arg1_type(x)); 41 | } 42 | 43 | } // namespace boost 44 | 45 | int 46 | main(int, char*[]) 47 | { 48 | // This is a simple example of using the transform_iterators class to 49 | // generate iterators that multiply the value returned by dereferencing 50 | // the iterator. In this case we are multiplying by 2. 51 | // Would be cooler to use lambda library in this example. 52 | 53 | int x[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; 54 | const int N = sizeof(x)/sizeof(int); 55 | 56 | typedef boost::binder1st< std::multiplies > Function; 57 | typedef boost::transform_iterator doubling_iterator; 58 | 59 | doubling_iterator i(x, boost::bind1st(std::multiplies(), 2)), 60 | i_end(x + N, boost::bind1st(std::multiplies(), 2)); 61 | 62 | std::cout << "multiplying the array by 2:" << std::endl; 63 | while (i != i_end) 64 | std::cout << *i++ << " "; 65 | std::cout << std::endl; 66 | 67 | std::cout << "adding 4 to each element in the array:" << std::endl; 68 | 69 | std::copy(boost::make_transform_iterator(x, boost::bind1st(std::plus(), 4)), 70 | boost::make_transform_iterator(x + N, boost::bind1st(std::plus(), 4)), 71 | std::ostream_iterator(std::cout, " ")); 72 | std::cout << std::endl; 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /include/boost/function_output_iterator.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Andrey Semashev 2017. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_FUNCTION_OUTPUT_ITERATOR_HPP 7 | #define BOOST_FUNCTION_OUTPUT_ITERATOR_HPP 8 | 9 | // This is a deprecated header left for backward compatibility. 10 | // Use boost/iterator/function_output_iterator.hpp instead. 11 | 12 | #include 13 | 14 | BOOST_HEADER_DEPRECATED("") 15 | 16 | #include 17 | 18 | #endif // BOOST_FUNCTION_OUTPUT_ITERATOR_HPP 19 | -------------------------------------------------------------------------------- /include/boost/generator_iterator.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Andrey Semashev 2025. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP 7 | #define BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP 8 | 9 | // This is a deprecated header left for backward compatibility. 10 | // Please use instead. 11 | 12 | #include 13 | 14 | #endif // BOOST_ITERATOR_ADAPTOR_GENERATOR_ITERATOR_HPP 15 | -------------------------------------------------------------------------------- /include/boost/indirect_reference.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_INDIRECT_REFERENCE_DWA200415_HPP 2 | #define BOOST_INDIRECT_REFERENCE_DWA200415_HPP 3 | 4 | // 5 | // Copyright David Abrahams 2004. Use, modification and distribution is 6 | // subject to the Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | // 9 | // typename indirect_reference

::type provides the type of *p. 10 | // 11 | // http://www.boost.org/libs/iterator/doc/pointee.html 12 | // 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | namespace boost { 21 | namespace detail { 22 | 23 | template< typename P > 24 | struct smart_ptr_reference 25 | { 26 | using type = boost::pointee_t< P >&; 27 | }; 28 | 29 | } // namespace detail 30 | 31 | template< typename P > 32 | struct indirect_reference : 33 | std::conditional< 34 | detail::is_incrementable< P >::value, 35 | iterator_reference< P >, 36 | detail::smart_ptr_reference< P > 37 | >::type 38 | { 39 | }; 40 | 41 | template< typename P > 42 | using indirect_reference_t = typename indirect_reference< P >::type; 43 | 44 | } // namespace boost 45 | 46 | #endif // BOOST_INDIRECT_REFERENCE_DWA200415_HPP 47 | -------------------------------------------------------------------------------- /include/boost/iterator/advance.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Michel Morin. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_ITERATOR_ADVANCE_HPP 8 | #define BOOST_ITERATOR_ADVANCE_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace boost { 14 | namespace iterators { 15 | namespace detail { 16 | 17 | template< typename InputIterator, typename Distance > 18 | inline BOOST_CXX14_CONSTEXPR void advance_impl(InputIterator& it, Distance n, incrementable_traversal_tag) 19 | { 20 | while (n > 0) 21 | { 22 | ++it; 23 | --n; 24 | } 25 | } 26 | 27 | template< typename BidirectionalIterator, typename Distance > 28 | inline BOOST_CXX14_CONSTEXPR void advance_impl(BidirectionalIterator& it, Distance n, bidirectional_traversal_tag) 29 | { 30 | if (n >= 0) 31 | { 32 | while (n > 0) 33 | { 34 | ++it; 35 | --n; 36 | } 37 | } 38 | else 39 | { 40 | while (n < 0) 41 | { 42 | --it; 43 | ++n; 44 | } 45 | } 46 | } 47 | 48 | template< typename RandomAccessIterator, typename Distance > 49 | inline BOOST_CXX14_CONSTEXPR void advance_impl(RandomAccessIterator& it, Distance n, random_access_traversal_tag) 50 | { 51 | it += n; 52 | } 53 | 54 | } // namespace detail 55 | 56 | namespace advance_adl_barrier { 57 | 58 | template< typename InputIterator, typename Distance > 59 | inline BOOST_CXX14_CONSTEXPR void advance(InputIterator& it, Distance n) 60 | { 61 | detail::advance_impl(it, n, typename iterator_traversal< InputIterator >::type()); 62 | } 63 | 64 | } // namespace advance_adl_barrier 65 | 66 | using namespace advance_adl_barrier; 67 | 68 | } // namespace iterators 69 | 70 | using namespace iterators::advance_adl_barrier; 71 | 72 | } // namespace boost 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /include/boost/iterator/detail/config_def.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright David Abrahams 2002. 2 | // (C) Copyright Jeremy Siek 2002. 3 | // (C) Copyright Thomas Witt 2002. 4 | // Distributed under the Boost Software License, Version 1.0. (See 5 | // accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | 8 | // no include guard multiple inclusion intended 9 | 10 | // 11 | // This is a temporary workaround until the bulk of this is 12 | // available in boost config. 13 | // 23/02/03 thw 14 | // 15 | 16 | #include // for prior 17 | #include 18 | 19 | #ifdef BOOST_ITERATOR_CONFIG_DEF 20 | # error you have nested config_def #inclusion. 21 | #else 22 | # define BOOST_ITERATOR_CONFIG_DEF 23 | #endif 24 | 25 | // We enable this always now. Otherwise, the simple case in 26 | // libs/iterator/test/constant_iterator_arrow.cpp fails to compile 27 | // because the operator-> return is improperly deduced as a non-const 28 | // pointer. 29 | 30 | // Recall that in general, compilers without partial specialization 31 | // can't strip constness. Consider counting_iterator, which normally 32 | // passes a const Value to iterator_facade. As a result, any code 33 | // which makes a std::vector of the iterator's value_type will fail 34 | // when its allocator declares functions overloaded on reference and 35 | // const_reference (the same type). 36 | // 37 | // Furthermore, Borland 5.5.1 drops constness in enough ways that we 38 | // end up using a proxy for operator[] when we otherwise shouldn't. 39 | // Using reference constness gives it an extra hint that it can 40 | // return the value_type from operator[] directly, but is not 41 | // strictly necessary. Not sure how best to resolve this one. 42 | 43 | # define BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY 1 44 | 45 | // no include guard; multiple inclusion intended 46 | -------------------------------------------------------------------------------- /include/boost/iterator/detail/config_undef.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Thomas Witt 2002. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // no include guard multiple inclusion intended 7 | 8 | // 9 | // This is a temporary workaround until the bulk of this is 10 | // available in boost config. 11 | // 23/02/03 thw 12 | // 13 | 14 | #undef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY 15 | 16 | #ifdef BOOST_ITERATOR_CONFIG_DEF 17 | # undef BOOST_ITERATOR_CONFIG_DEF 18 | #else 19 | # error missing or nested #include config_def 20 | #endif 21 | -------------------------------------------------------------------------------- /include/boost/iterator/detail/eval_if_default.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the Boost Software License, Version 1.0. 3 | * (See accompanying file LICENSE_1_0.txt or copy at 4 | * https://www.boost.org/LICENSE_1_0.txt) 5 | * 6 | * Copyright (c) 2025 Andrey Semashev 7 | */ 8 | 9 | #ifndef BOOST_ITERATOR_DETAIL_EVAL_IF_DEFAULT_HPP_INCLUDED_ 10 | #define BOOST_ITERATOR_DETAIL_EVAL_IF_DEFAULT_HPP_INCLUDED_ 11 | 12 | #include 13 | #include 14 | 15 | namespace boost { 16 | namespace iterators { 17 | namespace detail { 18 | 19 | // If T is use_default, return the result of invoking 20 | // DefaultNullaryFn, otherwise - of NondefaultNullaryFn. 21 | // By default, NondefaultNullaryFn returns T, which means 22 | // the metafunction can be called with just two parameters 23 | // and in that case will return either T or the result of 24 | // invoking DefaultNullaryFn. 25 | template< typename T, typename DefaultNullaryFn, typename NondefaultNullaryFn = detail::type_identity< T > > 26 | struct eval_if_default 27 | { 28 | using type = typename NondefaultNullaryFn::type; 29 | }; 30 | 31 | template< typename DefaultNullaryFn, typename NondefaultNullaryFn > 32 | struct eval_if_default< use_default, DefaultNullaryFn, NondefaultNullaryFn > 33 | { 34 | using type = typename DefaultNullaryFn::type; 35 | }; 36 | 37 | template< typename T, typename DefaultNullaryFn, typename NondefaultNullaryFn = detail::type_identity< T > > 38 | using eval_if_default_t = typename eval_if_default< T, DefaultNullaryFn, NondefaultNullaryFn >::type; 39 | 40 | } // namespace detail 41 | } // namespace iterators 42 | } // namespace boost 43 | 44 | #endif // BOOST_ITERATOR_DETAIL_EVAL_IF_DEFAULT_HPP_INCLUDED_ 45 | -------------------------------------------------------------------------------- /include/boost/iterator/detail/if_default.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the Boost Software License, Version 1.0. 3 | * (See accompanying file LICENSE_1_0.txt or copy at 4 | * https://www.boost.org/LICENSE_1_0.txt) 5 | * 6 | * Copyright (c) 2025 Andrey Semashev 7 | */ 8 | 9 | #ifndef BOOST_ITERATOR_DETAIL_IF_DEFAULT_HPP_INCLUDED_ 10 | #define BOOST_ITERATOR_DETAIL_IF_DEFAULT_HPP_INCLUDED_ 11 | 12 | #include 13 | 14 | namespace boost { 15 | namespace iterators { 16 | namespace detail { 17 | 18 | // If T is use_default, return Default, otherwise - Nondefault. 19 | // By default, Nondefault is T, which means 20 | // the metafunction can be called with just two parameters 21 | // and in that case will return either T or Default. 22 | template< typename T, typename Default, typename Nondefault = T > 23 | struct if_default 24 | { 25 | using type = Nondefault; 26 | }; 27 | 28 | template< typename Default, typename Nondefault > 29 | struct if_default< use_default, Default, Nondefault > 30 | { 31 | using type = Default; 32 | }; 33 | 34 | template< typename T, typename Default, typename Nondefault = T > 35 | using if_default_t = typename if_default< T, Default, Nondefault >::type; 36 | 37 | } // namespace detail 38 | } // namespace iterators 39 | } // namespace boost 40 | 41 | #endif // BOOST_ITERATOR_DETAIL_IF_DEFAULT_HPP_INCLUDED_ 42 | -------------------------------------------------------------------------------- /include/boost/iterator/detail/type_traits/conjunction.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the Boost Software License, Version 1.0. 3 | * (See accompanying file LICENSE_1_0.txt or copy at 4 | * https://www.boost.org/LICENSE_1_0.txt) 5 | * 6 | * Copyright (c) 2024 Georgiy Guminov 7 | */ 8 | /*! 9 | * \file iterator/detail/type_traits/conjunction.hpp 10 | * 11 | * This header contains definition of \c conjunction type trait. 12 | */ 13 | 14 | #ifndef BOOST_ITERATOR_DETAIL_TYPE_TRAITS_CONJUNCTION_HPP_INCLUDED_ 15 | #define BOOST_ITERATOR_DETAIL_TYPE_TRAITS_CONJUNCTION_HPP_INCLUDED_ 16 | 17 | #include 18 | #include 19 | 20 | #ifdef BOOST_HAS_PRAGMA_ONCE 21 | #pragma once 22 | #endif 23 | 24 | #if (defined(__cpp_lib_logical_traits) && (__cpp_lib_logical_traits >= 201510l)) || \ 25 | (defined(BOOST_MSSTL_VERSION) && (BOOST_MSSTL_VERSION >= 140) && (_MSC_FULL_VER >= 190023918) && (BOOST_CXX_VERSION >= 201703l)) 26 | 27 | namespace boost { 28 | namespace iterators { 29 | namespace detail { 30 | 31 | using std::conjunction; 32 | 33 | } // namespace detail 34 | } // namespace iterator 35 | } // namespace boost 36 | 37 | #else 38 | 39 | #include 40 | 41 | namespace boost { 42 | namespace iterators { 43 | namespace detail { 44 | 45 | using boost::conjunction; 46 | 47 | } // namespace detail 48 | } // namespace iterator 49 | } // namespace boost 50 | 51 | #endif 52 | 53 | #endif // BOOST_ITERATOR_DETAIL_TYPE_TRAITS_CONJUNCTION_HPP_INCLUDED_ 54 | -------------------------------------------------------------------------------- /include/boost/iterator/detail/type_traits/disjunction.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the Boost Software License, Version 1.0. 3 | * (See accompanying file LICENSE_1_0.txt or copy at 4 | * https://www.boost.org/LICENSE_1_0.txt) 5 | * 6 | * Copyright (c) 2024 Georgiy Guminov 7 | */ 8 | /*! 9 | * \file iterator/detail/type_traits/disjunction.hpp 10 | * 11 | * This header contains definition of \c disjunction type trait. 12 | */ 13 | 14 | #ifndef BOOST_ITERATOR_DETAIL_TYPE_TRAITS_DISJUNCTION_HPP_INCLUDED_ 15 | #define BOOST_ITERATOR_DETAIL_TYPE_TRAITS_DISJUNCTION_HPP_INCLUDED_ 16 | 17 | #include 18 | #include 19 | 20 | #ifdef BOOST_HAS_PRAGMA_ONCE 21 | #pragma once 22 | #endif 23 | 24 | #if (defined(__cpp_lib_logical_traits) && (__cpp_lib_logical_traits >= 201510l)) || \ 25 | (defined(BOOST_MSSTL_VERSION) && (BOOST_MSSTL_VERSION >= 140) && (_MSC_FULL_VER >= 190023918) && (BOOST_CXX_VERSION >= 201703l)) 26 | 27 | namespace boost { 28 | namespace iterators { 29 | namespace detail { 30 | 31 | using std::disjunction; 32 | 33 | } // namespace detail 34 | } // namespace iterator 35 | } // namespace boost 36 | 37 | #else 38 | 39 | #include 40 | 41 | namespace boost { 42 | namespace iterators { 43 | namespace detail { 44 | 45 | using boost::disjunction; 46 | 47 | } // namespace detail 48 | } // namespace iterator 49 | } // namespace boost 50 | 51 | #endif 52 | 53 | #endif // BOOST_ITERATOR_DETAIL_TYPE_TRAITS_DISJUNCTION_HPP_INCLUDED_ 54 | -------------------------------------------------------------------------------- /include/boost/iterator/detail/type_traits/negation.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the Boost Software License, Version 1.0. 3 | * (See accompanying file LICENSE_1_0.txt or copy at 4 | * https://www.boost.org/LICENSE_1_0.txt) 5 | * 6 | * Copyright (c) 2024 Georgiy Guminov 7 | */ 8 | /*! 9 | * \file iterator/detail/type_traits/negation.hpp 10 | * 11 | * This header contains definition of \c negation type trait. 12 | */ 13 | 14 | #ifndef BOOST_ITERATOR_DETAIL_TYPE_TRAITS_NEGATION_HPP_INCLUDED_ 15 | #define BOOST_ITERATOR_DETAIL_TYPE_TRAITS_NEGATION_HPP_INCLUDED_ 16 | 17 | #include 18 | #include 19 | 20 | #ifdef BOOST_HAS_PRAGMA_ONCE 21 | #pragma once 22 | #endif 23 | 24 | #if (defined(__cpp_lib_logical_traits) && (__cpp_lib_logical_traits >= 201510l)) || \ 25 | (defined(BOOST_MSSTL_VERSION) && (BOOST_MSSTL_VERSION >= 140) && (_MSC_FULL_VER >= 190023918) && (BOOST_CXX_VERSION >= 201703l)) 26 | 27 | namespace boost { 28 | namespace iterators { 29 | namespace detail { 30 | 31 | using std::negation; 32 | 33 | } // namespace detail 34 | } // namespace iterator 35 | } // namespace boost 36 | 37 | #else 38 | 39 | #include 40 | 41 | namespace boost { 42 | namespace iterators { 43 | namespace detail { 44 | 45 | using boost::negation; 46 | 47 | } // namespace detail 48 | } // namespace iterator 49 | } // namespace boost 50 | 51 | #endif 52 | 53 | #endif // BOOST_ITERATOR_DETAIL_TYPE_TRAITS_NEGATION_HPP_INCLUDED_ 54 | -------------------------------------------------------------------------------- /include/boost/iterator/detail/type_traits/type_identity.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Distributed under the Boost Software License, Version 1.0. 3 | * (See accompanying file LICENSE_1_0.txt or copy at 4 | * https://www.boost.org/LICENSE_1_0.txt) 5 | * 6 | * Copyright (c) 2025 Andrey Semashev 7 | */ 8 | /*! 9 | * \file iterator/detail/type_traits/type_identity.hpp 10 | * 11 | * This header contains definition of \c negation type trait. 12 | */ 13 | 14 | #ifndef BOOST_ITERATOR_DETAIL_TYPE_TRAITS_TYPE_IDENTITY_HPP_INCLUDED_ 15 | #define BOOST_ITERATOR_DETAIL_TYPE_TRAITS_TYPE_IDENTITY_HPP_INCLUDED_ 16 | 17 | #include 18 | #include 19 | 20 | #ifdef BOOST_HAS_PRAGMA_ONCE 21 | #pragma once 22 | #endif 23 | 24 | #if (defined(__cpp_lib_type_identity) && (__cpp_lib_type_identity >= 201806l)) || \ 25 | /* Note: MSVC 19.21 does not define _MSVC_LANG to 202002 in c++latest (C++20) mode but to a value larger than 201703 */ \ 26 | (defined(BOOST_MSSTL_VERSION) && (BOOST_MSSTL_VERSION >= 142) && (_MSC_VER >= 1921) && (BOOST_CXX_VERSION > 201703l)) 27 | 28 | namespace boost { 29 | namespace iterators { 30 | namespace detail { 31 | 32 | using std::type_identity; 33 | 34 | } // namespace detail 35 | } // namespace iterator 36 | } // namespace boost 37 | 38 | #else 39 | 40 | #include 41 | 42 | namespace boost { 43 | namespace iterators { 44 | namespace detail { 45 | 46 | using boost::type_identity; 47 | 48 | } // namespace detail 49 | } // namespace iterator 50 | } // namespace boost 51 | 52 | #endif 53 | 54 | #endif // BOOST_ITERATOR_DETAIL_TYPE_TRAITS_TYPE_IDENTITY_HPP_INCLUDED_ 55 | -------------------------------------------------------------------------------- /include/boost/iterator/distance.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Michel Morin. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_ITERATOR_DISTANCE_HPP 8 | #define BOOST_ITERATOR_DISTANCE_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace boost { 15 | namespace iterators { 16 | namespace detail { 17 | 18 | template< typename SinglePassIterator > 19 | inline BOOST_CXX14_CONSTEXPR typename iterator_difference< SinglePassIterator >::type 20 | distance_impl(SinglePassIterator first, SinglePassIterator last, single_pass_traversal_tag) 21 | { 22 | typename iterator_difference< SinglePassIterator >::type n = 0; 23 | while (first != last) 24 | { 25 | ++first; 26 | ++n; 27 | } 28 | return n; 29 | } 30 | 31 | template< typename RandomAccessIterator > 32 | inline BOOST_CXX14_CONSTEXPR typename iterator_difference< RandomAccessIterator >::type 33 | distance_impl(RandomAccessIterator first, RandomAccessIterator last, random_access_traversal_tag) 34 | { 35 | return last - first; 36 | } 37 | 38 | } // namespace detail 39 | 40 | namespace distance_adl_barrier { 41 | 42 | template< typename SinglePassIterator > 43 | inline BOOST_CXX14_CONSTEXPR typename iterator_difference< SinglePassIterator >::type 44 | distance(SinglePassIterator first, SinglePassIterator last) 45 | { 46 | return detail::distance_impl(first, last, typename iterator_traversal< SinglePassIterator >::type()); 47 | } 48 | 49 | } // namespace distance_adl_barrier 50 | 51 | using namespace distance_adl_barrier; 52 | 53 | } // namespace iterators 54 | 55 | using namespace iterators::distance_adl_barrier; 56 | 57 | } // namespace boost 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /include/boost/iterator/function_output_iterator.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Jeremy Siek 2001. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // Revision History: 7 | 8 | // 27 Feb 2001 Jeremy Siek 9 | // Initial checkin. 10 | 11 | #ifndef BOOST_ITERATOR_FUNCTION_OUTPUT_ITERATOR_HPP_INCLUDED_ 12 | #define BOOST_ITERATOR_FUNCTION_OUTPUT_ITERATOR_HPP_INCLUDED_ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | namespace boost { 19 | namespace iterators { 20 | 21 | template< typename UnaryFunction > 22 | class function_output_iterator 23 | { 24 | private: 25 | class output_proxy 26 | { 27 | public: 28 | explicit output_proxy(UnaryFunction& f) noexcept : 29 | m_f(f) 30 | {} 31 | 32 | template< typename T > 33 | typename std::enable_if< 34 | !std::is_same< typename std::remove_cv< typename std::remove_reference< T >::type >::type, output_proxy >::value, 35 | output_proxy const& 36 | >::type operator=(T&& value) const 37 | { 38 | m_f(static_cast< T&& >(value)); 39 | return *this; 40 | } 41 | 42 | output_proxy(output_proxy const& that) = default; 43 | output_proxy& operator=(output_proxy const&) = delete; 44 | 45 | private: 46 | UnaryFunction& m_f; 47 | }; 48 | 49 | public: 50 | using iterator_category = std::output_iterator_tag; 51 | using value_type = void; 52 | using difference_type = std::ptrdiff_t; 53 | using pointer = void; 54 | using reference = void; 55 | 56 | template< 57 | bool Requires = std::is_class< UnaryFunction >::value, 58 | typename = typename std::enable_if< Requires >::type 59 | > 60 | function_output_iterator() : 61 | m_f() 62 | {} 63 | 64 | explicit function_output_iterator(UnaryFunction const& f) : 65 | m_f(f) 66 | {} 67 | 68 | output_proxy operator*() { return output_proxy(m_f); } 69 | function_output_iterator& operator++() { return *this; } 70 | function_output_iterator& operator++(int) { return *this; } 71 | 72 | private: 73 | UnaryFunction m_f; 74 | }; 75 | 76 | template< typename UnaryFunction > 77 | inline function_output_iterator< UnaryFunction > make_function_output_iterator(UnaryFunction const& f = UnaryFunction()) 78 | { 79 | return function_output_iterator< UnaryFunction >(f); 80 | } 81 | 82 | } // namespace iterators 83 | 84 | using iterators::function_output_iterator; 85 | using iterators::make_function_output_iterator; 86 | 87 | } // namespace boost 88 | 89 | #endif // BOOST_ITERATOR_FUNCTION_OUTPUT_ITERATOR_HPP_INCLUDED_ 90 | -------------------------------------------------------------------------------- /include/boost/iterator/generator_iterator.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Jens Maurer 2001. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | // 6 | // Revision History: 7 | 8 | // 15 Nov 2001 Jens Maurer 9 | // created. 10 | 11 | // See http://www.boost.org/libs/utility/iterator_adaptors.htm for documentation. 12 | 13 | #ifndef BOOST_ITERATOR_GENERATOR_ITERATOR_HPP_INCLUDED_ 14 | #define BOOST_ITERATOR_GENERATOR_ITERATOR_HPP_INCLUDED_ 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | namespace boost { 23 | namespace iterators { 24 | 25 | template< typename Generator > 26 | class generator_iterator : 27 | public iterator_facade< 28 | generator_iterator< Generator >, 29 | decltype(std::declval< Generator& >()()), 30 | single_pass_traversal_tag, 31 | decltype(std::declval< Generator& >()()) const& 32 | > 33 | { 34 | friend class iterator_core_access; 35 | 36 | private: 37 | using super_t = iterator_facade< 38 | generator_iterator< Generator >, 39 | decltype(std::declval< Generator& >()()), 40 | single_pass_traversal_tag, 41 | decltype(std::declval< Generator& >()()) const& 42 | >; 43 | 44 | public: 45 | generator_iterator() : 46 | m_g(nullptr), 47 | m_value() 48 | {} 49 | 50 | generator_iterator(Generator* g) : 51 | m_g(g), 52 | m_value((*m_g)()) 53 | {} 54 | 55 | private: 56 | void increment() 57 | { 58 | m_value = (*m_g)(); 59 | } 60 | 61 | typename super_t::reference dereference() const 62 | { 63 | return m_value; 64 | } 65 | 66 | bool equal(generator_iterator const& y) const 67 | { 68 | return m_g == y.m_g && m_value == y.m_value; 69 | } 70 | 71 | private: 72 | Generator* m_g; 73 | typename Generator::result_type m_value; 74 | }; 75 | 76 | template< typename Generator > 77 | struct generator_iterator_generator 78 | { 79 | using type = generator_iterator< Generator >; 80 | }; 81 | 82 | template< typename Generator > 83 | inline generator_iterator< Generator > make_generator_iterator(Generator& gen) 84 | { 85 | return generator_iterator< Generator >(std::addressof(gen)); 86 | } 87 | 88 | } // namespace iterators 89 | 90 | using iterators::generator_iterator; 91 | using iterators::generator_iterator_generator; 92 | using iterators::make_generator_iterator; 93 | 94 | } // namespace boost 95 | 96 | #endif // BOOST_ITERATOR_GENERATOR_ITERATOR_HPP_INCLUDED_ 97 | -------------------------------------------------------------------------------- /include/boost/iterator/interoperable.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright David Abrahams 2002. 2 | // (C) Copyright Jeremy Siek 2002. 3 | // (C) Copyright Thomas Witt 2002. 4 | // Distributed under the Boost Software License, Version 1.0. (See 5 | // accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | #ifndef BOOST_INTEROPERABLE_23022003THW_HPP 8 | #define BOOST_INTEROPERABLE_23022003THW_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace boost { 14 | namespace iterators { 15 | 16 | // 17 | // Meta function that determines whether two 18 | // iterator types are considered interoperable. 19 | // 20 | // Two iterator types A,B are considered interoperable if either 21 | // A is convertible to B or vice versa. 22 | // This interoperability definition is in sync with the 23 | // standards requirements on constant/mutable container 24 | // iterators (23.1 [lib.container.requirements]). 25 | // 26 | // For compilers that don't support is_convertible 27 | // is_interoperable gives false positives. See comments 28 | // on operator implementation for consequences. 29 | // 30 | template< typename A, typename B > 31 | struct is_interoperable : 32 | public detail::disjunction< std::is_convertible< A, B >, std::is_convertible< B, A > > 33 | { 34 | }; 35 | 36 | } // namespace iterators 37 | 38 | using iterators::is_interoperable; 39 | 40 | } // namespace boost 41 | 42 | #endif // BOOST_INTEROPERABLE_23022003THW_HPP 43 | -------------------------------------------------------------------------------- /include/boost/iterator/is_lvalue_iterator.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2003. Use, modification and distribution is 2 | // subject to the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | #ifndef IS_LVALUE_ITERATOR_DWA2003112_HPP 5 | #define IS_LVALUE_ITERATOR_DWA2003112_HPP 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | namespace boost { 13 | namespace iterators { 14 | namespace detail { 15 | 16 | // Guts of is_lvalue_iterator. It is the iterator type and 17 | // Value is the iterator's value_type. 18 | template< typename It, typename Value > 19 | struct is_lvalue_iterator_impl : 20 | public detail::conjunction< 21 | std::is_convertible< decltype(*std::declval< It& >()), typename std::add_lvalue_reference< Value >::type >, 22 | std::is_lvalue_reference< decltype(*std::declval< It& >()) > 23 | >::type 24 | { 25 | }; 26 | 27 | // 28 | // void specializations to handle std input and output iterators 29 | // 30 | template< typename It > 31 | struct is_lvalue_iterator_impl< It, void > : 32 | public std::false_type 33 | { 34 | }; 35 | 36 | template< typename It > 37 | struct is_lvalue_iterator_impl< It, const void > : 38 | public std::false_type 39 | { 40 | }; 41 | 42 | template< typename It > 43 | struct is_lvalue_iterator_impl< It, volatile void > : 44 | public std::false_type 45 | { 46 | }; 47 | 48 | template< typename It > 49 | struct is_lvalue_iterator_impl< It, const volatile void > : 50 | public std::false_type 51 | { 52 | }; 53 | 54 | } // namespace detail 55 | 56 | template< typename T > 57 | struct is_lvalue_iterator : 58 | public iterators::detail::is_lvalue_iterator_impl< 59 | T, 60 | typename std::iterator_traits< T >::value_type const 61 | >::type 62 | { 63 | }; 64 | 65 | template< typename T > 66 | struct is_non_const_lvalue_iterator : 67 | public iterators::detail::is_lvalue_iterator_impl< 68 | T, 69 | typename std::iterator_traits< T >::value_type 70 | >::type 71 | { 72 | }; 73 | 74 | } // namespace iterators 75 | 76 | using iterators::is_lvalue_iterator; 77 | using iterators::is_non_const_lvalue_iterator; 78 | 79 | } // namespace boost 80 | 81 | #endif // IS_LVALUE_ITERATOR_DWA2003112_HPP 82 | -------------------------------------------------------------------------------- /include/boost/iterator/is_readable_iterator.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2003. Use, modification and distribution is 2 | // subject to the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | #ifndef IS_READABLE_ITERATOR_DWA2003112_HPP 5 | #define IS_READABLE_ITERATOR_DWA2003112_HPP 6 | 7 | #include 8 | #include 9 | 10 | namespace boost { 11 | namespace iterators { 12 | namespace detail { 13 | 14 | // Guts of is_readable_iterator. It is the iterator type and 15 | // Value is the iterator's value_type. 16 | template< typename It, typename Value > 17 | struct is_readable_iterator_impl : 18 | public std::is_convertible< 19 | decltype(*std::declval< It& >()), 20 | typename std::add_lvalue_reference< Value >::type 21 | > 22 | { 23 | }; 24 | 25 | // 26 | // void specializations to handle std input and output iterators 27 | // 28 | template< typename It > 29 | struct is_readable_iterator_impl< It, void > : 30 | public std::false_type 31 | { 32 | }; 33 | 34 | template< typename It > 35 | struct is_readable_iterator_impl< It, const void > : 36 | public std::false_type 37 | { 38 | }; 39 | 40 | template< typename It > 41 | struct is_readable_iterator_impl< It, volatile void > : 42 | public std::false_type 43 | { 44 | }; 45 | 46 | template< typename It > 47 | struct is_readable_iterator_impl< It, const volatile void > : 48 | public std::false_type 49 | { 50 | }; 51 | 52 | } // namespace detail 53 | 54 | template< typename T > 55 | struct is_readable_iterator : 56 | public iterators::detail::is_readable_iterator_impl< 57 | T, 58 | typename std::iterator_traits< T >::value_type const 59 | >::type 60 | { 61 | }; 62 | 63 | } // namespace iterators 64 | 65 | using iterators::is_readable_iterator; 66 | 67 | } // namespace boost 68 | 69 | #endif // IS_READABLE_ITERATOR_DWA2003112_HPP 70 | -------------------------------------------------------------------------------- /include/boost/iterator/iterator_traits.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2003. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | #ifndef ITERATOR_TRAITS_DWA200347_HPP 6 | #define ITERATOR_TRAITS_DWA200347_HPP 7 | 8 | #include 9 | 10 | namespace boost { 11 | namespace iterators { 12 | 13 | template< typename Iterator > 14 | using iterator_value_t = typename std::iterator_traits< Iterator >::value_type; 15 | 16 | template< typename Iterator > 17 | struct iterator_value 18 | { 19 | using type = iterator_value_t< Iterator >; 20 | }; 21 | 22 | template< typename Iterator > 23 | using iterator_reference_t = typename std::iterator_traits< Iterator >::reference; 24 | 25 | template< typename Iterator > 26 | struct iterator_reference 27 | { 28 | using type = iterator_reference_t< Iterator >; 29 | }; 30 | 31 | template< typename Iterator > 32 | using iterator_pointer_t = typename std::iterator_traits< Iterator >::pointer; 33 | 34 | template< typename Iterator > 35 | struct iterator_pointer 36 | { 37 | using type = iterator_pointer_t< Iterator >; 38 | }; 39 | 40 | template< typename Iterator > 41 | using iterator_difference_t = typename std::iterator_traits< Iterator >::difference_type; 42 | 43 | template< typename Iterator > 44 | struct iterator_difference 45 | { 46 | using type = iterator_difference_t< Iterator >; 47 | }; 48 | 49 | template< typename Iterator > 50 | using iterator_category_t = typename std::iterator_traits< Iterator >::iterator_category; 51 | 52 | template< typename Iterator > 53 | struct iterator_category 54 | { 55 | using type = iterator_category_t< Iterator >; 56 | }; 57 | 58 | } // namespace iterators 59 | 60 | using iterators::iterator_value; 61 | using iterators::iterator_reference; 62 | using iterators::iterator_pointer; 63 | using iterators::iterator_difference; 64 | using iterators::iterator_category; 65 | 66 | } // namespace boost 67 | 68 | #endif // ITERATOR_TRAITS_DWA200347_HPP 69 | -------------------------------------------------------------------------------- /include/boost/iterator/min_category.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Andrey Semashev 2025. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_ITERATOR_MIN_CATEGORY_HPP_INCLUDED_ 8 | #define BOOST_ITERATOR_MIN_CATEGORY_HPP_INCLUDED_ 9 | 10 | #include 11 | 12 | namespace boost { 13 | namespace iterators { 14 | namespace detail { 15 | 16 | template< 17 | typename T1, 18 | typename T2, 19 | bool GreaterEqual = std::is_convertible< T1, T2 >::value, 20 | bool LessEqual = std::is_convertible< T2, T1 >::value 21 | > 22 | struct min_category_impl 23 | { 24 | static_assert(GreaterEqual || LessEqual, "Iterator category types must be related through convertibility."); 25 | }; 26 | 27 | template< typename T1, typename T2 > 28 | struct min_category_impl< T1, T2, true, false > 29 | { 30 | using type = T2; 31 | }; 32 | 33 | template< typename T1, typename T2 > 34 | struct min_category_impl< T1, T2, false, true > 35 | { 36 | using type = T1; 37 | }; 38 | 39 | template< typename T1, typename T2 > 40 | struct min_category_impl< T1, T2, true, true > 41 | { 42 | static_assert(std::is_same< T1, T2 >::value, "Iterator category types must be the same when they are equivalent."); 43 | using type = T1; 44 | }; 45 | 46 | } // namespace detail 47 | 48 | // 49 | // Returns the minimum iterator category type in the list 50 | // or fails to compile if any of the categories are unrelated. 51 | // 52 | template< typename... Categories > 53 | struct min_category; 54 | 55 | template< typename T > 56 | struct min_category< T > 57 | { 58 | using type = T; 59 | }; 60 | 61 | template< typename T1, typename T2, typename... Tail > 62 | struct min_category< T1, T2, Tail... > 63 | { 64 | using type = typename min_category< 65 | typename iterators::detail::min_category_impl< T1, T2 >::type, 66 | Tail... 67 | >::type; 68 | }; 69 | 70 | // Shortcut to slightly optimize compilation speed 71 | template< typename T1, typename T2 > 72 | struct min_category< T1, T2 > 73 | { 74 | using type = typename iterators::detail::min_category_impl< T1, T2 >::type; 75 | }; 76 | 77 | template< typename... Categories > 78 | using min_category_t = typename min_category< Categories... >::type; 79 | 80 | } // namespace iterators 81 | } // namespace boost 82 | 83 | #endif // BOOST_ITERATOR_MIN_CATEGORY_HPP_INCLUDED_ 84 | -------------------------------------------------------------------------------- /include/boost/iterator/minimum_category.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2003. Use, modification and distribution is 2 | // subject to the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | #ifndef BOOST_ITERATOR_MINIMUM_CATEGORY_HPP_INCLUDED_ 5 | #define BOOST_ITERATOR_MINIMUM_CATEGORY_HPP_INCLUDED_ 6 | 7 | #include 8 | #include 9 | 10 | namespace boost { 11 | namespace iterators { 12 | 13 | // Deprecated metafunction for selecting minimum iterator category, 14 | // use min_category instead. 15 | template< class T1 = mpl::arg<1>, class T2 = mpl::arg<2> > 16 | struct minimum_category : 17 | public min_category 18 | { 19 | }; 20 | 21 | template <> 22 | struct minimum_category< mpl::arg<1>, mpl::arg<2> > 23 | { 24 | template 25 | struct apply : 26 | public min_category 27 | {}; 28 | }; 29 | 30 | } // namespace iterators 31 | } // namespace boost 32 | 33 | #endif // BOOST_ITERATOR_MINIMUM_CATEGORY_HPP_INCLUDED_ 34 | -------------------------------------------------------------------------------- /include/boost/iterator/reverse_iterator.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright David Abrahams 2002. 2 | // (C) Copyright Jeremy Siek 2002. 3 | // (C) Copyright Thomas Witt 2002. 4 | // Distributed under the Boost Software License, Version 1.0. (See 5 | // accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt) 7 | #ifndef BOOST_ITERATOR_REVERSE_ITERATOR_23022003THW_HPP 8 | #define BOOST_ITERATOR_REVERSE_ITERATOR_23022003THW_HPP 9 | 10 | #include 11 | #include 12 | 13 | namespace boost { 14 | namespace iterators { 15 | 16 | template< typename Iterator > 17 | class reverse_iterator : 18 | public iterator_adaptor< reverse_iterator< Iterator >, Iterator > 19 | { 20 | friend class iterator_core_access; 21 | 22 | private: 23 | using super_t = iterator_adaptor< reverse_iterator< Iterator >, Iterator >; 24 | 25 | public: 26 | reverse_iterator() = default; 27 | 28 | explicit reverse_iterator(Iterator x) : 29 | super_t(x) 30 | {} 31 | 32 | template< 33 | typename OtherIterator, 34 | typename = enable_if_convertible_t< OtherIterator, Iterator > 35 | > 36 | reverse_iterator(reverse_iterator< OtherIterator > const& r) : 37 | super_t(r.base()) 38 | {} 39 | 40 | private: 41 | typename super_t::reference dereference() const 42 | { 43 | Iterator it = this->base_reference(); 44 | --it; 45 | return *it; 46 | } 47 | 48 | void increment() { --this->base_reference(); } 49 | void decrement() { ++this->base_reference(); } 50 | 51 | void advance(typename super_t::difference_type n) 52 | { 53 | this->base_reference() -= n; 54 | } 55 | 56 | template< typename OtherIterator > 57 | typename super_t::difference_type distance_to(reverse_iterator< OtherIterator > const& y) const 58 | { 59 | return this->base_reference() - y.base(); 60 | } 61 | }; 62 | 63 | template< typename Iterator > 64 | inline reverse_iterator< Iterator > make_reverse_iterator(Iterator x) 65 | { 66 | return reverse_iterator< Iterator >(x); 67 | } 68 | 69 | } // namespace iterators 70 | 71 | using iterators::reverse_iterator; 72 | using iterators::make_reverse_iterator; 73 | 74 | } // namespace boost 75 | 76 | #endif // BOOST_ITERATOR_REVERSE_ITERATOR_23022003THW_HPP 77 | -------------------------------------------------------------------------------- /include/boost/iterator_adaptors.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2004. Distributed under the Boost 2 | // Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | // See www.boost.org/libs/iterator for documentation. 6 | 7 | #ifndef ITERATOR_ADAPTORS_DWA2004725_HPP 8 | # define ITERATOR_ADAPTORS_DWA2004725_HPP 9 | 10 | #define BOOST_ITERATOR_ADAPTORS_VERSION 0x0200 11 | #include 12 | 13 | #endif // ITERATOR_ADAPTORS_DWA2004725_HPP 14 | -------------------------------------------------------------------------------- /include/boost/pending/iterator_adaptors.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2003. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | -------------------------------------------------------------------------------- /include/boost/pointee.hpp: -------------------------------------------------------------------------------- 1 | #ifndef BOOST_POINTEE_DWA200415_HPP 2 | #define BOOST_POINTEE_DWA200415_HPP 3 | 4 | // 5 | // Copyright David Abrahams 2004. Use, modification and distribution is 6 | // subject to the Boost Software License, Version 1.0. (See accompanying 7 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | // 9 | // typename pointee

::type provides the pointee type of P. 10 | // 11 | // For example, it is T for T* and X for shared_ptr. 12 | // 13 | // http://www.boost.org/libs/iterator/doc/pointee.html 14 | // 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | namespace boost { 22 | namespace detail { 23 | 24 | template< typename P > 25 | struct smart_ptr_pointee 26 | { 27 | using type = typename P::element_type; 28 | }; 29 | 30 | template< 31 | typename Iterator, 32 | typename = typename std::remove_reference< decltype(*std::declval< Iterator& >()) >::type 33 | > 34 | struct iterator_pointee 35 | { 36 | using type = typename std::iterator_traits< Iterator >::value_type; 37 | }; 38 | 39 | template< typename Iterator, typename Reference > 40 | struct iterator_pointee< Iterator, const Reference > 41 | { 42 | using type = typename std::add_const< typename std::iterator_traits< Iterator >::value_type >::type; 43 | }; 44 | 45 | } // namespace detail 46 | 47 | template< typename P > 48 | struct pointee : 49 | public std::conditional< 50 | detail::is_incrementable< P >::value, 51 | detail::iterator_pointee< P >, 52 | detail::smart_ptr_pointee< P > 53 | >::type 54 | { 55 | }; 56 | 57 | template< typename P > 58 | using pointee_t = typename pointee< P >::type; 59 | 60 | } // namespace boost 61 | 62 | #endif // BOOST_POINTEE_DWA200415_HPP 63 | -------------------------------------------------------------------------------- /include/boost/shared_container_iterator.hpp: -------------------------------------------------------------------------------- 1 | // (C) Copyright Andrey Semashev 2025. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_SHARED_CONTAINER_ITERATOR_HPP 7 | #define BOOST_SHARED_CONTAINER_ITERATOR_HPP 8 | 9 | // This is a deprecated header left for backward compatibility. 10 | // Please use instead. 11 | 12 | #include 13 | 14 | #endif // BOOST_SHARED_CONTAINER_ITERATOR_HPP 15 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Automatically loading index page... if nothing happens, please go to 7 | doc/index.html. 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /meta/libraries.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "iterator", 3 | "name": "Iterator", 4 | "authors": [ 5 | "Dave Abrahams", 6 | "Jeremy Siek", 7 | "Thomas Witt" 8 | ], 9 | "description": "The Boost Iterator Library contains two parts. The first is a system of concepts which extend the C++ standard iterator requirements. The second is a framework of components for building iterators based on these extended concepts and includes several useful iterator adaptors.", 10 | "category": [ 11 | "Iterators" 12 | ], 13 | "maintainers": [ 14 | "David Abrahams ", 15 | "Thomas Witt ", 16 | "Jeffrey Lee Hellrung Jr. " 17 | ], 18 | "cxxstd": "03" 19 | } 20 | -------------------------------------------------------------------------------- /test/adl_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Michel Morin. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main() 13 | { 14 | // Test that boost::advance/distance are not found by ADL. 15 | // (https://github.com/boostorg/iterator/issues/43) 16 | 17 | typedef boost::array boost_type; 18 | std::vector std_boost(2); 19 | std::vector::iterator it = std_boost.begin(); 20 | 21 | advance(it, 2); 22 | (void)distance(it, it); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /test/advance_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Michel Morin. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | int twice(int x) { return x + x; } 15 | 16 | template 17 | void test_advance(Iterator it_from, Iterator it_to, int n) 18 | { 19 | boost::advance(it_from, n); 20 | BOOST_TEST(it_from == it_to); 21 | } 22 | 23 | int main() 24 | { 25 | int array[3] = {1, 2, 3}; 26 | int* ptr1 = array; 27 | int* ptr2 = array + 3; 28 | 29 | { 30 | test_advance(ptr1, ptr2, 3); 31 | test_advance(ptr2, ptr1, -3); 32 | 33 | test_advance( 34 | boost::make_transform_iterator(ptr1, twice) 35 | , boost::make_transform_iterator(ptr2, twice) 36 | , 3 37 | ); 38 | test_advance( 39 | boost::make_transform_iterator(ptr2, twice) 40 | , boost::make_transform_iterator(ptr1, twice) 41 | , -3 42 | ); 43 | } 44 | 45 | { 46 | std::vector ints(ptr1, ptr2); 47 | test_advance(ints.begin(), ints.end(), 3); 48 | test_advance(ints.end(), ints.begin(), -3); 49 | 50 | test_advance( 51 | boost::make_transform_iterator(ints.begin(), twice) 52 | , boost::make_transform_iterator(ints.end(), twice) 53 | , 3 54 | ); 55 | test_advance( 56 | boost::make_transform_iterator(ints.end(), twice) 57 | , boost::make_transform_iterator(ints.begin(), twice) 58 | , -3 59 | ); 60 | } 61 | 62 | { 63 | std::list ints(ptr1, ptr2); 64 | test_advance(ints.begin(), ints.end(), 3); 65 | test_advance(ints.end(), ints.begin(), -3); 66 | 67 | test_advance( 68 | boost::make_transform_iterator(ints.begin(), twice) 69 | , boost::make_transform_iterator(ints.end(), twice) 70 | , 3 71 | ); 72 | test_advance( 73 | boost::make_transform_iterator(ints.end(), twice) 74 | , boost::make_transform_iterator(ints.begin(), twice) 75 | , -3 76 | ); 77 | } 78 | 79 | { 80 | boost::container::slist ints(ptr1, ptr2); 81 | test_advance(ints.begin(), ints.end(), 3); 82 | 83 | test_advance( 84 | boost::make_transform_iterator(ints.begin(), twice) 85 | , boost::make_transform_iterator(ints.end(), twice) 86 | , 3 87 | ); 88 | } 89 | 90 | return boost::report_errors(); 91 | } 92 | -------------------------------------------------------------------------------- /test/constant_iter_arrow.cpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2004. Distributed under the Boost 2 | // Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | #include 7 | 8 | struct my_iter : boost::iterator_adaptor const*> 9 | { 10 | my_iter(std::pair const*); 11 | my_iter(); 12 | }; 13 | 14 | std::pair const x(1,1); 15 | my_iter p(&x); 16 | int y = p->first; // operator-> attempts to return an non-const pointer 17 | -------------------------------------------------------------------------------- /test/constant_iter_arrow_fail.cpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2004. Distributed under the Boost 2 | // Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | #include 7 | 8 | struct my_iter : boost::iterator_adaptor const*> 9 | { 10 | my_iter(std::pair const*); 11 | my_iter(); 12 | }; 13 | 14 | std::pair const x(1,1); 15 | my_iter p(&x); 16 | 17 | void test() 18 | { 19 | p->first = 3; 20 | } 21 | -------------------------------------------------------------------------------- /test/distance_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 Michel Morin. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | int twice(int x) { return x + x; } 15 | 16 | template 17 | void test_distance(Iterator it_from, Iterator it_to, int n) 18 | { 19 | BOOST_TEST(boost::distance(it_from, it_to) == n); 20 | } 21 | 22 | int main() 23 | { 24 | int array[3] = {1, 2, 3}; 25 | int* ptr1 = array; 26 | int* ptr2 = array + 3; 27 | 28 | { 29 | test_distance(ptr1, ptr2, 3); 30 | test_distance(ptr2, ptr1, -3); 31 | 32 | test_distance( 33 | boost::make_transform_iterator(ptr1, twice) 34 | , boost::make_transform_iterator(ptr2, twice) 35 | , 3 36 | ); 37 | test_distance( 38 | boost::make_transform_iterator(ptr2, twice) 39 | , boost::make_transform_iterator(ptr1, twice) 40 | , -3 41 | ); 42 | } 43 | 44 | { 45 | std::vector ints(ptr1, ptr2); 46 | test_distance(ints.begin(), ints.end(), 3); 47 | test_distance(ints.end(), ints.begin(), -3); 48 | 49 | test_distance( 50 | boost::make_transform_iterator(ints.begin(), twice) 51 | , boost::make_transform_iterator(ints.end(), twice) 52 | , 3 53 | ); 54 | test_distance( 55 | boost::make_transform_iterator(ints.end(), twice) 56 | , boost::make_transform_iterator(ints.begin(), twice) 57 | , -3 58 | ); 59 | } 60 | 61 | { 62 | std::list ints(ptr1, ptr2); 63 | test_distance(ints.begin(), ints.end(), 3); 64 | 65 | test_distance( 66 | boost::make_transform_iterator(ints.begin(), twice) 67 | , boost::make_transform_iterator(ints.end(), twice) 68 | , 3 69 | ); 70 | } 71 | 72 | { 73 | boost::container::slist ints(ptr1, ptr2); 74 | test_distance(ints.begin(), ints.end(), 3); 75 | 76 | test_distance( 77 | boost::make_transform_iterator(ints.begin(), twice) 78 | , boost::make_transform_iterator(ints.end(), twice) 79 | , 3 80 | ); 81 | } 82 | 83 | return boost::report_errors(); 84 | } 85 | -------------------------------------------------------------------------------- /test/function_output_iterator_cf.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2022 (c) Andrey Semashev 2 | // Distributed under the Boost Software License Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | 8 | namespace { 9 | 10 | struct sum_func 11 | { 12 | typedef void result_type; 13 | 14 | explicit sum_func(int& n) : m_n(n) {} 15 | result_type operator() (int x) const 16 | { 17 | m_n += x; 18 | } 19 | 20 | private: 21 | int& m_n; 22 | }; 23 | 24 | } // namespace 25 | 26 | int main() 27 | { 28 | int n = 0; 29 | boost::iterators::function_output_iterator< sum_func > it1 = 30 | boost::iterators::make_function_output_iterator(sum_func(n)); 31 | boost::iterators::function_output_iterator< sum_func > it2 = 32 | boost::iterators::make_function_output_iterator(sum_func(n)); 33 | 34 | *it1 = *it2; 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /test/function_output_iterator_def_ctor_cf.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2025 (c) Andrey Semashev 2 | // Distributed under the Boost Software License Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | 8 | int main() 9 | { 10 | boost::iterators::function_output_iterator< void (*)(int) > it; 11 | (void)it; 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /test/function_output_iterator_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2022 (c) Andrey Semashev 2 | // Distributed under the Boost Software License Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | namespace { 14 | 15 | struct sum_func 16 | { 17 | typedef void result_type; 18 | 19 | explicit sum_func(int& n) : m_n(n) {} 20 | result_type operator() (int x) const 21 | { 22 | m_n += x; 23 | } 24 | 25 | private: 26 | int& m_n; 27 | }; 28 | 29 | } // namespace 30 | 31 | int main() 32 | { 33 | { 34 | int n = 0; 35 | boost::iterators::function_output_iterator< sum_func > it = 36 | boost::iterators::make_function_output_iterator(sum_func(n)); 37 | 38 | *it = 1; 39 | ++it; 40 | *it = 2; 41 | ++it; 42 | *it = 3; 43 | 44 | BOOST_TEST_EQ(n, 6); 45 | } 46 | 47 | { 48 | int n = 0; 49 | auto it = boost::iterators::make_function_output_iterator([&n](int x) { n -= x; }); 50 | 51 | *it = 1; 52 | ++it; 53 | *it = 2; 54 | ++it; 55 | *it = 3; 56 | 57 | BOOST_TEST_EQ(n, -6); 58 | } 59 | 60 | #if defined(__cpp_lib_concepts) && ( __cpp_lib_concepts >= 202002L ) 61 | { 62 | auto func = [](int) {}; 63 | static_assert(std::output_iterator< boost::iterators::function_output_iterator< decltype(func) >, int >); 64 | } 65 | #endif 66 | 67 | return boost::report_errors(); 68 | } 69 | -------------------------------------------------------------------------------- /test/generator_iterator_test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2014 Peter Dimov 3 | // 4 | // Distributed under the Boost Software License, Version 1.0. 5 | // See accompanying file LICENSE_1_0.txt or copy at 6 | // http://www.boost.org/LICENSE_1_0.txt 7 | // 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | class X 14 | { 15 | private: 16 | 17 | int v; 18 | 19 | public: 20 | 21 | typedef int result_type; 22 | 23 | X(): v( 0 ) 24 | { 25 | } 26 | 27 | int operator()() 28 | { 29 | return ++v; 30 | } 31 | }; 32 | 33 | template OutputIterator copy_n( InputIterator first, Size n, OutputIterator result ) 34 | { 35 | while( n-- > 0 ) 36 | { 37 | *result++ = *first++; 38 | } 39 | 40 | return result; 41 | } 42 | 43 | void copy_test() 44 | { 45 | X x; 46 | boost::generator_iterator in( &x ); 47 | 48 | int const N = 4; 49 | int v[ N ] = { 0 }; 50 | 51 | ::copy_n( in, 4, v ); 52 | 53 | BOOST_TEST_EQ( v[0], 1 ); 54 | BOOST_TEST_EQ( v[1], 2 ); 55 | BOOST_TEST_EQ( v[2], 3 ); 56 | BOOST_TEST_EQ( v[3], 4 ); 57 | } 58 | 59 | int main() 60 | { 61 | copy_test(); 62 | return boost::report_errors(); 63 | } 64 | -------------------------------------------------------------------------------- /test/interoperable.cpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2004. Use, modification and distribution is 2 | // subject to the Boost Software License, Version 1.0. (See accompanying 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | struct mutable_it : boost::iterator_adaptor 11 | { 12 | typedef boost::iterator_adaptor super_t; 13 | 14 | mutable_it(); 15 | explicit mutable_it(int* p) : super_t(p) {} 16 | 17 | bool equal(mutable_it const& rhs) const 18 | { 19 | return this->base() == rhs.base(); 20 | } 21 | }; 22 | 23 | struct constant_it : boost::iterator_adaptor 24 | { 25 | typedef boost::iterator_adaptor super_t; 26 | 27 | constant_it(); 28 | explicit constant_it(int* p) : super_t(p) {} 29 | constant_it(mutable_it const& x) : super_t(x.base()) {} 30 | 31 | bool equal(constant_it const& rhs) const 32 | { 33 | return this->base() == rhs.base(); 34 | } 35 | }; 36 | 37 | int main() 38 | { 39 | int data[] = { 49, 77 }; 40 | 41 | mutable_it i(data); 42 | constant_it j(data + 1); 43 | BOOST_TEST(i < j); 44 | BOOST_TEST(j > i); 45 | BOOST_TEST(i <= j); 46 | BOOST_TEST(j >= i); 47 | BOOST_TEST(j - i == 1); 48 | BOOST_TEST(i - j == -1); 49 | 50 | constant_it k = i; 51 | 52 | BOOST_TEST(!(i < k)); 53 | BOOST_TEST(!(k > i)); 54 | BOOST_TEST(i <= k); 55 | BOOST_TEST(k >= i); 56 | BOOST_TEST(k - i == 0); 57 | BOOST_TEST(i - k == 0); 58 | 59 | return boost::report_errors(); 60 | } 61 | -------------------------------------------------------------------------------- /test/interoperable_fail.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Thomas Witt 2003. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | int main() 12 | { 13 | { 14 | typedef boost::reverse_iterator::iterator> rev_iter; 15 | typedef boost::indirect_iterator::iterator> ind_iter; 16 | 17 | ind_iter() == rev_iter(); 18 | } 19 | 20 | return boost::exit_success; 21 | } 22 | -------------------------------------------------------------------------------- /test/is_convertible_fail.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Thomas Witt 2002. 3 | // 4 | // Use, modification and distribution is subject to the 5 | // Boost Software License, Version 1.0. 6 | // (See accompanying file LICENSE_1_0.txt or copy at 7 | // http://www.boost.org/LICENSE_1_0.txt) 8 | // 9 | #include 10 | #include 11 | #include 12 | 13 | int main() 14 | { 15 | typedef boost::reverse_iterator rev_iter1; 16 | typedef boost::reverse_iterator rev_iter2; 17 | 18 | return std::is_convertible::value 19 | ? boost::exit_failure : boost::exit_success; 20 | } 21 | -------------------------------------------------------------------------------- /test/iter_archetype_default_ctor.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright Thomas Witt 2004. 3 | // Distributed under the Boost Software License, Version 1.0. (See 4 | // accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | #include 8 | 9 | 10 | int main() 11 | { 12 | typedef boost::iterator_archetype< 13 | int 14 | , boost::iterator_archetypes::readable_iterator_t 15 | , boost::single_pass_traversal_tag 16 | > iter; 17 | 18 | // single_pass_traversal iterators are not required to be 19 | // default constructible 20 | iter it; 21 | } 22 | -------------------------------------------------------------------------------- /test/iterator_adaptor_cc.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2004 Jeremy Siek 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main() 13 | { 14 | { 15 | typedef boost::reverse_iterator rev_iter; 16 | typedef boost::reverse_iterator c_rev_iter; 17 | 18 | boost::function_requires< boost_concepts::WritableIteratorConcept >(); 19 | boost::function_requires< boost_concepts::LvalueIteratorConcept >(); 20 | boost::function_requires< boost_concepts::RandomAccessTraversalConcept >(); 21 | boost::function_requires< boost::RandomAccessIteratorConcept >(); 22 | boost::function_requires< boost_concepts::InteroperableIteratorConcept >(); 23 | } 24 | 25 | // Many compilers' builtin container iterators don't interoperate well, though 26 | // STLport fixes that problem. 27 | #if defined(__SGI_STL_PORT) \ 28 | || !BOOST_WORKAROUND(__GNUC__, <= 2) \ 29 | && !(BOOST_WORKAROUND(__GNUC__, == 3) && BOOST_WORKAROUND(__GNUC_MINOR__, <= 1)) \ 30 | && !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551)) \ 31 | && !BOOST_WORKAROUND(__LIBCOMO_VERSION__, BOOST_TESTED_AT(29)) \ 32 | && !BOOST_WORKAROUND(BOOST_DINKUMWARE_STDLIB, <= 1) 33 | { 34 | typedef boost::reverse_iterator::iterator> rev_iter; 35 | typedef boost::reverse_iterator::const_iterator> c_rev_iter; 36 | 37 | boost::function_requires< boost_concepts::ReadableIteratorConcept >(); 38 | boost::function_requires< boost_concepts::LvalueIteratorConcept >(); 39 | boost::function_requires< boost_concepts::BidirectionalTraversalConcept >(); 40 | boost::function_requires< boost::BidirectionalIteratorConcept >(); 41 | boost::function_requires< boost_concepts::InteroperableIteratorConcept >(); 42 | } 43 | #endif 44 | 45 | return boost::exit_success; 46 | } 47 | -------------------------------------------------------------------------------- /test/iterator_archetype_cc.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright Thomas Witt 2003. 3 | // Distributed under the Boost Software License, Version 1.0. (See 4 | // accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | int main() 14 | { 15 | { 16 | typedef boost::iterator_archetype< 17 | int 18 | , boost::iterator_archetypes::readable_iterator_t 19 | , boost::random_access_traversal_tag 20 | > iter; 21 | 22 | boost::function_requires< boost_concepts::ReadableIteratorConcept >(); 23 | boost::function_requires< boost_concepts::RandomAccessTraversalConcept >(); 24 | } 25 | { 26 | typedef boost::iterator_archetype< 27 | int 28 | , boost::iterator_archetypes::readable_writable_iterator_t 29 | , boost::random_access_traversal_tag 30 | > iter; 31 | 32 | boost::function_requires< boost_concepts::ReadableIteratorConcept >(); 33 | boost::function_requires< boost_concepts::WritableIteratorConcept >(); 34 | boost::function_requires< boost_concepts::RandomAccessTraversalConcept >(); 35 | } 36 | { 37 | typedef boost::iterator_archetype< 38 | const int // I don't like adding const to Value. It is redundant. -JGS 39 | , boost::iterator_archetypes::readable_lvalue_iterator_t 40 | , boost::random_access_traversal_tag 41 | > iter; 42 | 43 | boost::function_requires< boost_concepts::ReadableIteratorConcept >(); 44 | boost::function_requires< boost_concepts::LvalueIteratorConcept >(); 45 | boost::function_requires< boost_concepts::RandomAccessTraversalConcept >(); 46 | } 47 | { 48 | typedef boost::iterator_archetype< 49 | int 50 | , boost::iterator_archetypes::writable_lvalue_iterator_t 51 | , boost::random_access_traversal_tag 52 | > iter; 53 | 54 | boost::function_requires< boost_concepts::WritableIteratorConcept >(); 55 | boost::function_requires< boost_concepts::LvalueIteratorConcept >(); 56 | boost::function_requires< boost_concepts::RandomAccessTraversalConcept >(); 57 | } 58 | 59 | return boost::exit_success; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /test/lvalue_concept_fail.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2004 Jeremy Siek 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | int main() 11 | { 12 | typedef boost::iterator_archetype< 13 | int 14 | , boost::iterator_archetypes::readable_iterator_t 15 | , boost::single_pass_traversal_tag 16 | > Iter; 17 | boost::function_requires< 18 | boost_concepts::LvalueIteratorConcept >(); 19 | return boost::exit_success; 20 | } 21 | -------------------------------------------------------------------------------- /test/min_category.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Andrey Semashev 2025. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | using std::is_same; 13 | using boost::iterators::min_category; 14 | using boost::iterators::min_category_t; 15 | 16 | int main(int, char*[]) 17 | { 18 | BOOST_TEST_TRAIT_TRUE((is_same::type, std::forward_iterator_tag>)); 19 | BOOST_TEST_TRAIT_TRUE((is_same::type, std::forward_iterator_tag>)); 20 | BOOST_TEST_TRAIT_TRUE((is_same::type, std::forward_iterator_tag>)); 21 | BOOST_TEST_TRAIT_TRUE((is_same::type, std::random_access_iterator_tag>)); 22 | BOOST_TEST_TRAIT_TRUE((is_same::type, std::forward_iterator_tag>)); 23 | BOOST_TEST_TRAIT_TRUE((is_same::type, std::forward_iterator_tag>)); 24 | 25 | BOOST_TEST_TRAIT_TRUE((is_same, std::forward_iterator_tag>)); 26 | BOOST_TEST_TRAIT_TRUE((is_same, std::forward_iterator_tag>)); 27 | BOOST_TEST_TRAIT_TRUE((is_same, std::forward_iterator_tag>)); 28 | BOOST_TEST_TRAIT_TRUE((is_same, std::random_access_iterator_tag>)); 29 | BOOST_TEST_TRAIT_TRUE((is_same, std::forward_iterator_tag>)); 30 | BOOST_TEST_TRAIT_TRUE((is_same, std::forward_iterator_tag>)); 31 | 32 | return boost::report_errors(); 33 | } 34 | -------------------------------------------------------------------------------- /test/min_category_compile_fail1.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Andrey Semashev 2025. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #include 8 | 9 | using boost::iterators::min_category; 10 | 11 | struct A {}; 12 | struct B {}; 13 | 14 | int main(int, char*[]) 15 | { 16 | min_category::type cat; 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /test/min_category_compile_fail2.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Andrey Semashev 2025. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #include 8 | 9 | using boost::iterators::min_category; 10 | 11 | int main(int, char*[]) 12 | { 13 | min_category<>::type cat; 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /test/minimum_category.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Andrey Semashev 2014. 2 | // 3 | // Use, modification and distribution is subject to 4 | // the Boost Software License, Version 1.0. (See accompanying 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | using std::is_same; 13 | using boost::iterators::minimum_category; 14 | 15 | int main(int, char*[]) 16 | { 17 | BOOST_TEST_TRAIT_TRUE((is_same::type, std::forward_iterator_tag>)); 18 | BOOST_TEST_TRAIT_TRUE((is_same::type, std::forward_iterator_tag>)); 19 | BOOST_TEST_TRAIT_TRUE((is_same::type, std::random_access_iterator_tag>)); 20 | 21 | return boost::report_errors(); 22 | } 23 | -------------------------------------------------------------------------------- /test/minimum_category_compile_fail.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Andrey Semashev 2014. 2 | // 3 | // Use, modification and distribution is subject to 4 | // the Boost Software License, Version 1.0. (See accompanying 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #include 8 | 9 | using boost::iterators::minimum_category; 10 | 11 | struct A {}; 12 | struct B {}; 13 | 14 | int main(int, char*[]) 15 | { 16 | minimum_category::type cat; 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /test/range_distance_compat_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Andrey Semashev 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | int main() 12 | { 13 | // Test that boost::distance from Boost.Range works with boost::distance from Boost.Iterator 14 | // (https://github.com/boostorg/iterator/commit/b844c8df530c474ec1856870b9b0de5f487b84d4#commitcomment-30603668) 15 | 16 | typedef boost::iterator_range range_type; 17 | range_type range; 18 | 19 | (void)boost::distance(range); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /test/shared_iterator_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2003 The Trustees of Indiana University. 2 | 3 | // Use, modification and distribution is subject to the Boost Software 4 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // Shared container iterator adaptor 8 | // Author: Ronald Garcia 9 | // See http://boost.org/libs/utility/shared_container_iterator.html 10 | // for documentation. 11 | 12 | // 13 | // shared_iterator_test.cpp - Regression tests for shared_container_iterator. 14 | // 15 | 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | struct resource 24 | { 25 | static int count; 26 | resource() { ++count; } 27 | resource(resource const&) { ++count; } 28 | ~resource() { --count; } 29 | }; 30 | int resource::count = 0; 31 | 32 | typedef std::vector< resource > resources_t; 33 | 34 | typedef boost::shared_container_iterator< resources_t > iterator; 35 | 36 | template< typename SharedPtr > 37 | void set_range(iterator& i, iterator& end) 38 | { 39 | SharedPtr objs(new resources_t()); 40 | 41 | for (int j = 0; j != 6; ++j) 42 | objs->push_back(resource()); 43 | 44 | i = iterator(objs->begin(), objs); 45 | end = iterator(objs->end(), objs); 46 | BOOST_TEST_EQ(resource::count, 6); 47 | } 48 | 49 | 50 | int main() { 51 | 52 | BOOST_TEST_EQ(resource::count, 0); 53 | 54 | { 55 | iterator i; 56 | { 57 | iterator end; 58 | set_range< boost::shared_ptr< resources_t > >(i, end); 59 | BOOST_TEST_EQ(resource::count, 6); 60 | } 61 | BOOST_TEST_EQ(resource::count, 6); 62 | } 63 | BOOST_TEST_EQ(resource::count, 0); 64 | 65 | { 66 | iterator i; 67 | { 68 | iterator end; 69 | set_range< std::shared_ptr< resources_t > >(i, end); 70 | BOOST_TEST_EQ(resource::count, 6); 71 | } 72 | BOOST_TEST_EQ(resource::count, 6); 73 | } 74 | BOOST_TEST_EQ(resource::count, 0); 75 | 76 | return boost::report_errors(); 77 | } 78 | -------------------------------------------------------------------------------- /test/static_assert_same.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2003. 2 | // Distributed under the Boost Software License, Version 1.0. (See 3 | // accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | #ifndef STATIC_ASSERT_SAME_DWA2003530_HPP 6 | # define STATIC_ASSERT_SAME_DWA2003530_HPP 7 | 8 | #include 9 | 10 | #define STATIC_ASSERT_SAME( T1,T2 ) static_assert(std::is_same::value, "T1 and T2 are expected to be the same types.") 11 | 12 | template 13 | struct static_assert_same 14 | { 15 | STATIC_ASSERT_SAME(T1, T2); 16 | enum { value = 1 }; 17 | }; 18 | 19 | #endif // STATIC_ASSERT_SAME_DWA2003530_HPP 20 | -------------------------------------------------------------------------------- /test/test_cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Andrey Semashev 2 | # 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt 5 | # 6 | # NOTE: This does NOT run the unit tests for Boost.Atomic. 7 | # It only tests if the CMakeLists.txt file in its root works as expected 8 | 9 | cmake_minimum_required(VERSION 3.5) 10 | 11 | project(BoostIteratorCMakeSelfTest) 12 | 13 | # Use experimental superproject to pull library dependencies recursively 14 | set(BOOST_ENABLE_CMAKE 1) 15 | add_subdirectory(../../../.. "${CMAKE_CURRENT_BINARY_DIR}/boost_superproject") 16 | 17 | add_definitions(-DBOOST_ALL_NO_LIB) 18 | 19 | add_executable(boost_iterator_cmake_self_test main.cpp) 20 | target_link_libraries(boost_iterator_cmake_self_test Boost::iterator) 21 | -------------------------------------------------------------------------------- /test/test_cmake/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 Andrey Semashev 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // See accompanying file LICENSE_1_0.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | template< typename Iterator > 38 | class adapted_iterator : 39 | public boost::iterators::iterator_adaptor< adapted_iterator< Iterator >, Iterator > 40 | { 41 | friend class iterator_core_access; 42 | 43 | private: 44 | typedef boost::iterators::iterator_adaptor< adapted_iterator< Iterator >, Iterator > base_type; 45 | 46 | public: 47 | explicit adapted_iterator(Iterator it) : base_type(it) {} 48 | }; 49 | 50 | int main() 51 | { 52 | unsigned char buf[8]; 53 | adapted_iterator< unsigned char* > b(buf), e(buf + sizeof(buf)); 54 | return boost::iterators::distance(b, e) == static_cast< adapted_iterator< unsigned char* >::difference_type >(sizeof(buf)); 55 | } 56 | -------------------------------------------------------------------------------- /test/zip_iterator_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define ZI_TUPLE boost::tuples::tuple 4 | #define ZI_MAKE_TUPLE boost::make_tuple 5 | #define ZI_TUPLE_GET(n) boost::tuples::get 6 | #define ZI_USE_BOOST_TUPLE 7 | 8 | #include "detail/zip_iterator_test_original.ipp" 9 | -------------------------------------------------------------------------------- /test/zip_iterator_test2_fusion_deque.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define ZI_TUPLE boost::fusion::deque 6 | #define ZI_MAKE_TUPLE boost::fusion::make_deque 7 | #define ZI_TUPLE_GET(n) boost::fusion::at_c 8 | 9 | #include "detail/zip_iterator_test_original.ipp" 10 | -------------------------------------------------------------------------------- /test/zip_iterator_test2_fusion_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #define ZI_TUPLE boost::fusion::list 8 | #define ZI_MAKE_TUPLE boost::fusion::make_list 9 | #define ZI_TUPLE_GET(n) boost::fusion::at_c 10 | 11 | #include "detail/zip_iterator_test_original.ipp" 12 | -------------------------------------------------------------------------------- /test/zip_iterator_test2_fusion_vector.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #define ZI_TUPLE boost::fusion::vector 8 | #define ZI_MAKE_TUPLE boost::fusion::make_vector 9 | #define ZI_TUPLE_GET(n) boost::fusion::at_c 10 | 11 | #include "detail/zip_iterator_test_original.ipp" 12 | -------------------------------------------------------------------------------- /test/zip_iterator_test2_std_tuple.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // libstdc++ from gcc 4.4 has a broken std::tuple that cannot be constructed from a compatible tuple, 4 | // e.g. std::tuple from std::tuple. 5 | #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \ 6 | (!defined(BOOST_LIBSTDCXX_VERSION) || BOOST_LIBSTDCXX_VERSION >= 40500) 7 | 8 | #include 9 | #include 10 | 11 | #define ZI_TUPLE std::tuple 12 | #define ZI_MAKE_TUPLE std::make_tuple 13 | #define ZI_TUPLE_GET(n) std::get 14 | 15 | #include "detail/zip_iterator_test_original.ipp" 16 | 17 | #else 18 | 19 | int main() 20 | { 21 | return 0; 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /test/zip_iterator_test_fusion.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Kohei Takahashi. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. (See 4 | // accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org for most recent version including documentation. 8 | 9 | #include 10 | #include 11 | 12 | #define TUPLE boost::fusion::vector 13 | #define MAKE_TUPLE boost::fusion::make_vector 14 | 15 | #include "detail/zip_iterator_test.ipp" 16 | -------------------------------------------------------------------------------- /test/zip_iterator_test_std_pair.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Kohei Takahashi. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. (See 4 | // accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org for most recent version including documentation. 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #if BOOST_WORKAROUND(BOOST_MSVC, < 1600) 14 | 15 | BOOST_PRAGMA_MESSAGE("Skipping test on msvc-9.0 and below") 16 | int main() {} 17 | 18 | #elif defined(BOOST_GCC) && __cplusplus < 201100 19 | 20 | BOOST_PRAGMA_MESSAGE("Skipping test on g++ in C++03 mode") 21 | int main() {} 22 | 23 | #else 24 | 25 | #include 26 | #include 27 | 28 | #define TUPLE std::pair 29 | #define MAKE_TUPLE std::make_pair 30 | 31 | #include "detail/zip_iterator_test.ipp" 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /test/zip_iterator_test_std_tuple.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Kohei Takahashi. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. (See 4 | // accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | // 7 | // See http://www.boost.org for most recent version including documentation. 8 | 9 | #include 10 | 11 | #if !defined(BOOST_NO_CXX11_HDR_TUPLE) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) 12 | 13 | #include 14 | #include 15 | 16 | #define TUPLE std::tuple 17 | #define MAKE_TUPLE std::make_tuple 18 | 19 | #include "detail/zip_iterator_test.ipp" 20 | 21 | #else 22 | 23 | int main() 24 | { 25 | return 0; 26 | } 27 | 28 | #endif 29 | 30 | --------------------------------------------------------------------------------