Chris@16
|
1 // Boost.Bimap
|
Chris@16
|
2 //
|
Chris@16
|
3 // Copyright (c) 2006-2007 Matias Capeletto
|
Chris@16
|
4 //
|
Chris@16
|
5 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
6 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8
|
Chris@16
|
9 /// \file relation/support/get.hpp
|
Chris@16
|
10 /// \brief get<tag>(r) function
|
Chris@16
|
11
|
Chris@16
|
12 #ifndef BOOST_BIMAP_RELATION_SUPPORT_GET_HPP
|
Chris@16
|
13 #define BOOST_BIMAP_RELATION_SUPPORT_GET_HPP
|
Chris@16
|
14
|
Chris@101
|
15 #if defined(_MSC_VER)
|
Chris@16
|
16 #pragma once
|
Chris@16
|
17 #endif
|
Chris@16
|
18
|
Chris@16
|
19 #include <boost/config.hpp>
|
Chris@16
|
20
|
Chris@16
|
21 #include <boost/bimap/relation/support/value_type_of.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 #include <boost/bimap/relation/detail/access_builder.hpp>
|
Chris@16
|
24
|
Chris@16
|
25 #include <boost/mpl/if.hpp>
|
Chris@16
|
26 #include <boost/type_traits/is_same.hpp>
|
Chris@16
|
27 #include <boost/type_traits/is_const.hpp>
|
Chris@16
|
28
|
Chris@16
|
29 #ifdef BOOST_BIMAP_ONLY_DOXYGEN_WILL_PROCESS_THE_FOLLOWING_LINES
|
Chris@16
|
30
|
Chris@16
|
31
|
Chris@16
|
32 namespace boost {
|
Chris@16
|
33 namespace bimaps {
|
Chris@16
|
34 namespace relation {
|
Chris@16
|
35 namespace support {
|
Chris@16
|
36
|
Chris@16
|
37 /** \brief Gets a pair view of the relation.
|
Chris@16
|
38
|
Chris@16
|
39 \ingroup relation_group
|
Chris@16
|
40 **/
|
Chris@16
|
41
|
Chris@16
|
42 template< class Tag, class SymmetricType >
|
Chris@16
|
43 BOOST_DEDUCED_TYPENAME result_of::get<Tag,SymmetricType>::type
|
Chris@16
|
44 get( SymmetricType & );
|
Chris@16
|
45
|
Chris@16
|
46 } // namespace support
|
Chris@16
|
47 } // namespace relation
|
Chris@16
|
48 } // namespace bimaps
|
Chris@16
|
49 } // namespace boost
|
Chris@16
|
50
|
Chris@16
|
51 #endif // BOOST_BIMAP_ONLY_DOXYGEN_WILL_PROCESS_THE_FOLLOWING_LINES
|
Chris@16
|
52
|
Chris@16
|
53
|
Chris@16
|
54
|
Chris@16
|
55 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
|
Chris@16
|
56
|
Chris@16
|
57 namespace boost {
|
Chris@16
|
58 namespace bimaps {
|
Chris@16
|
59 namespace relation {
|
Chris@16
|
60 namespace support {
|
Chris@16
|
61
|
Chris@16
|
62 // Since it is very error-prone to directly write the hole bunch
|
Chris@16
|
63 // of relation accesor. They are buil from litle macro blocks that
|
Chris@16
|
64 // are both more readable, leading to self docummenting code and a
|
Chris@16
|
65 // lot more easier to understand and mantain.
|
Chris@16
|
66 // It is very important to note that the three building blocks have
|
Chris@16
|
67 // to laid in the same namespace in order to work. There is also
|
Chris@16
|
68 // important to keep them in order.
|
Chris@16
|
69 // The forward declaration are not necesary but they help a lot to
|
Chris@16
|
70 // the reader, as they undercover what is the signature of the
|
Chris@16
|
71 // result code.
|
Chris@16
|
72 // In the end, it is not quicker to do it in this way because you
|
Chris@16
|
73 // write a lot. But this code has no complexity at all and almost
|
Chris@16
|
74 // every word writed is for documentation.
|
Chris@16
|
75
|
Chris@16
|
76 // Result of
|
Chris@16
|
77 // -------------------------------------------------------------------------
|
Chris@16
|
78 /*
|
Chris@16
|
79 namespace result_of {
|
Chris@16
|
80
|
Chris@16
|
81 template< class Tag, class Relation >
|
Chris@16
|
82 struct get<Tag,Relation>;
|
Chris@16
|
83 {
|
Chris@16
|
84 typedef -unspecified- type;
|
Chris@16
|
85 };
|
Chris@16
|
86
|
Chris@16
|
87 } // namespace result_of
|
Chris@16
|
88
|
Chris@16
|
89 */
|
Chris@16
|
90
|
Chris@16
|
91 BOOST_BIMAP_SYMMETRIC_ACCESS_RESULT_OF_BUILDER
|
Chris@16
|
92 (
|
Chris@16
|
93 get,
|
Chris@16
|
94 value_type_of
|
Chris@16
|
95 )
|
Chris@16
|
96
|
Chris@16
|
97
|
Chris@16
|
98
|
Chris@16
|
99 // Implementation
|
Chris@16
|
100 // -------------------------------------------------------------------------
|
Chris@16
|
101
|
Chris@16
|
102 BOOST_BIMAP_SYMMETRIC_ACCESS_IMPLEMENTATION_BUILDER
|
Chris@16
|
103 (
|
Chris@16
|
104 get,
|
Chris@16
|
105 SymmetricType,
|
Chris@16
|
106 st,
|
Chris@16
|
107 return st.get_left(),
|
Chris@16
|
108 return st.get_right()
|
Chris@16
|
109 )
|
Chris@16
|
110
|
Chris@16
|
111 namespace detail {
|
Chris@16
|
112
|
Chris@16
|
113 template< class SymmetricType >
|
Chris@16
|
114 BOOST_DEDUCED_TYPENAME result_of::get<
|
Chris@16
|
115 ::boost::bimaps::relation::member_at::info, SymmetricType >::type
|
Chris@16
|
116 get(::boost::bimaps::relation::member_at::info, SymmetricType & rel)
|
Chris@16
|
117 {
|
Chris@16
|
118 return rel.info;
|
Chris@16
|
119 }
|
Chris@16
|
120
|
Chris@16
|
121 } // namespace detail
|
Chris@16
|
122
|
Chris@16
|
123 // Interface
|
Chris@16
|
124 //----------------------------------------------------------------------------
|
Chris@16
|
125
|
Chris@16
|
126 BOOST_BIMAP_SYMMETRIC_ACCESS_INTERFACE_BUILDER
|
Chris@16
|
127 (
|
Chris@16
|
128 get
|
Chris@16
|
129 )
|
Chris@16
|
130
|
Chris@16
|
131
|
Chris@16
|
132 } // namespace support
|
Chris@16
|
133 } // namespace relation
|
Chris@16
|
134 } // namespace bimaps
|
Chris@16
|
135 } // namespace boost
|
Chris@16
|
136
|
Chris@16
|
137 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
|
Chris@16
|
138
|
Chris@16
|
139 #endif // BOOST_BIMAP_RELATION_SUPPORT_GET_HPP
|
Chris@16
|
140
|