diff --git a/iterator_adaptors.htm b/iterator_adaptors.htm index 8aa9e63..7dbd325 100644 --- a/iterator_adaptors.htm +++ b/iterator_adaptors.htm @@ -170,7 +170,8 @@ struct iterator_adaptor; The value_type of the resulting iterator, unless const. If Value is const X the value_type will be (non-const) X[1].
+ "#1">[1]. If the value_type you wish to use is an abstract + base class see note [5].
Default: std::iterator_traits<BaseType>::value_type [2] @@ -829,6 +830,20 @@ bool operator==(const iterator_adaptor<B1,P,V1,R1,P1,C,D>&, returning a reference could cause serious memory problems due to the reference being bound to a temporary object whose lifetime ends inside of the operator[]. + +

[5] + The value_type of an iterator may not be + an abstract base class, however many common uses of iterators + never need the value_type, only the reference type. + If you wish to create such an iterator adaptor, use a dummy + type such as char for the Value parameter, + and use a reference to your abstract base class for + the Reference parameter. Note that such an iterator + does not fulfill the C++ standards requirements for a + + Forward Iterator, so you will need to use a less restrictive + iterator category such as std::input_iterator_tag. +


Revised