Chris@102: // Boost.Range library Chris@102: // Chris@102: // Copyright Adam D. Walling 2012. Use, modification and Chris@102: // distribution is subject to the Boost Software License, Version Chris@102: // 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@102: // http://www.boost.org/LICENSE_1_0.txt) Chris@102: // Chris@102: // For more information, see http://www.boost.org/libs/range/ Chris@102: // Chris@102: Chris@102: #ifndef BOOST_RANGE_ADAPTOR_MFC_MAP_HPP Chris@102: #define BOOST_RANGE_ADAPTOR_MFC_MAP_HPP Chris@102: Chris@102: #if !defined(BOOST_RANGE_MFC_NO_CPAIR) Chris@102: Chris@102: #include Chris@102: #include Chris@102: Chris@102: namespace boost Chris@102: { Chris@102: namespace range_detail Chris@102: { Chris@102: // CMap and CMapStringToString range iterators return CPair, Chris@102: // which has a key and value member. Other MFC range iterators Chris@102: // already return adapted std::pair objects. This allows usage Chris@102: // of the map_keys and map_values range adaptors with CMap Chris@102: // and CMapStringToString Chris@102: Chris@102: // CPair has a VALUE value member, and a KEY key member; we will Chris@102: // use VALUE& as the result_type consistent with CMap::operator[] Chris@102: Chris@102: // specialization for CMap Chris@102: template Chris@102: struct select_first< CMap > Chris@102: { Chris@102: typedef BOOST_DEDUCED_TYPENAME CMap map_type; Chris@102: typedef BOOST_DEDUCED_TYPENAME range_reference::type argument_type; Chris@102: typedef BOOST_DEDUCED_TYPENAME const KEY& result_type; Chris@102: Chris@102: result_type operator()( argument_type r ) const Chris@102: { Chris@102: return r.key; Chris@102: } Chris@102: }; Chris@102: Chris@102: template Chris@102: struct select_second_mutable< CMap > Chris@102: { Chris@102: typedef BOOST_DEDUCED_TYPENAME CMap map_type; Chris@102: typedef BOOST_DEDUCED_TYPENAME range_reference::type argument_type; Chris@102: typedef BOOST_DEDUCED_TYPENAME VALUE& result_type; Chris@102: Chris@102: result_type operator()( argument_type r ) const Chris@102: { Chris@102: return r.value; Chris@102: } Chris@102: }; Chris@102: Chris@102: template Chris@102: struct select_second_const< CMap > Chris@102: { Chris@102: typedef BOOST_DEDUCED_TYPENAME CMap map_type; Chris@102: typedef BOOST_DEDUCED_TYPENAME range_reference::type argument_type; Chris@102: typedef BOOST_DEDUCED_TYPENAME const VALUE& result_type; Chris@102: Chris@102: result_type operator()( argument_type r ) const Chris@102: { Chris@102: return r.value; Chris@102: } Chris@102: }; Chris@102: Chris@102: Chris@102: // specialization for CMapStringToString Chris@102: template<> Chris@102: struct select_first< CMapStringToString > Chris@102: { Chris@102: typedef range_reference::type argument_type; Chris@102: typedef const CString& result_type; Chris@102: Chris@102: result_type operator()( argument_type r ) const Chris@102: { Chris@102: return r.key; Chris@102: } Chris@102: }; Chris@102: Chris@102: template<> Chris@102: struct select_second_mutable< CMapStringToString > Chris@102: { Chris@102: typedef range_reference::type argument_type; Chris@102: typedef CString& result_type; Chris@102: Chris@102: result_type operator()( argument_type r ) const Chris@102: { Chris@102: return r.value; Chris@102: } Chris@102: }; Chris@102: Chris@102: template<> Chris@102: struct select_second_const< CMapStringToString > Chris@102: { Chris@102: typedef range_reference::type argument_type; Chris@102: typedef const CString& result_type; Chris@102: Chris@102: result_type operator()( argument_type r ) const Chris@102: { Chris@102: return r.value; Chris@102: } Chris@102: }; Chris@102: } // 'range_detail' Chris@102: } // 'boost' Chris@102: Chris@102: #endif // !defined(BOOST_RANGE_MFC_NO_CPAIR) Chris@102: Chris@102: #endif