get_pair_functor.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. /// \file relation/support/get_pair_functor.hpp
  9. /// \brief get_pair_functor definition
  10. #ifndef BOOST_BIMAP_RELATION_SUPPORT_GET_PAIR_FUNCTOR_HPP
  11. #define BOOST_BIMAP_RELATION_SUPPORT_GET_PAIR_FUNCTOR_HPP
  12. #if defined(_MSC_VER)
  13. #pragma once
  14. #endif
  15. #include <boost/config.hpp>
  16. #include <boost/bimap/relation/support/pair_by.hpp>
  17. namespace boost {
  18. namespace bimaps {
  19. namespace relation {
  20. namespace support {
  21. /// \brief A Functor that takes a relation as a parameter an return the desired view.
  22. /**
  23. This functor is included to help users of the relation class when using
  24. stl algorithms.
  25. See also member_at, pair_by().
  26. \ingroup relation_group
  27. **/
  28. template< class Tag, class Relation >
  29. struct get_pair_functor
  30. {
  31. BOOST_DEDUCED_TYPENAME result_of::pair_by<Tag,Relation>::type
  32. operator()( Relation & r ) const
  33. {
  34. return pair_by<Tag>(r);
  35. }
  36. BOOST_DEDUCED_TYPENAME result_of::pair_by<Tag,const Relation>::type
  37. operator()( const Relation & r ) const
  38. {
  39. return pair_by<Tag>(r);
  40. }
  41. };
  42. /// \brief A Functor that takes a relation as a parameter an return the above view.
  43. /**
  44. \ingroup relation_group
  45. **/
  46. template< class Relation >
  47. struct get_above_view_functor
  48. {
  49. BOOST_DEDUCED_TYPENAME Relation::above_view &
  50. operator()( Relation & r ) const
  51. {
  52. return r.get_view();
  53. }
  54. const BOOST_DEDUCED_TYPENAME Relation::above_view &
  55. operator()( const Relation & r ) const
  56. {
  57. return r.get_view();
  58. }
  59. };
  60. } // namespace support
  61. } // namespace relation
  62. } // namespace bimaps
  63. } // namespace boost
  64. #endif // BOOST_BIMAP_RELATION_SUPPORT_GET_PAIR_FUNCTOR_HPP