|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-10-04 14:54:53
Patch applied, thanks George!
P.S. Peter, I also changed "bind" to "select" as needed.
===================================================
David Abrahams, C++ library designer for hire
resume: http://users.rcn.com/abrahams/resume.html
C++ Booster (http://www.boost.org)
email: david.abrahams_at_[hidden]
===================================================
----- Original Message -----
From: "George A. Heintzelman" <georgeh_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, October 04, 2001 3:01 PM
Subject: [boost] indirect_iterator_adaptor and const_iterator
>
> Hi boosters,
>
> The following code does not compile with boost 1.25.0:
>
> #include <boost/iterator_adaptors.hpp>
> #include <vector>
>
> using namespace boost;
> using namespace std;
>
> int main() {
> int ints[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
>
> typedef vector<int const *> vect_t;
> vect_t v;
> for (int i = 9; i >=0; i--) {
> v.push_back(ints + i);
> }
>
> typedef indirect_iterator_generator<vect_t::iterator>::type
> indirector;
>
>
> for (indirector it = indirector(v.begin()),
> end = indirector(v.end()); it != end; ++it) {
> const int &ref = *it;
>
> cout << ref << '\n';
> }
> }
>
> If I change the typedef to typedef vector<int *> vect_t; it works as
> expected. The same problem holds when const_iterators are used instead
> of const int **'s.
>
> The problem arises because the reference type and pointer type of an
> indirected <const int **> are int & and int *, not const int & and const
int *.
<snip>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk