pair_by.hpp 3.0 KB

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