Boost logo

Boost Users :

From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2008-06-03 05:43:12


Rodolfo Lima skrev:
> Hi, is there any other reason (apart from begin a bug) that the
> following code doesn't compile with g++-4.3?
>
> #include <boost/ptr_container/ptr_map.hpp>
>
> int main()
> {
> boost::ptr_map<int,int> m1, m2;
>
> m1.insert(1,std::auto_ptr<int>(new int(2)));
> m2.insert(1,std::auto_ptr<int>(new int(2)));
>
> return m1 == m2;
> }
>
>
> gcc spits the following errors (be seated...):
>
> /usr/lib/gcc/i686-pc-linux-gnu/4.3.0/include/g++-v4/bits/stl_algobase.h:
> In static member function 'static bool
> std::__equal<_BoolType>::equal(_II1, _II1, _II2) [with _II1 =
> boost::ptr_map_iterator<std::_Rb_tree_const_iterator<std::pair<const
> int, void*> >, int, const int* const>, _II2 =
> boost::ptr_map_iterator<std::_Rb_tree_const_iterator<std::pair<const
> int, void*> >, int, const int* const>, bool _BoolType = false]':
>
> /usr/lib/gcc/i686-pc-linux-gnu/4.3.0/include/g++-v4/bits/stl_algobase.h:818:
> instantiated from 'bool std::__equal_aux(_II1, _II1, _II2) [with _II1
> = boost::ptr_map_iterator<std::_Rb_tree_const_iterator<std::pair<const
> int, void*> >, int, const int* const>, _II2 =
> boost::ptr_map_iterator<std::_Rb_tree_const_iterator<std::pair<const
> int, void*> >, int, const int* const>]'
>
> /usr/lib/gcc/i686-pc-linux-gnu/4.3.0/include/g++-v4/bits/stl_algobase.h:950:
> instantiated from 'bool std::equal(_II1, _II1, _II2) [with _II1 =
> boost::ptr_map_iterator<std::_Rb_tree_const_iterator<std::pair<const
> int, void*> >, int, const int* const>, _II2 =
> boost::ptr_map_iterator<std::_Rb_tree_const_iterator<std::pair<const
> int, void*> >, int, const int* const>]'
>
> /usr/include/boost/ptr_container/detail/reversible_ptr_container.hpp:441:
> instantiated from 'bool
> boost::ptr_container_detail::reversible_ptr_container<Config,
> CloneAllocator>::operator==(const
> boost::ptr_container_detail::reversible_ptr_container<Config,
> CloneAllocator>&) const [with Config =
> boost::ptr_container_detail::map_config<int, std::map<int, void*,
> std::less<int>, std::allocator<std::pair<const int, void*> > > >,
> CloneAllocator = boost::heap_clone_allocator]'
> teste.cpp:10: instantiated from here
>
> /usr/lib/gcc/i686-pc-linux-gnu/4.3.0/include/g++-v4/bits/stl_algobase.h:789:
> error: no match for 'operator==' in
> '((boost::iterator_facade<boost::ptr_map_iterator<std::_Rb_tree_const_iterator<std::pair<const
> int, void*> >, int, const int* const>,
> boost::ptr_container_detail::ref_pair<int, const int* const>,
> boost::bidirectional_traversal_tag,
> boost::ptr_container_detail::ref_pair<int, const int* const>, int>*)(&
> __first1))->boost::iterator_facade<I, V, TC, R, D>::operator* [with
> Derived =
> boost::ptr_map_iterator<std::_Rb_tree_const_iterator<std::pair<const
> int, void*> >, int, const int* const>, Value =
> boost::ptr_container_detail::ref_pair<int, const int* const>,
> CategoryOrTraversal = boost::bidirectional_traversal_tag, Reference =
> boost::ptr_container_detail::ref_pair<int, const int* const>, Difference
> = int]() ==
> ((boost::iterator_facade<boost::ptr_map_iterator<std::_Rb_tree_const_iterator<std::pair<const
> int, void*> >, int, const int* const>,
> boost::ptr_container_detail::ref_pair<int, const int* const>,
> boost::bidirectional_traversal_tag,
> boost::ptr_container_detail::ref_pair<int, const int* const>, int>*)(&
> __first2))->boost::iterator_facade<I, V, TC, R, D>::operator* [with
> Derived =
> boost::ptr_map_iterator<std::_Rb_tree_const_iterator<std::pair<const
> int, void*> >, int, const int* const>, Value =
> boost::ptr_container_detail::ref_pair<int, const int* const>,
> CategoryOrTraversal = boost::bidirectional_traversal_tag, Reference =
> boost::ptr_container_detail::ref_pair<int, const int* const>, Difference
> = int]()'
> make: ** [teste] Erro 1
>
> My guess it that boost::ptr_container_detail::ref_pair should have an
> equality operator (and a less than also) somehow.
>
> In fact... by adding the following operator== to it the code compiles
> and behaves as expected:
>
> // #include <boost/utility/compare_pointees.hpp at top of the file
> bool operator==(const ref_pair &that) const
> {
> return first==that.first
> && boost::equal_pointees(second, that.second);
> }
>
> Something equivalent should be done for operator<
>
> Any objections?

No, I'll add something to trunk soon.

Thanks

-Thorsten


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