1 // Boost.Bimap 2 // 3 // Copyright (c) 2006-2007 Matias Capeletto 4 // 5 // Distributed under the Boost Software License, Version 1.0. 6 // (See accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE_1_0.txt) 8 9 /// \file relation/support/get_pair_functor.hpp 10 /// \brief get_pair_functor definition 11 12 #ifndef BOOST_BIMAP_RELATION_SUPPORT_GET_PAIR_FUNCTOR_HPP 13 #define BOOST_BIMAP_RELATION_SUPPORT_GET_PAIR_FUNCTOR_HPP 14 15 #if defined(_MSC_VER) 16 #pragma once 17 #endif 18 19 #include <boost/config.hpp> 20 21 #include <boost/bimap/relation/support/pair_by.hpp> 22 23 namespace boost { 24 namespace bimaps { 25 namespace relation { 26 namespace support { 27 28 /// \brief A Functor that takes a relation as a parameter an return the desired view. 29 /** 30 31 This functor is included to help users of the relation class when using 32 stl algorithms. 33 34 See also member_at, pair_by(). 35 \ingroup relation_group 36 37 **/ 38 39 template< class Tag, class Relation > 40 struct get_pair_functor 41 { 42 BOOST_DEDUCED_TYPENAME result_of::pair_by<Tag,Relation>::type operator ()boost::bimaps::relation::support::get_pair_functor43 operator()( Relation & r ) const 44 { 45 return pair_by<Tag>(r); 46 } 47 48 BOOST_DEDUCED_TYPENAME result_of::pair_by<Tag,const Relation>::type operator ()boost::bimaps::relation::support::get_pair_functor49 operator()( const Relation & r ) const 50 { 51 return pair_by<Tag>(r); 52 } 53 }; 54 55 56 /// \brief A Functor that takes a relation as a parameter an return the above view. 57 /** 58 59 \ingroup relation_group 60 **/ 61 62 template< class Relation > 63 struct get_above_view_functor 64 { 65 BOOST_DEDUCED_TYPENAME Relation::above_view & operator ()boost::bimaps::relation::support::get_above_view_functor66 operator()( Relation & r ) const 67 { 68 return r.get_view(); 69 } 70 71 const BOOST_DEDUCED_TYPENAME Relation::above_view & operator ()boost::bimaps::relation::support::get_above_view_functor72 operator()( const Relation & r ) const 73 { 74 return r.get_view(); 75 } 76 }; 77 78 } // namespace support 79 } // namespace relation 80 } // namespace bimaps 81 } // namespace boost 82 83 84 #endif // BOOST_BIMAP_RELATION_SUPPORT_GET_PAIR_FUNCTOR_HPP 85 86