Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:18

0001 // Boost.Range library
0002 //
0003 //  Copyright Adam D. Walling 2012. Use, modification and
0004 //  distribution is subject to the Boost Software License, Version
0005 //  1.0. (See accompanying file LICENSE_1_0.txt or copy at
0006 //  http://www.boost.org/LICENSE_1_0.txt)
0007 //
0008 // For more information, see http://www.boost.org/libs/range/
0009 //
0010 
0011 #ifndef BOOST_RANGE_ADAPTOR_MFC_MAP_HPP
0012 #define BOOST_RANGE_ADAPTOR_MFC_MAP_HPP
0013 
0014 #if !defined(BOOST_RANGE_MFC_NO_CPAIR)
0015 
0016 #include <boost/range/mfc.hpp>
0017 #include <boost/range/adaptor/map.hpp>
0018 
0019 namespace boost
0020 {
0021     namespace range_detail
0022     {
0023         // CMap and CMapStringToString range iterators return CPair,
0024         // which has a key and value member. Other MFC range iterators
0025         // already return adapted std::pair objects. This allows usage
0026         // of the map_keys and map_values range adaptors with CMap 
0027         // and CMapStringToString
0028         
0029         // CPair has a VALUE value member, and a KEY key member; we will
0030         // use VALUE& as the result_type consistent with CMap::operator[]
0031         
0032         // specialization for CMap 
0033         template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
0034         struct select_first< CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> >
0035         {
0036             typedef BOOST_DEDUCED_TYPENAME CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> map_type;
0037             typedef BOOST_DEDUCED_TYPENAME range_reference<const map_type>::type argument_type;
0038             typedef BOOST_DEDUCED_TYPENAME const KEY& result_type;
0039 
0040             result_type operator()( argument_type r ) const
0041             {
0042                 return r.key;
0043             }
0044         };
0045 
0046         template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
0047         struct select_second_mutable< CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> >
0048         {
0049             typedef BOOST_DEDUCED_TYPENAME CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> map_type;
0050             typedef BOOST_DEDUCED_TYPENAME range_reference<map_type>::type argument_type;
0051             typedef BOOST_DEDUCED_TYPENAME VALUE& result_type;
0052 
0053             result_type operator()( argument_type r ) const
0054             {
0055                 return r.value;
0056             }
0057         };
0058 
0059         template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
0060         struct select_second_const< CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> >
0061         {
0062             typedef BOOST_DEDUCED_TYPENAME CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> map_type;
0063             typedef BOOST_DEDUCED_TYPENAME range_reference<const map_type>::type argument_type;
0064             typedef BOOST_DEDUCED_TYPENAME const VALUE& result_type;
0065 
0066             result_type operator()( argument_type r ) const
0067             {
0068                 return r.value;
0069             }
0070         };
0071 
0072 
0073         // specialization for CMapStringToString
0074         template<>
0075         struct select_first< CMapStringToString >
0076         {
0077             typedef range_reference<const CMapStringToString>::type argument_type;
0078             typedef const CString& result_type;
0079 
0080             result_type operator()( argument_type r ) const
0081             {
0082                 return r.key;
0083             }
0084         };
0085 
0086         template<>
0087         struct select_second_mutable< CMapStringToString >
0088         {
0089             typedef range_reference<CMapStringToString>::type argument_type;
0090             typedef CString& result_type;
0091 
0092             result_type operator()( argument_type r ) const
0093             {
0094                 return r.value;
0095             }
0096         };
0097 
0098         template<>
0099         struct select_second_const< CMapStringToString >
0100         {
0101             typedef range_reference<const CMapStringToString>::type argument_type;
0102             typedef const CString& result_type;
0103 
0104             result_type operator()( argument_type r ) const
0105             {
0106                 return r.value;
0107             }
0108         };
0109     } // 'range_detail'
0110 } // 'boost'
0111 
0112 #endif // !defined(BOOST_RANGE_MFC_NO_CPAIR)
0113 
0114 #endif