map_by.hpp 3.2 KB

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