|
Boost Users : |
From: Doug Gregor (dgregor_at_[hidden])
Date: 2007-06-01 14:04:24
On Jun 1, 2007, at 3:04 AM, Sashan Govender wrote:
> Hi
>
> I'm trying to run a functor over edges from a graph using for_each
> however it fails when the iterators are edges. The same technique
> works for iterators to vertices. Here is the compiler error:
>
> g++ -o bind_edge_test bind_edge_test.cpp
> /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4/bits/stl_algo.h:
> In function '_Function std::for_each(_InputIterator, _InputIterator,
> _Function) [with _InputIterator =
> boost::detail::undirected_edge_iter<std::_List_iterator<boost::list_ed
> ge<void*,
> boost::property<boost::edge_name_t, unsigned int, boost::no_property>
>> >, boost::detail::edge_desc_impl<boost::undirected_tag, void*>,
> int>, _Function = boost::_bi::bind_t<void, Op,
> boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >]':
> bind_edge_test.cpp:79: instantiated from here
> /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4/bits/stl_algo.h:
> 159:
> error: no match for call to '(boost::_bi::bind_t<void, Op,
> boost::_bi::list2<boost::arg<1>, boost::_bi::value<int> > >)
> (boost::detail::edge_desc_impl<boost::undirected_tag, void*>)'
Unfortunately, this isn't an easy problem to solve. The edge
iterators in the BGL return temporary edge objects when you
dereference them. Bind, however, cannot accept temporary objects...
this is the dreaded "forwarding problem". It's the same reason you
can't pass literals to a bound function object, e.g.,
bind(std::plus<int>, _1, _2)(17, 42); // error: no match for call to...
Unfortunately, this probably means that for_each with bind and edge
iterators just won't work. There is some hope: the next version of
the C++ standard will eventually fix this problem.
- 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