mirror of
https://github.com/boostorg/iterator.git
synced 2025-05-09 23:23:54 +00:00
Add documentation for advance and distance
This commit is contained in:
parent
4791425000
commit
e2c927628c
75
doc/advance.rst
Normal file
75
doc/advance.rst
Normal file
@ -0,0 +1,75 @@
|
||||
.. Copyright (C) 2017 Michel Morin.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
=======
|
||||
advance
|
||||
=======
|
||||
|
||||
``boost::iterators::advance`` is an adapted version of ``std::advance`` for
|
||||
the Boost iterator traversal concepts.
|
||||
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
``<boost/iterator/advance.hpp>``
|
||||
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
template <typename Iterator, typename Distance>
|
||||
constexpr void advance(Iterator& it, Distance n);
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Moves ``it`` forward by ``n`` increments
|
||||
(or backward by ``|n|`` decrements if ``n`` is negative).
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
``Iterator`` should model Incrementable Iterator.
|
||||
|
||||
|
||||
Preconditions
|
||||
-------------
|
||||
|
||||
Let ``it``\ :sub:`i` be the iterator obtained by incrementing
|
||||
(or decrementing if ``n`` is negative) ``it`` by *i*. All the iterators
|
||||
``it``\ :sub:`i` for *i* = 0, 1, 2, ..., ``|n|`` should be valid.
|
||||
|
||||
If ``Iterator`` does not model Bidirectional Traversal Iterator,
|
||||
``n`` should be non-negative.
|
||||
|
||||
|
||||
Complexity
|
||||
----------
|
||||
|
||||
If ``Iterator`` models Random Access Traversal Iterator, it takes constant time;
|
||||
otherwise it takes linear time.
|
||||
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
- This function is not a customization point and is protected against
|
||||
being found by argument-dependent lookup (ADL).
|
||||
- This function is ``constexpr`` only in C++14 or later.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
| Author: Michel Morin
|
||||
| Copyright |C| 2017 Michel Morin
|
||||
| Distributed under the `Boost Software License, Version 1.0
|
||||
<http://www.boost.org/LICENSE_1_0.txt>`_.
|
||||
|
||||
.. |C| unicode:: U+00A9 .. COPYRIGHT SIGN
|
72
doc/distance.rst
Normal file
72
doc/distance.rst
Normal file
@ -0,0 +1,72 @@
|
||||
.. Copyright (C) 2017 Michel Morin.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
========
|
||||
distance
|
||||
========
|
||||
|
||||
``boost::iterators::distance`` is an adapted version of ``std::distance`` for
|
||||
the Boost iterator traversal concepts.
|
||||
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
``<boost/iterator/distance.hpp>``
|
||||
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
::
|
||||
|
||||
template <typename Iterator>
|
||||
constexpr typename iterator_difference<Iterator>::type
|
||||
distance(Iterator first, Iterator last);
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Computes the (signed) distance from ``first`` to ``last``.
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
``Iterator`` should model Single Pass Iterator.
|
||||
|
||||
|
||||
Preconditions
|
||||
-------------
|
||||
|
||||
If ``Iterator`` models Random Access Traversal Iterator,
|
||||
``[first, last)`` or ``[last, first)`` should be valid;
|
||||
otherwise ``[first, last)`` should be valid.
|
||||
|
||||
|
||||
Complexity
|
||||
----------
|
||||
|
||||
If ``Iterator`` models Random Access Traversal Iterator, it takes constant time;
|
||||
otherwise it takes linear time.
|
||||
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
- This function is not a customization point and is protected against
|
||||
being found by argument-dependent lookup (ADL).
|
||||
- This function is ``constexpr`` only in C++14 or later.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
| Author: Michel Morin
|
||||
| Copyright |C| 2017 Michel Morin
|
||||
| Distributed under the `Boost Software License, Version 1.0
|
||||
<http://www.boost.org/LICENSE_1_0.txt>`_.
|
||||
|
||||
.. |C| unicode:: U+00A9 .. COPYRIGHT SIGN
|
Loading…
x
Reference in New Issue
Block a user