Boost logo

Boost :

From: Shannon Stewman (stew_at_[hidden])
Date: 2004-03-01 22:39:39


I sent this a couple days ago, but I think it became lost in the ether
when the list moved machines.... apologies if it didn't.

I noticed a small potential problem with indirect_iterator. I've been
using it with raw pointers, and the default constructor appears broken
in this case (gcc-3.3.2):

    #include <boost/iterator/indirect_iterator.hpp>
    #include <iostream>

    struct MyType {};
    typedef MyType* MyTypeList;
    typedef boost::indirect_iterator< MyTypeList, MyType > Iter;

    int main( int argc, char** argv )
    {
      std::cout << "Iter() == Iter() ? "
                << ( Iter() == Iter() ) << std::endl
                << "Iter(NULL) == Iter(NULL) ? "
                << ( Iter(NULL) == Iter(NULL) ) << std::endl;
    }

The output is:

    Iter() == Iter() ? 0
    Iter(NULL) == Iter(NULL) ? 1

Is this an actual bug, or am I misusing the code?

If I'm misusing the code, is there some reason for this? It's
inconvenient that the default constructor doesn't initialize pointers
to some consistent value; the problem goes away when I change the
indirect_iterator default constructor:

    94c94,96
    < indirect_iterator() {}
    ---
> indirect_iterator()
> : super_t( Iterator() )
> {}

Best,

-- 
Shannon Stewman         | Let us walk through the waning night,
Caught in a whirlpool,  | As dawn-rays tickle our toes, the dew soothes
A quartering act:       | Our blistered soles, and damp bones stir
Solitude or society?    | As crimson cracks under the blue-grey sky.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk