[Xapian-discuss] Weird problem on PositionIterator

Olly Betts olly at survex.com
Thu Nov 13 12:04:29 GMT 2008


On 13/11/2008, zhiguo li <zhiguo.li at gmail.com> wrote:
>  Xapian::MSetIterator im;
>  Xapian::TermIterator it1, it2;
>  Xapian::PositionIterator ip1_begin, ip1_end, ip2_begin, ip2_end;

I assume there's some initialisation of the above variables which you've
omitted here...

>  ip1_begin = db.positionlist_begin(*im, *it1);
>  ip1_end = db.positionlist_end(*im, *it1);
>
>  ip2_begin = db.positionlist_begin(*im, *it2);
>  ip2_end = db.positionlist_end(*im, *it2);
>
>  for (Xapian::PositionIterator ip1 = ip1_begin; ip1 != ip1_end; ip1++)
>
>  {
>
>          cout << *ip1 << endl;
>          for (Xapian::PositionIterator ip2 = ip2_begin; ip2 != ip2_end;
> ip2++)

The second time around, ip2_begin is no longer valid because PositionIterator is
an input iterator.  You can't factor out ip2_begin and ip2_end like this...

Cheers,
    Olly



More information about the Xapian-discuss mailing list