distance.rst 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. distance
  7. ========
  8. ``boost::iterators::distance`` is an adapted version of ``std::distance`` for
  9. the Boost iterator traversal concepts.
  10. Header
  11. ------
  12. ``<boost/iterator/distance.hpp>``
  13. Synopsis
  14. --------
  15. ::
  16. template <typename Iterator>
  17. constexpr typename iterator_difference<Iterator>::type
  18. distance(Iterator first, Iterator last);
  19. Description
  20. -----------
  21. Computes the (signed) distance from ``first`` to ``last``.
  22. Requirements
  23. ------------
  24. ``Iterator`` should model Single Pass Iterator.
  25. Preconditions
  26. -------------
  27. If ``Iterator`` models Random Access Traversal Iterator,
  28. ``[first, last)`` or ``[last, first)`` should be valid;
  29. otherwise ``[first, last)`` should be valid.
  30. Complexity
  31. ----------
  32. If ``Iterator`` models Random Access Traversal Iterator, it takes constant time;
  33. otherwise it takes linear time.
  34. Notes
  35. -----
  36. - This function is not a customization point and is protected against
  37. being found by argument-dependent lookup (ADL).
  38. - This function is ``constexpr`` only in C++14 or later.
  39. --------------------------------------------------------------------------------
  40. | Author: Michel Morin
  41. | Copyright |C| 2017 Michel Morin
  42. | Distributed under the `Boost Software License, Version 1.0
  43. <http://www.boost.org/LICENSE_1_0.txt>`_.
  44. .. |C| unicode:: U+00A9 .. COPYRIGHT SIGN