3 // Copyright Adam D. Walling 2012. Use, modification and
4 // distribution is subject to the Boost Software License, Version
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // For more information, see http://www.boost.org/libs/range/
11 #ifndef BOOST_RANGE_ADAPTOR_MFC_MAP_HPP
12 #define BOOST_RANGE_ADAPTOR_MFC_MAP_HPP
14 #if !defined(BOOST_RANGE_MFC_NO_CPAIR)
16 #include <boost/range/mfc.hpp>
17 #include <boost/range/adaptor/map.hpp>
21 namespace range_detail
23 // CMap and CMapStringToString range iterators return CPair,
24 // which has a key and value member. Other MFC range iterators
25 // already return adapted std::pair objects. This allows usage
26 // of the map_keys and map_values range adaptors with CMap
27 // and CMapStringToString
29 // CPair has a VALUE value member, and a KEY key member; we will
30 // use VALUE& as the result_type consistent with CMap::operator[]
32 // specialization for CMap
33 template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
34 struct select_first< CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> >
36 typedef BOOST_DEDUCED_TYPENAME CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> map_type;
37 typedef BOOST_DEDUCED_TYPENAME range_reference<const map_type>::type argument_type;
38 typedef BOOST_DEDUCED_TYPENAME const KEY& result_type;
40 result_type operator()( argument_type r ) const
46 template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
47 struct select_second_mutable< CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> >
49 typedef BOOST_DEDUCED_TYPENAME CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> map_type;
50 typedef BOOST_DEDUCED_TYPENAME range_reference<map_type>::type argument_type;
51 typedef BOOST_DEDUCED_TYPENAME VALUE& result_type;
53 result_type operator()( argument_type r ) const
59 template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
60 struct select_second_const< CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> >
62 typedef BOOST_DEDUCED_TYPENAME CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> map_type;
63 typedef BOOST_DEDUCED_TYPENAME range_reference<const map_type>::type argument_type;
64 typedef BOOST_DEDUCED_TYPENAME const VALUE& result_type;
66 result_type operator()( argument_type r ) const
73 // specialization for CMapStringToString
75 struct select_first< CMapStringToString >
77 typedef range_reference<const CMapStringToString>::type argument_type;
78 typedef const CString& result_type;
80 result_type operator()( argument_type r ) const
87 struct select_second_mutable< CMapStringToString >
89 typedef range_reference<CMapStringToString>::type argument_type;
90 typedef CString& result_type;
92 result_type operator()( argument_type r ) const
99 struct select_second_const< CMapStringToString >
101 typedef range_reference<const CMapStringToString>::type argument_type;
102 typedef const CString& result_type;
104 result_type operator()( argument_type r ) const
112 #endif // !defined(BOOST_RANGE_MFC_NO_CPAIR)