[range] No iterator_range::const_reference

Hi list, boost::iterator_range currently contains both 'iterator' and 'reference' typedefs, and yet only a 'const_iterator' one (no 'const_reference'). This can be a problem with Spirit actions (compilation errors, see trac ticket #2234 - http://svn.boost.org/trac/boost/ticket/2234). After removing Spirit code, it boils down to: //////////////////// #include <boost/spirit/include/phoenix_stl.hpp> #include <boost/range/iterator_range.hpp> int main() { typedef const boost::iterator_range< const char* > cir; boost::phoenix::stl::front::result< cir > foo; // compilation error return 0; } //////////////////// The problem comes from the instantiation of boost::phoenix::stl::front::result< const iterator_range<...> > which, since its template argument is const, accesses its const_reference typedef -- which doesn't exist in iterator_range. Does it make sense / is it possible to add a const_reference typedef in iterator_range? Thanks, Francois

Francois Barel skrev:
Hi list,
boost::iterator_range currently contains both 'iterator' and 'reference' typedefs, and yet only a 'const_iterator' one (no 'const_reference').
This can be a problem with Spirit actions (compilation errors, see trac ticket #2234 - http://svn.boost.org/trac/boost/ticket/2234). After removing Spirit code, it boils down to:
//////////////////// #include <boost/spirit/include/phoenix_stl.hpp> #include <boost/range/iterator_range.hpp>
int main() { typedef const boost::iterator_range< const char* > cir; boost::phoenix::stl::front::result< cir > foo; // compilation error return 0; } ////////////////////
The problem comes from the instantiation of boost::phoenix::stl::front::result< const iterator_range<...> > which, since its template argument is const, accesses its const_reference typedef -- which doesn't exist in iterator_range.
Does it make sense / is it possible to add a const_reference typedef in iterator_range?
I guess it possible, and sub-range already has the const_reference typedef. There might also be some minor tweaks to better support iterators that return proxies or by value for operator*(). I'll look into it. -Thorsten

Thorsten Ottosen wrote:
Francois Barel skrev:
Hi list,
boost::iterator_range currently contains both 'iterator' and 'reference' typedefs, and yet only a 'const_iterator' one (no 'const_reference'). <snip>
I guess it possible, and sub-range already has the const_reference typedef. There might also be some minor tweaks to better support iterators that return proxies or by value for operator*().
I'll look into it.
-Thorsten
I hit similar problems just yesterday dealing with rows of images from GIL as ranges, since I think GIL uses proxies instead of references. I noticed that some code (wither range or transform_iterator) just uses the value type as a const reference, which gave me confusing compiler problems I am going to have to work through today. --John
participants (3)
-
Francois Barel
-
John C. Femiani
-
Thorsten Ottosen