|
Boost Users : |
Subject: [Boost-users] Build bimap with iterators ... + lower_bound(..) ?
From: Rytuto (rytuto_at_[hidden])
Date: 2011-02-03 08:56:37
Hello everyone,
I have just started to use boost via boost::bimap.
I have a problem when using iterators to build a new bimap.
Here is a sample of my code :
class MyObject {...Definitions of MyObject...};
struct Position{};
// Wherever you meet Pos, it will mean Position
// Define my bimap type :
typedef boost::bimap<
set_of<tagged<double,Position> >,
multiset_of<tagged< MyObject*, MyObject> > // because at one position,
I can have many objects .... is that right ?
> PosMap;
typedef PosMap::value_type MyObjectPos;
PosMap posX ;
// This posX maps the position of my objects
for(MyObject::iterator it = MyObject.begin() ; it!= = MyObject.end() ; it++)
{
// it is an iterator on MyObjects
Vector3D position = it->GetPosition() ;
// Fill my map :
posX.insert(MyObjectPos(position.x(), (*it)));
}
// Now I would like just to select a window on my posX bimap:
double x = something ;
double R = something else ;
// PosMap::left_iterator tmp_itLowX = posX.left.lower_bound(x-R);
// PosMap::left_iterator tmp_itUpX = posX.left.lower_bound(x+R);
// Here is my problem :
PosMap m(posX.left.lower_bound(x-R), posX.left.lower_bound(x+R));
What is wrong with this piece of code ... ?
//___________________________________________________________
Here is the output from the compiler :
./boost/bimap/container_adaptor/ordered_associative_container_adaptor.hpp: In
member function âtypename
boost::bimaps::container_adaptor::ordered_associative_container_adaptor_base<Base,
Iterator, ConstIterator, ReverseIterator, ConstReverseIterator, KeyType,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter, ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter, FunctorsFromDerivedClasses>::type::iterator
boost::bimaps::container_adaptor::ordered_associative_container_adaptor<Base,
Iterator, ConstIterator, ReverseIterator, ConstReverseIterator, KeyType,
IteratorToBaseConverter, IteratorFromBaseConverter,
ReverseIteratorFromBaseConverter, ValueToBaseConverter, ValueFromBaseConverter,
KeyToBaseConverter, FunctorsFromDerivedClasses>::lower_bound(const
CompatibleKey&) [with CompatibleKey = double, Base =
boost::multi_index::detail::ordered_index<boost::multi_index::member<boost::bimaps::relation::detail::relation_storage<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
true>, double,
&boost::bimaps::relation::detail::relation_storage<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
true>::left>, std::less<double>, boost::multi_index::detail::nth_layer<2,
boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true>,
boost::bimaps::detail::bimap_core<boost::bimaps::set_of<boost::bimaps::tags::tagged<double,
Position>, std::less<double> >,
boost::bimaps::multiset_of<boost::bimaps::tags::tagged<MyObject*, MyObject>,
std::less<MyObject*> >, mpl_::na, mpl_::na, mpl_::na>::core_indices,
std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true> > >, boost::mpl::v_item<Position,
boost::mpl::vector0<mpl_::na>, 0>,
boost::multi_index::detail::ordered_unique_tag>, Iterator =
boost::bimaps::detail::set_view_iterator<boost::multi_index::detail::bidir_node_iterator<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true>,
std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true> > > > > >, ConstIterator =
boost::bimaps::detail::const_set_view_iterator<boost::multi_index::detail::bidir_node_iterator<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true>,
std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true> > > > > >, ReverseIterator =
boost::bimaps::detail::set_view_iterator<boost::reverse_iterator<boost::multi_index::detail::bidir_node_iterator<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true>,
std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true> > > > > > >, ConstReverseIterator =
boost::bimaps::detail::const_set_view_iterator<boost::reverse_iterator<boost::multi_index::detail::bidir_node_iterator<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true>,
std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true> > > > > > >, KeyType =
boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, false>, IteratorToBaseConverter =
boost::bimaps::container_adaptor::support::iterator_facade_to_base<boost::bimaps::detail::set_view_iterator<boost::multi_index::detail::bidir_node_iterator<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true>,
std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true> > > > > >,
boost::bimaps::detail::const_set_view_iterator<boost::multi_index::detail::bidir_node_iterator<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true>,
std::allocator<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true> > > > > > >, IteratorFromBaseConverter = mpl_::na,
ReverseIteratorFromBaseConverter = mpl_::na, ValueToBaseConverter =
boost::bimaps::relation::detail::get_mutable_relation_functor<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true> >, ValueFromBaseConverter =
boost::bimaps::relation::support::get_above_view_functor<boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true> >, KeyToBaseConverter =
boost::bimaps::detail::set_view_key_to_base<double,
boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true>,
boost::multi_index::member<boost::bimaps::relation::detail::relation_storage<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
true>, double,
&boost::bimaps::relation::detail::relation_storage<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
true>::left> >, FunctorsFromDerivedClasses = boost::mpl::vector<mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na,
mpl_::na, mpl_::na, mpl_::na>]â:
include/MyObjectManager.icc:184: instantiated from âstd::vector<MyObject*,
std::allocator<MyObject*> >
MyObjectManager<T>::FindClosestITsWithinGivenRange(const ThreeVector&, double)
[with T = Object]â
kit.cc:240: instantiated from here
./boost/bimap/container_adaptor/ordered_associative_container_adaptor.hpp:257:
erreur: no match for call to
â(boost::bimaps::detail::set_view_key_to_base<double,
boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true>,
boost::multi_index::member<boost::bimaps::relation::detail::relation_storage<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
true>, double,
&boost::bimaps::relation::detail::relation_storage<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
true>::left> >) (const double&)â
./boost/bimap/detail/set_view_base.hpp:38: note: candidats sont: const Key
boost::bimaps::detail::set_view_key_to_base<Key, Value,
KeyToBase>::operator()(const Value&) const [with Key = double, Value =
boost::bimaps::relation::mutant_relation<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
mpl_::na, true>, KeyToBase =
boost::multi_index::member<boost::bimaps::relation::detail::relation_storage<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
true>, double,
&boost::bimaps::relation::detail::relation_storage<boost::bimaps::tags::tagged<const
double, Position>, boost::bimaps::tags::tagged<MyObject* const, MyObject>,
true>::left>]
//___________________________________________________________
Thank you very much for your help and guidance,
Mathieu
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