permutation_iterator_ref.rst 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. .. parsed-literal::
  5. template< class ElementIterator
  6. , class IndexIterator
  7. , class ValueT = use_default
  8. , class CategoryT = use_default
  9. , class ReferenceT = use_default
  10. , class DifferenceT = use_default >
  11. class permutation_iterator
  12. {
  13. public:
  14. permutation_iterator();
  15. explicit permutation_iterator(ElementIterator x, IndexIterator y);
  16. template< class OEIter, class OIIter, class V, class C, class R, class D >
  17. permutation_iterator(
  18. permutation_iterator<OEIter, OIIter, V, C, R, D> const& r
  19. , typename enable_if_convertible<OEIter, ElementIterator>::type* = 0
  20. , typename enable_if_convertible<OIIter, IndexIterator>::type* = 0
  21. );
  22. reference operator*() const;
  23. permutation_iterator& operator++();
  24. ElementIterator const& base() const;
  25. private:
  26. ElementIterator m_elt; // exposition only
  27. IndexIterator m_order; // exposition only
  28. };
  29. template <class ElementIterator, class IndexIterator>
  30. permutation_iterator<ElementIterator, IndexIterator>
  31. make_permutation_iterator( ElementIterator e, IndexIterator i);
  32. ``permutation_iterator`` requirements
  33. -------------------------------------
  34. ``ElementIterator`` shall model Random Access Traversal Iterator.
  35. ``IndexIterator`` shall model Readable Iterator. The value type of
  36. the ``IndexIterator`` must be convertible to the difference type of
  37. ``ElementIterator``.
  38. ``permutation_iterator`` models
  39. -------------------------------
  40. ``permutation_iterator`` models the same iterator traversal concepts
  41. as ``IndexIterator`` and the same iterator access concepts as
  42. ``ElementIterator``.
  43. If ``IndexIterator`` models Single Pass Iterator and
  44. ``ElementIterator`` models Readable Iterator then
  45. ``permutation_iterator`` models Input Iterator.
  46. If ``IndexIterator`` models Forward Traversal Iterator and
  47. ``ElementIterator`` models Readable Lvalue Iterator then
  48. ``permutation_iterator`` models Forward Iterator.
  49. If ``IndexIterator`` models Bidirectional Traversal Iterator and
  50. ``ElementIterator`` models Readable Lvalue Iterator then
  51. ``permutation_iterator`` models Bidirectional Iterator.
  52. If ``IndexIterator`` models Random Access Traversal Iterator and
  53. ``ElementIterator`` models Readable Lvalue Iterator then
  54. ``permutation_iterator`` models Random Access Iterator.
  55. ``permutation_iterator<E1, X, V1, C2, R1, D1>`` is interoperable
  56. with ``permutation_iterator<E2, Y, V2, C2, R2, D2>`` if and only if
  57. ``X`` is interoperable with ``Y`` and ``E1`` is convertible
  58. to ``E2``.
  59. ``permutation_iterator`` operations
  60. -----------------------------------
  61. In addition to those operations required by the concepts that
  62. ``permutation_iterator`` models, ``permutation_iterator`` provides the
  63. following operations.
  64. ``permutation_iterator();``
  65. :Effects: Default constructs ``m_elt`` and ``m_order``.
  66. ``explicit permutation_iterator(ElementIterator x, IndexIterator y);``
  67. :Effects: Constructs ``m_elt`` from ``x`` and ``m_order`` from ``y``.
  68. ::
  69. template< class OEIter, class OIIter, class V, class C, class R, class D >
  70. permutation_iterator(
  71. permutation_iterator<OEIter, OIIter, V, C, R, D> const& r
  72. , typename enable_if_convertible<OEIter, ElementIterator>::type* = 0
  73. , typename enable_if_convertible<OIIter, IndexIterator>::type* = 0
  74. );
  75. :Effects: Constructs ``m_elt`` from ``r.m_elt`` and
  76. ``m_order`` from ``y.m_order``.
  77. ``reference operator*() const;``
  78. :Returns: ``*(m_elt + *m_order)``
  79. ``permutation_iterator& operator++();``
  80. :Effects: ``++m_order``
  81. :Returns: ``*this``
  82. ``ElementIterator const& base() const;``
  83. :Returns: ``m_order``
  84. ::
  85. template <class ElementIterator, class IndexIterator>
  86. permutation_iterator<ElementIterator, IndexIterator>
  87. make_permutation_iterator(ElementIterator e, IndexIterator i);
  88. :Returns: ``permutation_iterator<ElementIterator, IndexIterator>(e, i)``