I wrote a sparse vector class (see #1, #2.)
I would like to provide two kinds of iterators:
The first set, the regular iterators, can point any element, whether set or unset. If they are read from, they return either the set value or value_type(), if they are written to, they create the element and return the lvalue reference. Thus, they are:
Random Access Traversal Iterator and Readable and Writable Iterator
The second set, the sparse iterators, iterate over only the set elements. Since they don't need to lazily create elements that are written to, they are:
Random Access Traversal Iterator and Readable and Writable and Lvalue Iterator
I also need const versions of both, which are not writable.
I can fill in the blanks, but not sure how to use boost::iterator_adaptor to start out.
Here's what I have so far:
class iterator
: public boost::iterator_adaptor<
iterator // Derived
, value_type* // Base
, boost::use_default // Value
, boost::?????? // CategoryOrTraversal
>
class sparse_iterator
: public boost::iterator_adaptor<
iterator // Derived
, value_type* // Base
, boost::use_default // Value
, boost::random_access_traversal_tag? // CategoryOrTraversal
>