2004-01-27 17:03:46 +00:00
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en" >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" />
2006-02-01 23:33:32 +00:00
< meta name = "generator" content = "Docutils 0.3.8: http://docutils.sourceforge.net/" />
2004-11-02 14:31:27 +00:00
< title ></ title >
2004-01-27 17:03:46 +00:00
< link rel = "stylesheet" href = "default.css" type = "text/css" />
</ head >
< body >
< div class = "document" >
<!-- Version 1.4 of this ReStructuredText document corresponds to
n1530_, the paper accepted by the LWG for TR1. -->
2004-11-02 14:31:27 +00:00
<!-- Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003. -->
2004-01-27 17:03:46 +00:00
< pre class = "literal-block" >
template <
class Derived
, class Base
2004-11-02 14:31:27 +00:00
, class Value = use_default
, class CategoryOrTraversal = use_default
, class Reference = use_default
2004-01-27 17:03:46 +00:00
, class Difference = use_default
>
class iterator_adaptor
2004-11-02 14:31:27 +00:00
: public iterator_facade< Derived, < em > V'</ em > , < em > C'</ em > , < em > R'</ em > , < em > D'</ em > > // see < a class = "reference" href = "#base-parameters" > details</ a >
2004-01-27 17:03:46 +00:00
{
friend class iterator_core_access;
public:
iterator_adaptor();
2006-02-01 23:33:32 +00:00
explicit iterator_adaptor(Base const& iter);
typedef Base base_type;
2004-11-02 14:31:27 +00:00
Base const& base() const;
2004-01-27 17:03:46 +00:00
protected:
2004-11-02 14:31:27 +00:00
typedef iterator_adaptor iterator_adaptor_;
2004-01-27 17:03:46 +00:00
Base const& base_reference() const;
Base& base_reference();
private: // Core iterator interface for iterator_facade.
typename iterator_adaptor::reference dereference() const;
template <
class OtherDerived, class OtherIterator, class V, class C, class R, class D
>
bool equal(iterator_adaptor< OtherDerived, OtherIterator, V, C, R, D> const& x) const;
void advance(typename iterator_adaptor::difference_type n);
void increment();
void decrement();
template <
class OtherDerived, class OtherIterator, class V, class C, class R, class D
>
typename iterator_adaptor::difference_type distance_to(
iterator_adaptor< OtherDerived, OtherIterator, V, C, R, D> const& y) const;
private:
Base m_iterator; // exposition only
};
</ pre >
2006-02-01 23:33:32 +00:00
< div class = "section" id = "iterator-adaptor-requirements" >
< h1 >< a name = "iterator-adaptor-requirements" >< span class = "target" id = "requirements" ></ span >< tt class = "docutils literal" >< span class = "pre" > iterator_adaptor</ span ></ tt > requirements</ a ></ h1 >
< p >< tt class = "docutils literal" >< span class = "pre" > static_cast< Derived*> (iterator_adaptor*)</ span ></ tt > shall be well-formed.
The < tt class = "docutils literal" >< span class = "pre" > Base</ span ></ tt > argument shall be Assignable and Copy Constructible.</ p >
</ div >
2004-11-02 14:31:27 +00:00
< div class = "section" id = "iterator-adaptor-base-class-parameters" >
2006-02-01 23:33:32 +00:00
< h1 >< a name = "iterator-adaptor-base-class-parameters" >< span class = "target" id = "base-parameters" ></ span >< tt class = "docutils literal" >< span class = "pre" > iterator_adaptor</ span ></ tt > base class parameters</ a ></ h1 >
< p > The < em > V'</ em > , < em > C'</ em > , < em > R'</ em > , and < em > D'</ em > parameters of the < tt class = "docutils literal" >< span class = "pre" > iterator_facade</ span ></ tt >
used as a base class in the summary of < tt class = "docutils literal" >< span class = "pre" > iterator_adaptor</ span ></ tt >
2004-01-27 17:03:46 +00:00
above are defined as follows:</ p >
< pre class = "literal-block" >
2004-11-02 14:31:27 +00:00
< em > V'</ em > = if (Value is use_default)
2004-01-27 17:03:46 +00:00
return iterator_traits< Base> ::value_type
else
return Value
2004-11-02 14:31:27 +00:00
< em > C'</ em > = if (CategoryOrTraversal is use_default)
2004-01-27 17:03:46 +00:00
return iterator_traversal< Base> ::type
else
return CategoryOrTraversal
2004-11-02 14:31:27 +00:00
< em > R'</ em > = if (Reference is use_default)
2004-01-27 17:03:46 +00:00
if (Value is use_default)
return iterator_traits< Base> ::reference
else
return Value&
else
return Reference
2004-11-02 14:31:27 +00:00
< em > D'</ em > = if (Difference is use_default)
2004-01-27 17:03:46 +00:00
return iterator_traits< Base> ::difference_type
else
return Difference
</ pre >
2004-11-02 14:31:27 +00:00
<!-- ``iterator_adaptor`` models
- - - - - - - - - - - - - - - - - - - - - - - - - - -
In order for ``Derived`` to model the iterator concepts corresponding
to ``iterator_traits<Derived>::iterator_category``, the expressions
involving ``m_iterator`` in the specifications of those private member
functions of ``iterator_adaptor`` that may be called by
``iterator_facade<Derived, V, C, R, D>`` in evaluating any valid
expression involving ``Derived`` in those concepts' requirements. -->
<!-- The above is confusing and needs a rewrite. -JGS -->
<!-- That's why it's removed. We're embracing inheritance, remember? -->
2004-01-27 17:03:46 +00:00
</ div >
< div class = "section" id = "iterator-adaptor-public-operations" >
2006-02-01 23:33:32 +00:00
< h1 >< a name = "iterator-adaptor-public-operations" >< tt class = "docutils literal" >< span class = "pre" > iterator_adaptor</ span ></ tt > public operations</ a ></ h1 >
< p >< tt class = "docutils literal" >< span class = "pre" > iterator_adaptor();</ span ></ tt ></ p >
< table class = "docutils field-list" frame = "void" rules = "none" >
2004-01-27 17:03:46 +00:00
< col class = "field-name" />
< col class = "field-body" />
< tbody valign = "top" >
2006-02-01 23:33:32 +00:00
< tr class = "field" >< th class = "field-name" > Requires:</ th >< td class = "field-body" > The < tt class = "docutils literal" >< span class = "pre" > Base</ span ></ tt > type must be Default Constructible.</ td >
2004-01-27 17:03:46 +00:00
</ tr >
2006-02-01 23:33:32 +00:00
< tr class = "field" >< th class = "field-name" > Returns:</ th >< td class = "field-body" > An instance of < tt class = "docutils literal" >< span class = "pre" > iterator_adaptor</ span ></ tt > with
< tt class = "docutils literal" >< span class = "pre" > m_iterator</ span ></ tt > default constructed.</ td >
2004-01-27 17:03:46 +00:00
</ tr >
</ tbody >
</ table >
2006-02-01 23:33:32 +00:00
< p >< tt class = "docutils literal" >< span class = "pre" > explicit</ span > < span class = "pre" > iterator_adaptor(Base</ span > < span class = "pre" > const& </ span > < span class = "pre" > iter);</ span ></ tt ></ p >
< table class = "docutils field-list" frame = "void" rules = "none" >
2004-01-27 17:03:46 +00:00
< col class = "field-name" />
< col class = "field-body" />
< tbody valign = "top" >
2006-02-01 23:33:32 +00:00
< tr class = "field" >< th class = "field-name" > Returns:</ th >< td class = "field-body" > An instance of < tt class = "docutils literal" >< span class = "pre" > iterator_adaptor</ span ></ tt > with
< tt class = "docutils literal" >< span class = "pre" > m_iterator</ span ></ tt > copy constructed from < tt class = "docutils literal" >< span class = "pre" > iter</ span ></ tt > .</ td >
2004-01-27 17:03:46 +00:00
</ tr >
</ tbody >
</ table >
2006-02-01 23:33:32 +00:00
< p >< tt class = "docutils literal" >< span class = "pre" > Base</ span > < span class = "pre" > const& </ span > < span class = "pre" > base()</ span > < span class = "pre" > const;</ span ></ tt ></ p >
< table class = "docutils field-list" frame = "void" rules = "none" >
2004-01-27 17:03:46 +00:00
< col class = "field-name" />
< col class = "field-body" />
< tbody valign = "top" >
2006-02-01 23:33:32 +00:00
< tr class = "field" >< th class = "field-name" > Returns:</ th >< td class = "field-body" >< tt class = "docutils literal" >< span class = "pre" > m_iterator</ span ></ tt ></ td >
2004-01-27 17:03:46 +00:00
</ tr >
</ tbody >
</ table >
</ div >
< div class = "section" id = "iterator-adaptor-protected-member-functions" >
2006-02-01 23:33:32 +00:00
< h1 >< a name = "iterator-adaptor-protected-member-functions" >< tt class = "docutils literal" >< span class = "pre" > iterator_adaptor</ span ></ tt > protected member functions</ a ></ h1 >
< p >< tt class = "docutils literal" >< span class = "pre" > Base</ span > < span class = "pre" > const& </ span > < span class = "pre" > base_reference()</ span > < span class = "pre" > const;</ span ></ tt ></ p >
< table class = "docutils field-list" frame = "void" rules = "none" >
2004-01-27 17:03:46 +00:00
< col class = "field-name" />
< col class = "field-body" />
< tbody valign = "top" >
2006-02-01 23:33:32 +00:00
< tr class = "field" >< th class = "field-name" > Returns:</ th >< td class = "field-body" > A const reference to < tt class = "docutils literal" >< span class = "pre" > m_iterator</ span ></ tt > .</ td >
2004-01-27 17:03:46 +00:00
</ tr >
</ tbody >
</ table >
2006-02-01 23:33:32 +00:00
< p >< tt class = "docutils literal" >< span class = "pre" > Base& </ span > < span class = "pre" > base_reference();</ span ></ tt ></ p >
< table class = "docutils field-list" frame = "void" rules = "none" >
2004-01-27 17:03:46 +00:00
< col class = "field-name" />
< col class = "field-body" />
< tbody valign = "top" >
2006-02-01 23:33:32 +00:00
< tr class = "field" >< th class = "field-name" > Returns:</ th >< td class = "field-body" > A non-const reference to < tt class = "docutils literal" >< span class = "pre" > m_iterator</ span ></ tt > .</ td >
2004-01-27 17:03:46 +00:00
</ tr >
</ tbody >
</ table >
</ div >
< div class = "section" id = "iterator-adaptor-private-member-functions" >
2006-02-01 23:33:32 +00:00
< h1 >< a name = "iterator-adaptor-private-member-functions" >< tt class = "docutils literal" >< span class = "pre" > iterator_adaptor</ span ></ tt > private member functions</ a ></ h1 >
< p >< tt class = "docutils literal" >< span class = "pre" > typename</ span > < span class = "pre" > iterator_adaptor::reference</ span > < span class = "pre" > dereference()</ span > < span class = "pre" > const;</ span ></ tt ></ p >
< table class = "docutils field-list" frame = "void" rules = "none" >
2004-01-27 17:03:46 +00:00
< col class = "field-name" />
< col class = "field-body" />
< tbody valign = "top" >
2006-02-01 23:33:32 +00:00
< tr class = "field" >< th class = "field-name" > Returns:</ th >< td class = "field-body" >< tt class = "docutils literal" >< span class = "pre" > *m_iterator</ span ></ tt ></ td >
2004-01-27 17:03:46 +00:00
</ tr >
</ tbody >
</ table >
< pre class = "literal-block" >
template <
class OtherDerived, class OtherIterator, class V, class C, class R, class D
>
bool equal(iterator_adaptor< OtherDerived, OtherIterator, V, C, R, D> const& x) const;
</ pre >
2006-02-01 23:33:32 +00:00
< table class = "docutils field-list" frame = "void" rules = "none" >
2004-01-27 17:03:46 +00:00
< col class = "field-name" />
< col class = "field-body" />
< tbody valign = "top" >
2006-02-01 23:33:32 +00:00
< tr class = "field" >< th class = "field-name" > Returns:</ th >< td class = "field-body" >< tt class = "docutils literal" >< span class = "pre" > m_iterator</ span > < span class = "pre" > ==</ span > < span class = "pre" > x.base()</ span ></ tt ></ td >
2004-01-27 17:03:46 +00:00
</ tr >
</ tbody >
</ table >
2006-02-01 23:33:32 +00:00
< p >< tt class = "docutils literal" >< span class = "pre" > void</ span > < span class = "pre" > advance(typename</ span > < span class = "pre" > iterator_adaptor::difference_type</ span > < span class = "pre" > n);</ span ></ tt ></ p >
< table class = "docutils field-list" frame = "void" rules = "none" >
2004-01-27 17:03:46 +00:00
< col class = "field-name" />
< col class = "field-body" />
< tbody valign = "top" >
2006-02-01 23:33:32 +00:00
< tr class = "field" >< th class = "field-name" > Effects:</ th >< td class = "field-body" >< tt class = "docutils literal" >< span class = "pre" > m_iterator</ span > < span class = "pre" > +=</ span > < span class = "pre" > n;</ span ></ tt ></ td >
2004-01-27 17:03:46 +00:00
</ tr >
</ tbody >
</ table >
2006-02-01 23:33:32 +00:00
< p >< tt class = "docutils literal" >< span class = "pre" > void</ span > < span class = "pre" > increment();</ span ></ tt ></ p >
< table class = "docutils field-list" frame = "void" rules = "none" >
2004-01-27 17:03:46 +00:00
< col class = "field-name" />
< col class = "field-body" />
< tbody valign = "top" >
2006-02-01 23:33:32 +00:00
< tr class = "field" >< th class = "field-name" > Effects:</ th >< td class = "field-body" >< tt class = "docutils literal" >< span class = "pre" > ++m_iterator;</ span ></ tt ></ td >
2004-01-27 17:03:46 +00:00
</ tr >
</ tbody >
</ table >
2006-02-01 23:33:32 +00:00
< p >< tt class = "docutils literal" >< span class = "pre" > void</ span > < span class = "pre" > decrement();</ span ></ tt ></ p >
< table class = "docutils field-list" frame = "void" rules = "none" >
2004-01-27 17:03:46 +00:00
< col class = "field-name" />
< col class = "field-body" />
< tbody valign = "top" >
2006-02-01 23:33:32 +00:00
< tr class = "field" >< th class = "field-name" > Effects:</ th >< td class = "field-body" >< tt class = "docutils literal" >< span class = "pre" > --m_iterator;</ span ></ tt ></ td >
2004-01-27 17:03:46 +00:00
</ tr >
</ tbody >
</ table >
< pre class = "literal-block" >
template <
class OtherDerived, class OtherIterator, class V, class C, class R, class D
>
typename iterator_adaptor::difference_type distance_to(
iterator_adaptor< OtherDerived, OtherIterator, V, C, R, D> const& y) const;
</ pre >
2006-02-01 23:33:32 +00:00
< table class = "docutils field-list" frame = "void" rules = "none" >
2004-01-27 17:03:46 +00:00
< col class = "field-name" />
< col class = "field-body" />
< tbody valign = "top" >
2006-02-01 23:33:32 +00:00
< tr class = "field" >< th class = "field-name" > Returns:</ th >< td class = "field-body" >< tt class = "docutils literal" >< span class = "pre" > y.base()</ span > < span class = "pre" > -</ span > < span class = "pre" > m_iterator</ span ></ tt ></ td >
2004-01-27 17:03:46 +00:00
</ tr >
</ tbody >
</ table >
</ div >
</ div >
2006-02-01 23:33:32 +00:00
< hr class = "docutils footer" />
2004-01-27 17:03:46 +00:00
< div class = "footer" >
< a class = "reference" href = "iterator_adaptor_ref.rst" > View document source</ a > .
Generated by < a class = "reference" href = "http://docutils.sourceforge.net/" > Docutils</ a > from < a class = "reference" href = "http://docutils.sourceforge.net/rst.html" > reStructuredText</ a > source.
</ div >
</ body >
</ html >