Boost logo

Boost :

Subject: Re: [boost] [iterators] Missing typedefs in v1.57
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2014-12-09 16:19:39


On Tue, Dec 9, 2014 at 11:08 PM, news.gmane.org <boost57_at_[hidden]> wrote:
> Class iterator_facade has been refactored in v1.57 such that most of its
> functionality is now in iterator_facade_base. This includes the typedefs
> for difference_type and reference. Hence, my classes which are derived from
> iterator_facade now have to declare them. For example:
>
> template <typename Stream, typename Value>
> class char_iter
> : public boost::iterators::iterator_facade< char_iter<Stream, Value>,
> Value,
>
> boost::iterators::random_access_traversal_tag,
> Value, Size >
> {
> public:
> typedef typename iterator_facade_::difference_type difference_type;
> typedef typename iterator_facade_::reference reference;
> ...
> };
>
> Have I misunderstood how to do this?

Your class is a template, and iterator_facade specialization depends
on the template parameters. The compiler does not bind names from the
iterator_facade base class (because it doesn't know which
specialization will be taken), so you must explicitly qualify the base
class name or declare the convenience typedefs like above. By doing so
you make the type names dependent on the template parameters,
postponing name binding to the template instantiation stage. This is
also true for the iterator_facade_ typedef, as well as other members
of iterator_facade, BTW. This behavior is standard C++, and 1.57
didn't bring anything new in this respect.

Some compilers do not perform name binding properly, effectively
delaying all of it to the template instantiation point. This is not a
conforming behavior, and it can let errors like this pass unnoticed.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk