Opened 7 years ago

#11847 new Bugs

reference typedef no longer available in parent class of iterator_facade

Reported by: alexhighviz@… Owned by: jeffrey.hellrung
Milestone: To Be Determined Component: iterator
Version: Boost 1.57.0 Severity: Problem
Keywords: Cc: raad@…

Description

The iterator_facade defines the reference type. In Boost version 1.56 the parent class to the facade could make use of this type, from version 1.57 this is no longer possible.

This is not difficult to work around, but does cause existing code to fail.

I am using Visual Studio 2013 (12.0)

See code below:

#include <boost/iterator/iterator_facade.hpp>

#include <vector>

template<class T>

class simple_iterator : public

boost::iterator_facade<simple_iterator<T>, T, boost::forward_traversal_tag>

{

public:

simple_iterator(const typename std::vector<T>::iterator& i) : m_iter(i) {}

private:

friend boost::iterator_core_access;

/* The commented line compiled in 1.56 but no longer so in 1.57 */

/* reference dereference() const { return *m_iter; } */

T& dereference() const { return *m_iter; }

bool equal(const simple_iterator& that) { return m_iter == that.m_iter; }

void increment() { ++m_iter; }

typename std::vector<T>::iterator m_iter;

};

int main() {

std::vector<int> v = { 1, 2, 3 } ;

simple_iterator<int> i(v.begin());

simple_iterator<int>::reference vi = *i;

return 0;

}

Change History (0)

Note: See TracTickets for help on using tickets.