From 84663ff2e2ccd47de4e18a05c887ab7bfd96732e Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Mon, 19 Mar 2001 18:01:41 +0000 Subject: [PATCH] added more doc [SVN r9586] --- development/libs/iterator/iterator_traits.htm | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/development/libs/iterator/iterator_traits.htm b/development/libs/iterator/iterator_traits.htm index 5ebc332..1574f0a 100644 --- a/development/libs/iterator/iterator_traits.htm +++ b/development/libs/iterator/iterator_traits.htm @@ -14,13 +14,58 @@ Boost Iterator Traits - + +C++ Boost +
+

Boost Iterator Traits

Header boost/iterator_traits.hpp +

+The boost::iterator_traits class provides access to the +associated types of iterators that model the Boost Iterator Concepts, which are a +replacement for the iterator requirements in the C++ standard. +The main difference between std::iterator_traits and +boost::iterator_traits is that the iterator_category +type has been removed, and replaced with two new types: + +

+ + +

+An important feature of the boost::iterator_traits is that it +is backwards compatible, i.e., it will automatically work for +iterators for which there are valid definitions of +std::iterator_traits. The old iterator_category is +mapped to the appropriate traversal and return categories. + +

+When creating a new iterator type that is meant to work with +boost::iterator_traits, you can either create a +specialization of boost::iterator_traits for your iterator +type, or you can provide all the necessary associated types as nested +typedefs. In this case, your iterator class will need to inherit from +new_iterator_base to let boost::iterator_traits know +that it will be able to find typedefs for traversal_category +and return_category in you iterator class. + +

 namespace boost {
 
+  // Inherit from iterator_base if your iterator defines its own
+  // return_category and traversal_category. Otherwise, the "old style"
+  // iterator category will be mapped to the return_category and
+  // traversal_category.
+  struct new_iterator_base { };
+
   template <typename Iterator>
   struct iterator_traits
   {
@@ -86,7 +131,7 @@ namespace boost {
     
jeremy siek
-Last modified: Sun Mar 18 17:10:26 EST 2001 +Last modified: Mon Mar 19 12:59:30 EST 2001