[EMAIL PROTECTED] (Hartmut Kaiser) writes: > David Abrahams wrote: > >> >> I have a problem while using the iterator_adaptor templates >> >> in conjunction with a istreambuf_iterator<char> (an >> >> input_iterator type). The problem shows up, because the >> >> istreambuf_iterator<char>::operator*() >> >> implementation of the STL I'm using returns a value_type >> >> (char), but the dereference policy member expects to return >> >> it a reference. >> >> >> >> It seems, that there should be a similar return type deduction for >> >> the >> >> iterator_adaptor<>::operator*() function as already >> >> implemented for the >> >> iterator_adaptor<>::operator->() function. >> > >> > Regards Hartmut >> >> Which template are you having problems with? Can you post >> some code which reproduces the problem? Did you try >> explicitly specifying the iterator's reference type? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Can't you solve this by passing char instead of char& as the 4th template parameter? > I've attached a minimal (braindead) sample, which reproduces the problem > (it does not compile). > > The input_iterator used as the Base iterator of the adaptor returns a > value_type from its operator*(), but the iterator_adaptor template > expects a reference here. Surely I could solve it by adding a member of > type value_type to my policy class, using it as a buffer and the > reference to it may be returned, but isn't it better to resolve it in > the adaptor? Even more because a congruent problem, which happens often > with the operator->() is already solved through a proxy class. I believe > that the operator*() problem may be solved in a similar fashion. > > Regards Hartmut > > > #include <iterator> > #include <boost/iterator_adaptors.hpp> > > using namespace boost; > > struct dummy_input_iterator > { > typedef std::input_iterator_tag iterator_category; > typedef char value_type; > typedef size_t difference_type; > typedef char * pointer; > typedef char & reference; > > value_type operator*() const { return 42; } > dummy_input_iterator & operator++() { return *this; } > dummy_input_iterator operator++(int) { return *this; } > }; > > typedef iterator_adaptor< > dummy_input_iterator, default_iterator_policies, > char, char &, char * > > adapted_dummy_iterator; -- Dave Abrahams Boost Consulting www.boost-consulting.com _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost