|
Boost Users : |
From: Nico Galoppo (nico_at_[hidden])
Date: 2006-02-21 08:42:23
Hi,
I'm having trouble getting make_filter_iterator and bind to work together nicely:
-------------------------------------------------------------------------------
boost::function<bool (const node_type&)> is_constraint;
is_constraint = boost::bind(&node_type::IsConstraint, _1);
boost::make_filter_iterator(is_constraint, ab.begin(), ab.end()); // ERROR:
does not compile
boost::make_filter_iterator(boost::bind(&node_type::IsConstraint, _1),
ab.begin(), ab.end()); // compiles
-------------------------------------------------------------------------------
Note that ab.begin()/ab.end() return iterators to containers of shared pointers.
See below for compiler errors.
What I would like to do, in the end, is something like this:
-------------------------------------------------------------------------------
typedef boost::filter_iterator<boost::function<bool (const node_type&)>,
articulated_model_type::node_df_traversal_iterator> joint_iterator;
joint_iterator first =
boost::make_filter_iterator(boost::bind(&node_type::IsConstraint, _1),
ab.begin(), ab.end());
-------------------------------------------------------------------------------
Unfortunately, this doesn't compile either. I want an explicit handle to the
interator (first), because I'd like to do a normal for loop like this:
for(joint_iterator joint = first; joint != last; ++joint)
{ ... }
Again, compile errors are below. Thanks for the help.
--nico
d:\dev\boost_1_33_1\boost\iterator\filter_iterator.hpp(100) : error C2664:
'boost::function1<R,T0,Allocator>::result_type
boost::function1<R,T0,Allocator>::operator ()(T0) const' : cannot convert
parameter 1 from 'Hybrid::Graph<node_traits>::const_node_ptr' to 'const
Hybrid::Node<graph_type_,node_traits> '
with
[
R=bool,
T0=const
Hybrid::Node<Hybrid::Graph<ArticulatedModelNodeTraits<MyTypes>>::graph_type,ArticulatedModelNodeTraits<MyTypes>>
,
Allocator=std::allocator<void>
]
and
[
node_traits=ArticulatedModelNodeTraits<MyTypes>
]
and
[
graph_type_=Hybrid::Graph<ArticulatedModelNodeTraits<MyTypes>>::graph_type,
node_traits=ArticulatedModelNodeTraits<MyTypes>
]
Reason: cannot convert from
'Hybrid::Graph<node_traits>::const_node_ptr' to 'const node_type'
with
[
node_traits=ArticulatedModelNodeTraits<MyTypes>
]
No constructor could take the source type, or constructor overload
resolution was ambiguous
d:\dev\boost_1_33_1\boost\iterator\filter_iterator.hpp(99) : while
compiling class-template member function 'void
boost::filter_iterator<Predicate,Iterator>::satisfy_predicate(void)'
with
[
Predicate=boost::function<bool (const node_type &)>,
Iterator=Hybrid::Graph<ArticulatedModelNodeTraits<MyTypes>>::node_df_traversal_iterator
]
d:\dev\Hybrid\Tests\Graph\main.cpp(645) : see reference to class
template instantiation 'boost::filter_iterator<Predicate,Iterator>' being compiled
with
[
Predicate=boost::function<bool (const node_type &)>,
Iterator=Hybrid::Graph<ArticulatedModelNodeTraits<MyTypes>>::node_df_traversal_iterator
]
======================================================================================
:\dev\Hybrid\Tests\Graph\main.cpp(646) : error C2440: 'initializing' : cannot
convert from 'boost::filter_iterator<Predicate,Iterator>' to
'boost::filter_iterator<Predicate,Iterator>'
with
[
Predicate=boost::_bi::bind_t<bool,boost::_mfi::cmf0<bool,ConstraintNodeTraits>,boost::_bi::list1<boost::_bi::list_av_1<boost::arg<1>>::B1>>,
Iterator=Hybrid::Graph<ArticulatedModelNodeTraits<MyTypes>>::node_df_traversal_iterator
]
and
[
Predicate=boost::function<bool (const node_type &)>,
Iterator=Hybrid::Graph<ArticulatedModelNodeTraits<MyTypes>>::node_df_traversal_iterator
]
No constructor could take the source type, or constructor overload
resolution was ambiguous
-- nico galoppo von borries @ address: 105 creel st., chapel hill comp. graphics phd. student @ north carolina, 27516 USA UNC, chapel hill @ phone: +1 (919) 962-1898 (office) @ +1 (919) 942-7609 (home) @ email: nico at cs dot unc dot edu @ homepage: http://www.cs.unc.edu/~nico --- debian linux :: vim powered
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