Movatterモバイル変換


[0]ホーム

URL:


cplusplus.com

Reference

class
<iterator>

std::bidirectional_iterator_tag

struct bidirectional_iterator_tag {}
Bidirectional iterator category
Empty class to identify the category of an iterator as abidirectional iterator:

Bidirectional iterators


Bidirectional iterators are iterators that can be used to access the sequence of elements in a range in both directions (towards the end and towards the beginning).

Allrandom-access iterators are also validbidirectional iterators.

There is not a single type ofbidirectional iterator: Each container may define its own specific iterator type able to iterate through it and access its elements.

Bidirectional iterators have the same properties asforward iterators, with the only difference that they can also be decremented:

propertyvalid expressions
Isdefault-constructible,copy-constructible,copy-assignable anddestructibleX a;
X b(a);
b = a;
Can be compared for equivalence using the equality/inequality operators
(meaningful when both iterator values iterate over the same underlying sequence).
a == b
a != b
Can be dereferenced as anrvalue (if in adereferenceable state).*a
a->m
Formutable iterators (non-constant iterators):
Can be dereferenced as anlvalue (if in adereferenceable state).
*a = t
Can be incremented (if in adereferenceable state).
The result is either alsodereferenceable or apast-the-end iterator.
Two iterators that compare equal, keep comparing equal after being both increased.
++a
a++
*a++
Can be decremented (if adereferenceable iterator value precedes it).
--a
a--
*a--
propertyvalid expressions
Isdefault-constructible,copy-constructible,copy-assignable anddestructibleX a;
X b(a);
b = a;
Can be compared for equivalence using the equality/inequality operators
(meaningful when both iterator values iterate over the same underlying sequence).
a == b
a != b
Can be dereferenced as anrvalue (if in adereferenceable state).*a
a->m
Formutable iterators (non-constant iterators):
Can be dereferenced as anlvalue (if in adereferenceable state).
*a = t
Can be incremented (if in adereferenceable state).
The result is either alsodereferenceable or apast-the-end iterator.
Two iterators that compare equal, keep comparing equal after being both increased.
++a
a++
*a++
Can be decremented (if adereferenceable iterator value precedes it).
--a
a--
*a--
Lvalues areswappable.swap(a,b)

WhereX is abidirectional iterator type,a andb are objects of this iterator type, andt is an object of the type pointed by the iterator type (or some other type that can be assigned to thelvalue returned by dereferencing an object of typeX).

Constant iterators are iterators that do not fulfill the requirements of anoutput iterator; Dereferencing them yields a reference to a constant element (such asconst T&).

Allbidirectional iterators are also validforward andinput iterators.

See also

input_iterator_tag
Input iterator category(class)
output_iterator_tag
Output iterator category(class)
forward_iterator_tag
Forward iterator category(class)
random_access_iterator_tag
Random-access iterator category(class)
iterator
Iterator base class(class template)
Home page |Privacy policy
© cplusplus.com, 2000-2025 - All rights reserved -v3.3.4s
Spotted an error? contact us

[8]ページ先頭

©2009-2026 Movatter.jp