advance.rst 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. advance
  7. =======
  8. ``boost::iterators::advance`` is an adapted version of ``std::advance`` for
  9. the Boost iterator traversal concepts.
  10. Header
  11. ------
  12. ``<boost/iterator/advance.hpp>``
  13. Synopsis
  14. --------
  15. ::
  16. template <typename Iterator, typename Distance>
  17. constexpr void advance(Iterator& it, Distance n);
  18. Description
  19. -----------
  20. Moves ``it`` forward by ``n`` increments
  21. (or backward by ``|n|`` decrements if ``n`` is negative).
  22. Requirements
  23. ------------
  24. ``Iterator`` should model Incrementable Iterator.
  25. Preconditions
  26. -------------
  27. Let ``it``\ :sub:`i` be the iterator obtained by incrementing
  28. (or decrementing if ``n`` is negative) ``it`` by *i*. All the iterators
  29. ``it``\ :sub:`i` for *i* = 0, 1, 2, ..., ``|n|`` should be valid.
  30. If ``Iterator`` does not model Bidirectional Traversal Iterator,
  31. ``n`` should be non-negative.
  32. Complexity
  33. ----------
  34. If ``Iterator`` models Random Access Traversal Iterator, it takes constant time;
  35. otherwise it takes linear time.
  36. Notes
  37. -----
  38. - This function is not a customization point and is protected against
  39. being found by argument-dependent lookup (ADL).
  40. - This function is ``constexpr`` only in C++14 or later.
  41. --------------------------------------------------------------------------------
  42. | Author: Michel Morin
  43. | Copyright |C| 2017 Michel Morin
  44. | Distributed under the `Boost Software License, Version 1.0
  45. <http://www.boost.org/LICENSE_1_0.txt>`_.
  46. .. |C| unicode:: U+00A9 .. COPYRIGHT SIGN