|
Boost Users : |
From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2007-02-09 10:15:08
On Feb 9, 2007, at 2:38 AM, Sebastian Weber wrote:
> At least that's how I understood, how the property_map concept works.
> However, if I use a bit-vector the above scheme breaks down to work:
>
> std::vector<bool> bit_props(num_vertices(my_graph), false)
>
> bfs_search(..., make_my_vistor(&bit_props[0]), ...)
>
> The compiler compiles these lines, but complains that a temprorary is
> passed as a reference to make_my_visitor and the code generated
> crashes.
> My system is a Ubununtu Edgy with boost 1.33.1 and g++ 4.1.2. Any
> ideas
> why this happens and what I can do here?
The problem here is that vector<bool> does a space "optimization" by
packing bool values into individual bits, and you can't take the
address of a bit. Instead of trying to get a pointer to the bits, use
iterators into the bit vector, e.g.,
bfs_search(..., make_my_vistor(bit_props.begin()), ...)
Cheers,
Doug
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