Boost logo

Boost Users :

Subject: [Boost-users] [Range] sub_range and list not working together
From: Brian Wood (woodbrian77_at_[hidden])
Date: 2011-07-11 22:43:08


B"H

I've been testing my marshalling support for sub_range and have a question.

In reviewing some old posts and notes, it looks like the following used to
compile:

boost::sub_range<std::list<int32_t> > rng;

Today though I get the following error message:

g++ -Os -s -W -Wall -I. -I ./loki-0.1.7/include/loki/flex -I
/home/brian/boost_1_47_0_beta1 -c -o local_messages_d.cg.o
local_messages_d.cg.cc
In file included from
/home/brian/boost_1_47_0_beta1/boost/range/iterator_range.hpp:13:0,
                 from
/home/brian/boost_1_47_0_beta1/boost/range/sub_range.hpp:23,
                 from ./local_messages_d.cg.hh:5,
                 from local_messages_d.cg.cc:1:
/home/brian/boost_1_47_0_beta1/boost/range/iterator_range_core.hpp: In
member function ‘boost::iterator_range<IteratorT>::difference_type
boost::iterator_range<IteratorT>::size() const [with IteratorT =
std::_List_iterator<int>, boost::iterator_range<IteratorT>::difference_type
= int]’:
/home/brian/boost_1_47_0_beta1/boost/range/sub_range.hpp:117:58:
instantiated from ‘boost::sub_range<ForwardRange>::difference_type
boost::sub_range<ForwardRange>::size() const [with ForwardRange =
std::list<int>, boost::sub_range<ForwardRange>::difference_type = int]’
local_messages_d.cg.cc:22:33: instantiated from here
/home/brian/boost_1_47_0_beta1/boost/range/iterator_range_core.hpp:252:32:
error: no match for ‘operator-’ in ‘((const
boost::iterator_range<std::_List_iterator<int>
>*)this)->boost::iterator_range<std::_List_iterator<int> >::m_End - ((const
boost::iterator_range<std::_List_iterator<int>
>*)this)->boost::iterator_range<std::_List_iterator<int> >::m_Begin’
/usr/lib/gcc/i686-redhat-linux/4.5.1/../../../../include/c++/4.5.1/bits/stl_bvector.h:179:3:
note: candidate is: ptrdiff_t std::operator-(const std::_Bit_iterator_base&,
const std::_Bit_iterator_base&)
/home/brian/boost_1_47_0_beta1/boost/range/iterator_range_core.hpp:253:13:
warning: control reaches end of non-void function

Is this to be expected? I don't know if a specialization for std::list
in this regard would be useful, but seems possible.

If I change the list to a vector, everything compiles fine.
boost::sub_range<std::vector<int32_t> > rng;

The following sentence from the docs doesn't make sense to me.
"counting_range is a function to generator that generates an
iterator_rangewrapping a
counting_iterator (from Boost.Iterator). "

Regards,
Brian Wood
Ebenezer Enterprises
http://webEbenezer.net



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net