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/detail/access_builder.hpp
|
Chris@16
|
10 /// \brief Define macros to help building metafunctions
|
Chris@16
|
11
|
Chris@16
|
12 #ifndef BOOST_BIMAP_RELATION_ACCESS_BUILDER_HPP
|
Chris@16
|
13 #define BOOST_BIMAP_RELATION_ACCESS_BUILDER_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/member_with_tag.hpp>
|
Chris@16
|
22 #include <boost/bimap/relation/member_at.hpp>
|
Chris@16
|
23 #include <boost/call_traits.hpp>
|
Chris@16
|
24 #include <boost/type_traits/is_const.hpp>
|
Chris@16
|
25 #include <boost/mpl/if.hpp>
|
Chris@16
|
26 #include <boost/mpl/not.hpp>
|
Chris@16
|
27 #include <boost/utility/enable_if.hpp>
|
Chris@16
|
28
|
Chris@16
|
29
|
Chris@16
|
30 /******************************************************************************
|
Chris@16
|
31 BIMAP SYMMETRIC ACCESS RESULT OF
|
Chris@16
|
32 *******************************************************************************
|
Chris@16
|
33
|
Chris@16
|
34 namespace result_of {
|
Chris@16
|
35
|
Chris@16
|
36 template< class Tag, class SymmetricType >
|
Chris@16
|
37 struct NAME
|
Chris@16
|
38 {
|
Chris@16
|
39 typedef -unspecified- type;
|
Chris@16
|
40 };
|
Chris@16
|
41
|
Chris@16
|
42 } // namespace result_of
|
Chris@16
|
43
|
Chris@16
|
44 ******************************************************************************/
|
Chris@16
|
45
|
Chris@16
|
46 /*===========================================================================*/
|
Chris@16
|
47 #define BOOST_BIMAP_SYMMETRIC_ACCESS_RESULT_OF_BUILDER( \
|
Chris@16
|
48 \
|
Chris@16
|
49 NAME, \
|
Chris@16
|
50 METAFUNCTION_BASE \
|
Chris@16
|
51 ) \
|
Chris@16
|
52 \
|
Chris@16
|
53 namespace result_of { \
|
Chris@16
|
54 \
|
Chris@16
|
55 template< class Tag, class SymmetricType > \
|
Chris@16
|
56 struct NAME \
|
Chris@16
|
57 { \
|
Chris@16
|
58 typedef BOOST_DEDUCED_TYPENAME METAFUNCTION_BASE \
|
Chris@16
|
59 < \
|
Chris@16
|
60 Tag,SymmetricType \
|
Chris@16
|
61 \
|
Chris@16
|
62 >::type value_type; \
|
Chris@16
|
63 \
|
Chris@16
|
64 typedef BOOST_DEDUCED_TYPENAME mpl::if_< is_const<SymmetricType>, \
|
Chris@16
|
65 \
|
Chris@16
|
66 BOOST_DEDUCED_TYPENAME call_traits<value_type>::const_reference, \
|
Chris@16
|
67 \
|
Chris@16
|
68 BOOST_DEDUCED_TYPENAME call_traits<value_type>::reference \
|
Chris@16
|
69 \
|
Chris@16
|
70 >::type type; \
|
Chris@16
|
71 }; \
|
Chris@16
|
72 \
|
Chris@16
|
73 }
|
Chris@16
|
74 /*===========================================================================*/
|
Chris@16
|
75
|
Chris@16
|
76
|
Chris@16
|
77
|
Chris@16
|
78 /******************************************************************************
|
Chris@16
|
79 BIMAP SYMMETRIC ACCESS IMPLEMENTATION
|
Chris@16
|
80 *******************************************************************************
|
Chris@16
|
81
|
Chris@16
|
82 namespace detail {
|
Chris@16
|
83
|
Chris@16
|
84 template< class Tag, class SymmetricType >
|
Chris@16
|
85 typename result_of::NAME<Tag,SymmetricType>::type
|
Chris@16
|
86 NAME( Tag , const Relation & );
|
Chris@16
|
87
|
Chris@16
|
88 } // namespace detail
|
Chris@16
|
89
|
Chris@16
|
90 ******************************************************************************/
|
Chris@16
|
91
|
Chris@16
|
92
|
Chris@16
|
93 /*===========================================================================*/
|
Chris@16
|
94 #define BOOST_BIMAP_SYMMETRIC_ACCESS_IMPLEMENTATION_BUILDER( \
|
Chris@16
|
95 \
|
Chris@16
|
96 NAME, \
|
Chris@16
|
97 TP_SYMMETRIC, \
|
Chris@16
|
98 PARAMETER_NAME, \
|
Chris@16
|
99 LEFT_BODY, \
|
Chris@16
|
100 RIGHT_BODY \
|
Chris@16
|
101 ) \
|
Chris@16
|
102 \
|
Chris@16
|
103 namespace detail { \
|
Chris@16
|
104 \
|
Chris@16
|
105 \
|
Chris@16
|
106 \
|
Chris@16
|
107 template< class TP_SYMMETRIC > \
|
Chris@16
|
108 BOOST_DEDUCED_TYPENAME result_of::NAME \
|
Chris@16
|
109 < \
|
Chris@16
|
110 ::boost::bimaps::relation::member_at::left,TP_SYMMETRIC \
|
Chris@16
|
111 \
|
Chris@16
|
112 >::type \
|
Chris@16
|
113 \
|
Chris@16
|
114 NAME( ::boost::bimaps::relation::member_at::left, \
|
Chris@16
|
115 TP_SYMMETRIC & PARAMETER_NAME ) \
|
Chris@16
|
116 { \
|
Chris@16
|
117 LEFT_BODY; \
|
Chris@16
|
118 } \
|
Chris@16
|
119 \
|
Chris@16
|
120 template< class TP_SYMMETRIC > \
|
Chris@16
|
121 BOOST_DEDUCED_TYPENAME result_of::NAME \
|
Chris@16
|
122 < \
|
Chris@16
|
123 ::boost::bimaps::relation::member_at::right,TP_SYMMETRIC \
|
Chris@16
|
124 \
|
Chris@16
|
125 >::type \
|
Chris@16
|
126 \
|
Chris@16
|
127 NAME( ::boost::bimaps::relation::member_at::right, \
|
Chris@16
|
128 TP_SYMMETRIC & PARAMETER_NAME ) \
|
Chris@16
|
129 { \
|
Chris@16
|
130 RIGHT_BODY; \
|
Chris@16
|
131 } \
|
Chris@16
|
132 \
|
Chris@16
|
133 }
|
Chris@16
|
134 /*===========================================================================*/
|
Chris@16
|
135
|
Chris@16
|
136
|
Chris@16
|
137 /******************************************************************************
|
Chris@16
|
138 BIMAP RELATION ACCESS INTERFACE
|
Chris@16
|
139 *******************************************************************************
|
Chris@16
|
140
|
Chris@16
|
141 template< class Tag, class SymmetricType >
|
Chris@16
|
142 typename result_of::NAME<Tag,SymmetricType>::type
|
Chris@16
|
143 NAME( const SymmetricType & );
|
Chris@16
|
144
|
Chris@16
|
145 ******************************************************************************/
|
Chris@16
|
146
|
Chris@16
|
147 /*===========================================================================*/
|
Chris@16
|
148 #define BOOST_BIMAP_SYMMETRIC_ACCESS_INTERFACE_BUILDER( \
|
Chris@16
|
149 \
|
Chris@16
|
150 NAME \
|
Chris@16
|
151 ) \
|
Chris@16
|
152 \
|
Chris@16
|
153 template< class Tag, class SymmetricType > \
|
Chris@16
|
154 BOOST_DEDUCED_TYPENAME result_of::NAME<Tag,SymmetricType>::type \
|
Chris@16
|
155 NAME( SymmetricType & s ) \
|
Chris@16
|
156 { \
|
Chris@16
|
157 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support:: \
|
Chris@16
|
158 member_with_tag \
|
Chris@16
|
159 < \
|
Chris@16
|
160 Tag,SymmetricType \
|
Chris@16
|
161 \
|
Chris@16
|
162 >::type member_at_tag; \
|
Chris@16
|
163 \
|
Chris@16
|
164 return detail::NAME(member_at_tag(),s); \
|
Chris@16
|
165 }
|
Chris@16
|
166 /*===========================================================================*/
|
Chris@16
|
167
|
Chris@16
|
168
|
Chris@16
|
169 #endif // BOOST_BIMAP_RELATION_ACCESS_BUILDER_HPP
|
Chris@16
|
170
|