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