get.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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.hpp
  9. /// \brief get<tag>(r) function
  10. #ifndef BOOST_BIMAP_RELATION_SUPPORT_GET_HPP
  11. #define BOOST_BIMAP_RELATION_SUPPORT_GET_HPP
  12. #if defined(_MSC_VER)
  13. #pragma once
  14. #endif
  15. #include <boost/config.hpp>
  16. #include <boost/bimap/relation/support/value_type_of.hpp>
  17. #include <boost/bimap/relation/detail/access_builder.hpp>
  18. #include <boost/mpl/if.hpp>
  19. #include <boost/type_traits/is_same.hpp>
  20. #include <boost/type_traits/is_const.hpp>
  21. #ifdef BOOST_BIMAP_ONLY_DOXYGEN_WILL_PROCESS_THE_FOLLOWING_LINES
  22. namespace boost {
  23. namespace bimaps {
  24. namespace relation {
  25. namespace support {
  26. /** \brief Gets a pair view of the relation.
  27. \ingroup relation_group
  28. **/
  29. template< class Tag, class SymmetricType >
  30. BOOST_DEDUCED_TYPENAME result_of::get<Tag,SymmetricType>::type
  31. get( SymmetricType & );
  32. } // namespace support
  33. } // namespace relation
  34. } // namespace bimaps
  35. } // namespace boost
  36. #endif // BOOST_BIMAP_ONLY_DOXYGEN_WILL_PROCESS_THE_FOLLOWING_LINES
  37. #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
  38. namespace boost {
  39. namespace bimaps {
  40. namespace relation {
  41. namespace support {
  42. // Since it is very error-prone to directly write the hole bunch
  43. // of relation accesor. They are buil from litle macro blocks that
  44. // are both more readable, leading to self docummenting code and a
  45. // lot more easier to understand and mantain.
  46. // It is very important to note that the three building blocks have
  47. // to laid in the same namespace in order to work. There is also
  48. // important to keep them in order.
  49. // The forward declaration are not necesary but they help a lot to
  50. // the reader, as they undercover what is the signature of the
  51. // result code.
  52. // In the end, it is not quicker to do it in this way because you
  53. // write a lot. But this code has no complexity at all and almost
  54. // every word writed is for documentation.
  55. // Result of
  56. // -------------------------------------------------------------------------
  57. /*
  58. namespace result_of {
  59. template< class Tag, class Relation >
  60. struct get<Tag,Relation>;
  61. {
  62. typedef -unspecified- type;
  63. };
  64. } // namespace result_of
  65. */
  66. BOOST_BIMAP_SYMMETRIC_ACCESS_RESULT_OF_BUILDER
  67. (
  68. get,
  69. value_type_of
  70. )
  71. // Implementation
  72. // -------------------------------------------------------------------------
  73. BOOST_BIMAP_SYMMETRIC_ACCESS_IMPLEMENTATION_BUILDER
  74. (
  75. get,
  76. SymmetricType,
  77. st,
  78. return st.get_left(),
  79. return st.get_right()
  80. )
  81. namespace detail {
  82. template< class SymmetricType >
  83. BOOST_DEDUCED_TYPENAME result_of::get<
  84. ::boost::bimaps::relation::member_at::info, SymmetricType >::type
  85. get(::boost::bimaps::relation::member_at::info, SymmetricType & rel)
  86. {
  87. return rel.info;
  88. }
  89. } // namespace detail
  90. // Interface
  91. //----------------------------------------------------------------------------
  92. BOOST_BIMAP_SYMMETRIC_ACCESS_INTERFACE_BUILDER
  93. (
  94. get
  95. )
  96. } // namespace support
  97. } // namespace relation
  98. } // namespace bimaps
  99. } // namespace boost
  100. #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
  101. #endif // BOOST_BIMAP_RELATION_SUPPORT_GET_HPP