Boost logo

Boost :

Subject: Re: [boost] [iterator] Silent-but-deadly bug in iterator_facade category
From: paul Fultz (pfultz2_at_[hidden])
Date: 2013-05-06 17:22:18


> > Does the problem lie with iterator_category_with_traversal?  It looks > like it's intended in this case to be convertible to either > std::input_iterator_tag or std::random_access_iterator_tag, but > clearly something is wrong with the latter conversion.  Any ideas? > The problem lies in the fact that your iterator when it calls `dereference()`, returns something that is not a reference(ie char). For it to be a `std::random_access_iterator_tag` it must a reference. That is, `iterator_traits<X>::reference` must be an actual reference. So therefore your iterator is given the `std::input_iterator_tag`, since it is the only iterator category that doesn't require `dereference()` to return a reference. So then when you call: > std::advance(it, -1); With an input iterator, it will, depending on the implementation and the build type, either fail with a runtime assertion, or go into an infinite loop. Thanks, Paul


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