iterator_adaptor_body.rst 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. .. 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. .. Version 1.2 of this ReStructuredText document corresponds to
  5. n1530_, the paper accepted by the LWG for TR1.
  6. .. Copyright David Abrahams, Jeremy Siek, and Thomas Witt 2003.
  7. The ``iterator_adaptor`` class template adapts some ``Base`` [#base]_
  8. type to create a new iterator. Instantiations of ``iterator_adaptor``
  9. are derived from a corresponding instantiation of ``iterator_facade``
  10. and implement the core behaviors in terms of the ``Base`` type. In
  11. essence, ``iterator_adaptor`` merely forwards all operations to an
  12. instance of the ``Base`` type, which it stores as a member.
  13. .. [#base] The term "Base" here does not refer to a base class and is
  14. not meant to imply the use of derivation. We have followed the lead
  15. of the standard library, which provides a base() function to access
  16. the underlying iterator object of a ``reverse_iterator`` adaptor.
  17. The user of ``iterator_adaptor`` creates a class derived from an
  18. instantiation of ``iterator_adaptor`` and then selectively
  19. redefines some of the core member functions described in the
  20. ``iterator_facade`` core requirements table. The ``Base`` type need
  21. not meet the full requirements for an iterator; it need only
  22. support the operations used by the core interface functions of
  23. ``iterator_adaptor`` that have not been redefined in the user's
  24. derived class.
  25. Several of the template parameters of ``iterator_adaptor`` default
  26. to ``use_default``. This allows the
  27. user to make use of a default parameter even when she wants to
  28. specify a parameter later in the parameter list. Also, the
  29. defaults for the corresponding associated types are somewhat
  30. complicated, so metaprogramming is required to compute them, and
  31. ``use_default`` can help to simplify the implementation. Finally,
  32. the identity of the ``use_default`` type is not left unspecified
  33. because specification helps to highlight that the ``Reference``
  34. template parameter may not always be identical to the iterator's
  35. ``reference`` type, and will keep users from making mistakes based on
  36. that assumption.