2 // Boost.Pointer Container
4 // Copyright Thorsten Ottosen 2003-2005. Use, modification and
5 // distribution is subject to the Boost Software License, Version
6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // For more information, see http://www.boost.org/libs/ptr_container/
12 #ifndef BOOST_PTR_CONTAINER_MAP_ITERATOR_HPP
13 #define BOOST_PTR_CONTAINER_MAP_ITERATOR_HPP
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
19 #include <boost/config.hpp>
20 #include <boost/iterator/iterator_adaptor.hpp>
21 #include <boost/utility/compare_pointees.hpp>
24 #if defined(BOOST_MSVC)
25 # pragma warning(push)
26 # pragma warning(disable:4512) // Assignment operator could not be generated.
31 namespace ptr_container_detail
33 template< class F
, class S
>
37 typedef S second_type
;
42 template< class F2
, class S2
>
43 ref_pair( const std::pair
<F2
,S2
>& p
)
44 : first(p
.first
), second(static_cast<S
>(p
.second
))
48 ref_pair( const RP
* rp
)
49 : first(rp
->first
), second(rp
->second
)
52 const ref_pair
* const operator->() const
57 friend inline bool operator==( ref_pair l
, ref_pair r
)
59 return l
.first
== r
.first
&&
60 boost::equal_pointees( l
.second
, r
.second
);
63 friend inline bool operator!=( ref_pair l
, ref_pair r
)
68 friend inline bool operator<( ref_pair l
, ref_pair r
)
70 if( l
.first
== r
.first
)
71 return boost::less_pointees( l
.second
, r
.second
);
73 return l
.first
< r
.first
;
76 friend inline bool operator>( ref_pair l
, ref_pair r
)
81 friend inline bool operator<=( ref_pair l
, ref_pair r
)
86 friend inline bool operator>=( ref_pair l
, ref_pair r
)
95 class I
, // base iterator
96 class F
, // first type, key type
97 class S
// second type, mapped type
99 class ptr_map_iterator
:
100 public boost::iterator_adaptor
< ptr_map_iterator
<I
,F
,S
>, I
,
101 ptr_container_detail::ref_pair
<F
,S
>,
103 ptr_container_detail::ref_pair
<F
,S
> >
105 typedef boost::iterator_adaptor
< ptr_map_iterator
<I
,F
,S
>, I
,
106 ptr_container_detail::ref_pair
<F
,S
>,
108 ptr_container_detail::ref_pair
<F
,S
> >
113 ptr_map_iterator() : base_type()
116 explicit ptr_map_iterator( const I
& i
) : base_type(i
)
119 template< class I2
, class F2
, class S2
>
120 ptr_map_iterator( const ptr_map_iterator
<I2
,F2
,S2
>& r
)
121 : base_type(r
.base())
124 }; // class 'ptr_map_iterator'
128 #if defined(BOOST_MSVC)
129 # pragma warning(pop)