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/structured_pair.hpp
|
Chris@16
|
10 /// \brief Defines the structured_pair class.
|
Chris@16
|
11
|
Chris@16
|
12 #ifndef BOOST_BIMAP_RELATION_STRUCTURED_PAIR_HPP
|
Chris@16
|
13 #define BOOST_BIMAP_RELATION_STRUCTURED_PAIR_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 <utility>
|
Chris@16
|
22
|
Chris@16
|
23 #include <boost/type_traits/remove_const.hpp>
|
Chris@16
|
24
|
Chris@16
|
25 #include <boost/mpl/aux_/na.hpp>
|
Chris@16
|
26
|
Chris@16
|
27 #include <boost/call_traits.hpp>
|
Chris@16
|
28
|
Chris@16
|
29 #include <boost/utility/enable_if.hpp>
|
Chris@16
|
30 #include <boost/type_traits/is_same.hpp>
|
Chris@16
|
31 #include <boost/mpl/if.hpp>
|
Chris@16
|
32 #include <boost/mpl/vector.hpp>
|
Chris@16
|
33
|
Chris@16
|
34 #include <boost/bimap/detail/debug/static_error.hpp>
|
Chris@16
|
35 #include <boost/bimap/relation/pair_layout.hpp>
|
Chris@16
|
36 #include <boost/bimap/relation/symmetrical_base.hpp>
|
Chris@16
|
37 #include <boost/bimap/relation/support/get.hpp>
|
Chris@16
|
38 #include <boost/bimap/tags/support/value_type_of.hpp>
|
Chris@16
|
39
|
Chris@16
|
40
|
Chris@16
|
41
|
Chris@16
|
42 namespace boost {
|
Chris@16
|
43 namespace bimaps {
|
Chris@16
|
44 namespace relation {
|
Chris@16
|
45
|
Chris@16
|
46 namespace detail {
|
Chris@16
|
47
|
Chris@16
|
48 /// \brief Storage definition of the left view of a mutant relation.
|
Chris@16
|
49 /**
|
Chris@16
|
50
|
Chris@16
|
51 See also storage_finder, mirror_storage.
|
Chris@16
|
52 **/
|
Chris@16
|
53
|
Chris@16
|
54 template< class FirstType, class SecondType >
|
Chris@16
|
55 class normal_storage :
|
Chris@16
|
56 public symmetrical_base<FirstType,SecondType>
|
Chris@16
|
57 {
|
Chris@16
|
58 typedef symmetrical_base<FirstType,SecondType> base_;
|
Chris@16
|
59
|
Chris@16
|
60 public:
|
Chris@16
|
61
|
Chris@16
|
62 typedef normal_storage storage_;
|
Chris@16
|
63
|
Chris@16
|
64 typedef BOOST_DEDUCED_TYPENAME base_::left_value_type first_type;
|
Chris@16
|
65 typedef BOOST_DEDUCED_TYPENAME base_::right_value_type second_type;
|
Chris@16
|
66
|
Chris@16
|
67 first_type first;
|
Chris@16
|
68 second_type second;
|
Chris@16
|
69
|
Chris@16
|
70 normal_storage() {}
|
Chris@16
|
71
|
Chris@16
|
72 normal_storage(BOOST_DEDUCED_TYPENAME ::boost::call_traits<
|
Chris@16
|
73 first_type >::param_type f,
|
Chris@16
|
74 BOOST_DEDUCED_TYPENAME ::boost::call_traits<
|
Chris@16
|
75 second_type>::param_type s)
|
Chris@16
|
76
|
Chris@16
|
77 : first(f), second(s) {}
|
Chris@16
|
78
|
Chris@16
|
79 BOOST_DEDUCED_TYPENAME base_:: left_value_type & get_left() { return first; }
|
Chris@16
|
80 const BOOST_DEDUCED_TYPENAME base_:: left_value_type & get_left()const { return first; }
|
Chris@16
|
81 BOOST_DEDUCED_TYPENAME base_::right_value_type & get_right() { return second; }
|
Chris@16
|
82 const BOOST_DEDUCED_TYPENAME base_::right_value_type & get_right()const { return second; }
|
Chris@16
|
83 };
|
Chris@16
|
84
|
Chris@16
|
85 /// \brief Storage definition of the right view of a mutant relation.
|
Chris@16
|
86 /**
|
Chris@16
|
87
|
Chris@16
|
88 See also storage_finder, normal_storage.
|
Chris@16
|
89 **/
|
Chris@16
|
90
|
Chris@16
|
91 template< class FirstType, class SecondType >
|
Chris@16
|
92 class mirror_storage :
|
Chris@16
|
93 public symmetrical_base<SecondType,FirstType>
|
Chris@16
|
94 {
|
Chris@16
|
95 typedef symmetrical_base<SecondType,FirstType> base_;
|
Chris@16
|
96
|
Chris@16
|
97 public:
|
Chris@16
|
98
|
Chris@16
|
99 typedef mirror_storage storage_;
|
Chris@16
|
100
|
Chris@16
|
101 typedef BOOST_DEDUCED_TYPENAME base_::left_value_type second_type;
|
Chris@16
|
102 typedef BOOST_DEDUCED_TYPENAME base_::right_value_type first_type;
|
Chris@16
|
103
|
Chris@16
|
104 second_type second;
|
Chris@16
|
105 first_type first;
|
Chris@16
|
106
|
Chris@16
|
107 mirror_storage() {}
|
Chris@16
|
108
|
Chris@16
|
109 mirror_storage(BOOST_DEDUCED_TYPENAME ::boost::call_traits<first_type >::param_type f,
|
Chris@16
|
110 BOOST_DEDUCED_TYPENAME ::boost::call_traits<second_type >::param_type s)
|
Chris@16
|
111
|
Chris@16
|
112 : second(s), first(f) {}
|
Chris@16
|
113
|
Chris@16
|
114 BOOST_DEDUCED_TYPENAME base_:: left_value_type & get_left() { return second; }
|
Chris@16
|
115 const BOOST_DEDUCED_TYPENAME base_:: left_value_type & get_left()const { return second; }
|
Chris@16
|
116 BOOST_DEDUCED_TYPENAME base_::right_value_type & get_right() { return first; }
|
Chris@16
|
117 const BOOST_DEDUCED_TYPENAME base_::right_value_type & get_right()const { return first; }
|
Chris@16
|
118 };
|
Chris@16
|
119
|
Chris@16
|
120 /** \struct boost::bimaps::relation::storage_finder
|
Chris@16
|
121 \brief Obtain the a storage with the correct layout.
|
Chris@16
|
122
|
Chris@16
|
123 \code
|
Chris@16
|
124 template< class FirstType, class SecondType, class Layout >
|
Chris@16
|
125 struct storage_finder
|
Chris@16
|
126 {
|
Chris@16
|
127 typedef {normal/mirror}_storage<FirstType,SecondType> type;
|
Chris@16
|
128 };
|
Chris@16
|
129 \endcode
|
Chris@16
|
130
|
Chris@16
|
131 See also normal_storage, mirror_storage.
|
Chris@16
|
132 **/
|
Chris@16
|
133
|
Chris@16
|
134 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
|
Chris@16
|
135
|
Chris@16
|
136 template
|
Chris@16
|
137 <
|
Chris@16
|
138 class FirstType,
|
Chris@16
|
139 class SecondType,
|
Chris@16
|
140 class Layout
|
Chris@16
|
141 >
|
Chris@16
|
142 struct storage_finder
|
Chris@16
|
143 {
|
Chris@16
|
144 typedef normal_storage<FirstType,SecondType> type;
|
Chris@16
|
145 };
|
Chris@16
|
146
|
Chris@16
|
147 template
|
Chris@16
|
148 <
|
Chris@16
|
149 class FirstType,
|
Chris@16
|
150 class SecondType
|
Chris@16
|
151 >
|
Chris@16
|
152 struct storage_finder<FirstType,SecondType,mirror_layout>
|
Chris@16
|
153 {
|
Chris@16
|
154 typedef mirror_storage<FirstType,SecondType> type;
|
Chris@16
|
155 };
|
Chris@16
|
156
|
Chris@16
|
157 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
|
Chris@16
|
158
|
Chris@16
|
159
|
Chris@16
|
160 template< class TA, class TB, class Info, class Layout >
|
Chris@16
|
161 class pair_info_hook :
|
Chris@16
|
162 public ::boost::bimaps::relation::detail::storage_finder<TA,TB,Layout>::type
|
Chris@16
|
163 {
|
Chris@16
|
164 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::detail::storage_finder<TA,TB,Layout>::type base_;
|
Chris@16
|
165
|
Chris@16
|
166 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::tags::support::
|
Chris@16
|
167 default_tagged<Info,member_at::info>::type tagged_info_type;
|
Chris@16
|
168
|
Chris@16
|
169 public:
|
Chris@16
|
170 typedef BOOST_DEDUCED_TYPENAME tagged_info_type::value_type info_type;
|
Chris@16
|
171 typedef BOOST_DEDUCED_TYPENAME tagged_info_type::tag info_tag;
|
Chris@16
|
172
|
Chris@16
|
173 info_type info;
|
Chris@16
|
174
|
Chris@16
|
175 protected:
|
Chris@16
|
176
|
Chris@16
|
177 pair_info_hook() {}
|
Chris@16
|
178
|
Chris@16
|
179 pair_info_hook( BOOST_DEDUCED_TYPENAME ::boost::call_traits<
|
Chris@16
|
180 BOOST_DEDUCED_TYPENAME base_::first_type
|
Chris@16
|
181 >::param_type f,
|
Chris@16
|
182 BOOST_DEDUCED_TYPENAME ::boost::call_traits<
|
Chris@16
|
183 BOOST_DEDUCED_TYPENAME base_::second_type
|
Chris@16
|
184 >::param_type s,
|
Chris@16
|
185 BOOST_DEDUCED_TYPENAME ::boost::call_traits<
|
Chris@16
|
186 info_type
|
Chris@16
|
187 >::param_type i = info_type() )
|
Chris@16
|
188 : base_(f,s), info(i) {}
|
Chris@16
|
189
|
Chris@16
|
190 template< class Pair >
|
Chris@16
|
191 pair_info_hook( const Pair & p) :
|
Chris@16
|
192 base_(p.first,p.second),
|
Chris@16
|
193 info(p.info) {}
|
Chris@16
|
194
|
Chris@16
|
195 template< class Pair >
|
Chris@16
|
196 void change_to( const Pair & p )
|
Chris@16
|
197 {
|
Chris@16
|
198 base_::first = p.first ;
|
Chris@16
|
199 base_::second = p.second;
|
Chris@16
|
200 info = p.info ;
|
Chris@16
|
201 }
|
Chris@16
|
202
|
Chris@16
|
203 void clear_info()
|
Chris@16
|
204 {
|
Chris@16
|
205 info = info_type();
|
Chris@16
|
206 };
|
Chris@16
|
207 };
|
Chris@16
|
208
|
Chris@16
|
209 template< class TA, class TB, class Layout>
|
Chris@16
|
210 class pair_info_hook<TA,TB,::boost::mpl::na,Layout> :
|
Chris@16
|
211 public ::boost::bimaps::relation::detail::storage_finder<TA,TB,Layout>::type
|
Chris@16
|
212 {
|
Chris@16
|
213 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::detail::storage_finder<TA,TB,Layout>::type base_;
|
Chris@16
|
214
|
Chris@16
|
215 public:
|
Chris@16
|
216 typedef ::boost::mpl::na info_type;
|
Chris@16
|
217 typedef member_at::info info_tag;
|
Chris@16
|
218
|
Chris@16
|
219 protected:
|
Chris@16
|
220
|
Chris@16
|
221 pair_info_hook() {}
|
Chris@16
|
222
|
Chris@16
|
223 pair_info_hook( BOOST_DEDUCED_TYPENAME ::boost::call_traits<
|
Chris@16
|
224 BOOST_DEDUCED_TYPENAME base_::first_type
|
Chris@16
|
225 >::param_type f,
|
Chris@16
|
226 BOOST_DEDUCED_TYPENAME ::boost::call_traits<
|
Chris@16
|
227 BOOST_DEDUCED_TYPENAME base_::second_type
|
Chris@16
|
228 >::param_type s)
|
Chris@16
|
229
|
Chris@16
|
230 : base_(f,s) {}
|
Chris@16
|
231
|
Chris@16
|
232 template< class Pair >
|
Chris@16
|
233 pair_info_hook( const Pair & p ) :
|
Chris@16
|
234 base_(p.first,p.second) {}
|
Chris@16
|
235
|
Chris@16
|
236 template< class Pair >
|
Chris@16
|
237 void change_to( const Pair & p )
|
Chris@16
|
238 {
|
Chris@16
|
239 base_::first = p.first ;
|
Chris@16
|
240 base_::second = p.second;
|
Chris@16
|
241 }
|
Chris@16
|
242
|
Chris@16
|
243 void clear_info() {};
|
Chris@16
|
244 };
|
Chris@16
|
245
|
Chris@16
|
246
|
Chris@16
|
247
|
Chris@16
|
248 } // namespace detail
|
Chris@16
|
249
|
Chris@16
|
250 template< class TA, class TB, class Info, bool FM >
|
Chris@16
|
251 class mutant_relation;
|
Chris@16
|
252
|
Chris@16
|
253
|
Chris@16
|
254 /// \brief A std::pair signature compatible class that allows you to control
|
Chris@16
|
255 /// the internal structure of the data.
|
Chris@16
|
256 /**
|
Chris@16
|
257 This class allows you to specify the order in wich the two data types will be
|
Chris@16
|
258 in the layout of the class.
|
Chris@16
|
259 **/
|
Chris@16
|
260
|
Chris@16
|
261 template< class FirstType, class SecondType, class Info, class Layout = normal_layout >
|
Chris@16
|
262 class structured_pair :
|
Chris@16
|
263
|
Chris@16
|
264 public ::boost::bimaps::relation::detail::pair_info_hook
|
Chris@16
|
265 <
|
Chris@16
|
266 FirstType, SecondType,
|
Chris@16
|
267 Info,
|
Chris@16
|
268 Layout
|
Chris@16
|
269
|
Chris@16
|
270 >
|
Chris@16
|
271
|
Chris@16
|
272 {
|
Chris@16
|
273 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::detail::pair_info_hook
|
Chris@16
|
274 <
|
Chris@16
|
275 FirstType, SecondType,
|
Chris@16
|
276 Info,
|
Chris@16
|
277 Layout
|
Chris@16
|
278
|
Chris@16
|
279 > base_;
|
Chris@16
|
280
|
Chris@16
|
281 public:
|
Chris@16
|
282
|
Chris@16
|
283 typedef ::boost::mpl::vector3<
|
Chris@16
|
284 structured_pair< FirstType, SecondType, Info, normal_layout >,
|
Chris@16
|
285 structured_pair< FirstType, SecondType, Info, mirror_layout >,
|
Chris@16
|
286 BOOST_DEDUCED_TYPENAME ::boost::mpl::if_<
|
Chris@16
|
287 BOOST_DEDUCED_TYPENAME ::boost::is_same<Layout, normal_layout>::type,
|
Chris@16
|
288 mutant_relation< FirstType, SecondType, Info, true >,
|
Chris@16
|
289 mutant_relation< SecondType, FirstType, Info, true >
|
Chris@16
|
290 >::type
|
Chris@16
|
291
|
Chris@16
|
292 > mutant_views;
|
Chris@16
|
293
|
Chris@16
|
294 structured_pair() {}
|
Chris@16
|
295
|
Chris@16
|
296 structured_pair(BOOST_DEDUCED_TYPENAME boost::call_traits<
|
Chris@16
|
297 BOOST_DEDUCED_TYPENAME base_::first_type >::param_type f,
|
Chris@16
|
298 BOOST_DEDUCED_TYPENAME boost::call_traits<
|
Chris@16
|
299 BOOST_DEDUCED_TYPENAME base_::second_type >::param_type s)
|
Chris@16
|
300 : base_(f,s) {}
|
Chris@16
|
301
|
Chris@16
|
302 structured_pair(BOOST_DEDUCED_TYPENAME boost::call_traits<
|
Chris@16
|
303 BOOST_DEDUCED_TYPENAME base_::first_type >::param_type f,
|
Chris@16
|
304 BOOST_DEDUCED_TYPENAME boost::call_traits<
|
Chris@16
|
305 BOOST_DEDUCED_TYPENAME base_::second_type >::param_type s,
|
Chris@16
|
306 BOOST_DEDUCED_TYPENAME boost::call_traits<
|
Chris@16
|
307 BOOST_DEDUCED_TYPENAME base_::info_type >::param_type i)
|
Chris@16
|
308 : base_(f,s,i) {}
|
Chris@16
|
309
|
Chris@16
|
310 template< class OtherLayout >
|
Chris@16
|
311 structured_pair(
|
Chris@16
|
312 const structured_pair<FirstType,SecondType,Info,OtherLayout> & p)
|
Chris@16
|
313 : base_(p) {}
|
Chris@16
|
314
|
Chris@16
|
315 template< class OtherLayout >
|
Chris@16
|
316 structured_pair& operator=(
|
Chris@16
|
317 const structured_pair<FirstType,SecondType,OtherLayout> & p)
|
Chris@16
|
318 {
|
Chris@16
|
319 base_::change_to(p);
|
Chris@16
|
320 return *this;
|
Chris@16
|
321 }
|
Chris@16
|
322
|
Chris@16
|
323 template< class First, class Second >
|
Chris@16
|
324 structured_pair(const std::pair<First,Second> & p) :
|
Chris@16
|
325 base_(p.first,p.second)
|
Chris@16
|
326 {}
|
Chris@16
|
327
|
Chris@16
|
328 template< class First, class Second >
|
Chris@16
|
329 structured_pair& operator=(const std::pair<First,Second> & p)
|
Chris@16
|
330 {
|
Chris@16
|
331 base_::first = p.first;
|
Chris@16
|
332 base_::second = p.second;
|
Chris@16
|
333 base_::clear_info();
|
Chris@16
|
334 return *this;
|
Chris@16
|
335 }
|
Chris@16
|
336
|
Chris@16
|
337 template< class Tag >
|
Chris@16
|
338 const BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
|
Chris@16
|
339 result_of::get<Tag,const structured_pair>::type
|
Chris@101
|
340 get() const
|
Chris@16
|
341 {
|
Chris@16
|
342 return ::boost::bimaps::relation::support::get<Tag>(*this);
|
Chris@16
|
343 }
|
Chris@16
|
344
|
Chris@16
|
345 template< class Tag >
|
Chris@16
|
346 BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::
|
Chris@16
|
347 result_of::get<Tag,structured_pair>::type
|
Chris@101
|
348 get()
|
Chris@16
|
349 {
|
Chris@16
|
350 return ::boost::bimaps::relation::support::get<Tag>(*this);
|
Chris@16
|
351 }
|
Chris@16
|
352 };
|
Chris@16
|
353
|
Chris@16
|
354 // structured_pair - structured_pair
|
Chris@16
|
355
|
Chris@16
|
356 template< class FirstType, class SecondType, class Info, class Layout1, class Layout2 >
|
Chris@16
|
357 bool operator==(const structured_pair<FirstType,SecondType,Info,Layout1> & a,
|
Chris@16
|
358 const structured_pair<FirstType,SecondType,Info,Layout2> & b)
|
Chris@16
|
359 {
|
Chris@16
|
360 return ( ( a.first == b.first ) &&
|
Chris@16
|
361 ( a.second == b.second ) );
|
Chris@16
|
362 }
|
Chris@16
|
363
|
Chris@16
|
364 template< class FirstType, class SecondType, class Info, class Layout1, class Layout2 >
|
Chris@16
|
365 bool operator!=(const structured_pair<FirstType,SecondType,Info,Layout1> & a,
|
Chris@16
|
366 const structured_pair<FirstType,SecondType,Info,Layout2> & b)
|
Chris@16
|
367 {
|
Chris@16
|
368 return ! ( a == b );
|
Chris@16
|
369 }
|
Chris@16
|
370
|
Chris@16
|
371 template< class FirstType, class SecondType, class Info, class Layout1, class Layout2 >
|
Chris@16
|
372 bool operator<(const structured_pair<FirstType,SecondType,Info,Layout1> & a,
|
Chris@16
|
373 const structured_pair<FirstType,SecondType,Info,Layout2> & b)
|
Chris@16
|
374 {
|
Chris@16
|
375 return ( ( a.first < b.first ) ||
|
Chris@16
|
376 (( a.first == b.first ) && ( a.second < b.second )));
|
Chris@16
|
377 }
|
Chris@16
|
378
|
Chris@16
|
379 template< class FirstType, class SecondType, class Info, class Layout1, class Layout2 >
|
Chris@16
|
380 bool operator<=(const structured_pair<FirstType,SecondType,Info,Layout1> & a,
|
Chris@16
|
381 const structured_pair<FirstType,SecondType,Info,Layout2> & b)
|
Chris@16
|
382 {
|
Chris@16
|
383 return ( ( a.first < b.first ) ||
|
Chris@16
|
384 (( a.first == b.first ) && ( a.second <= b.second )));
|
Chris@16
|
385 }
|
Chris@16
|
386
|
Chris@16
|
387 template< class FirstType, class SecondType, class Info, class Layout1, class Layout2 >
|
Chris@16
|
388 bool operator>(const structured_pair<FirstType,SecondType,Info,Layout1> & a,
|
Chris@16
|
389 const structured_pair<FirstType,SecondType,Info,Layout2> & b)
|
Chris@16
|
390 {
|
Chris@16
|
391 return ( ( a.first > b.first ) ||
|
Chris@16
|
392 (( a.first == b.first ) && ( a.second > b.second )));
|
Chris@16
|
393 }
|
Chris@16
|
394
|
Chris@16
|
395 template< class FirstType, class SecondType, class Info, class Layout1, class Layout2 >
|
Chris@16
|
396 bool operator>=(const structured_pair<FirstType,SecondType,Info,Layout1> & a,
|
Chris@16
|
397 const structured_pair<FirstType,SecondType,Info,Layout2> & b)
|
Chris@16
|
398 {
|
Chris@16
|
399 return ( ( a.first > b.first ) ||
|
Chris@16
|
400 (( a.first == b.first ) && ( a.second >= b.second )));
|
Chris@16
|
401 }
|
Chris@16
|
402
|
Chris@16
|
403 // structured_pair - std::pair
|
Chris@16
|
404
|
Chris@16
|
405 template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
|
Chris@16
|
406 bool operator==(const structured_pair<FirstType,SecondType,Info,Layout> & a,
|
Chris@16
|
407 const std::pair<F,S> & b)
|
Chris@16
|
408 {
|
Chris@16
|
409 return ( ( a.first == b.first ) &&
|
Chris@16
|
410 ( a.second == b.second ) );
|
Chris@16
|
411 }
|
Chris@16
|
412
|
Chris@16
|
413 template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
|
Chris@16
|
414 bool operator!=(const structured_pair<FirstType,SecondType,Info,Layout> & a,
|
Chris@16
|
415 const std::pair<F,S> & b)
|
Chris@16
|
416 {
|
Chris@16
|
417 return ! ( a == b );
|
Chris@16
|
418 }
|
Chris@16
|
419
|
Chris@16
|
420 template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
|
Chris@16
|
421 bool operator<(const structured_pair<FirstType,SecondType,Info,Layout> & a,
|
Chris@16
|
422 const std::pair<F,S> & b)
|
Chris@16
|
423 {
|
Chris@16
|
424 return ( ( a.first < b.first ) ||
|
Chris@16
|
425 (( a.first == b.first ) && ( a.second < b.second )));
|
Chris@16
|
426 }
|
Chris@16
|
427
|
Chris@16
|
428 template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
|
Chris@16
|
429 bool operator<=(const structured_pair<FirstType,SecondType,Info,Layout> & a,
|
Chris@16
|
430 const std::pair<F,S> & b)
|
Chris@16
|
431 {
|
Chris@16
|
432 return ( ( a.first < b.first ) ||
|
Chris@16
|
433 (( a.first == b.first ) && ( a.second <= b.second )));
|
Chris@16
|
434 }
|
Chris@16
|
435
|
Chris@16
|
436 template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
|
Chris@16
|
437 bool operator>(const structured_pair<FirstType,SecondType,Info,Layout> & a,
|
Chris@16
|
438 const std::pair<F,S> & b)
|
Chris@16
|
439 {
|
Chris@16
|
440 return ( ( a.first > b.first ) ||
|
Chris@16
|
441 (( a.first == b.first ) && ( a.second > b.second )));
|
Chris@16
|
442 }
|
Chris@16
|
443
|
Chris@16
|
444 template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
|
Chris@16
|
445 bool operator>=(const structured_pair<FirstType,SecondType,Info,Layout> & a,
|
Chris@16
|
446 const std::pair<F,S> & b)
|
Chris@16
|
447 {
|
Chris@16
|
448 return ( ( a.first > b.first ) ||
|
Chris@16
|
449 (( a.first == b.first ) && ( a.second >= b.second )));
|
Chris@16
|
450 }
|
Chris@16
|
451
|
Chris@16
|
452 // std::pair - sturctured_pair
|
Chris@16
|
453
|
Chris@16
|
454 template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
|
Chris@16
|
455 bool operator==(const std::pair<F,S> & a,
|
Chris@16
|
456 const structured_pair<FirstType,SecondType,Info,Layout> & b)
|
Chris@16
|
457 {
|
Chris@16
|
458 return ( ( a.first == b.first ) &&
|
Chris@16
|
459 ( a.second == b.second ) );
|
Chris@16
|
460 }
|
Chris@16
|
461
|
Chris@16
|
462 template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
|
Chris@16
|
463 bool operator!=(const std::pair<F,S> & a,
|
Chris@16
|
464 const structured_pair<FirstType,SecondType,Info,Layout> & b)
|
Chris@16
|
465 {
|
Chris@16
|
466 return ! ( a == b );
|
Chris@16
|
467 }
|
Chris@16
|
468
|
Chris@16
|
469 template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
|
Chris@16
|
470 bool operator<(const std::pair<F,S> & a,
|
Chris@16
|
471 const structured_pair<FirstType,SecondType,Info,Layout> & b)
|
Chris@16
|
472 {
|
Chris@16
|
473 return ( ( a.first < b.first ) ||
|
Chris@16
|
474 (( a.first == b.first ) && ( a.second < b.second )));
|
Chris@16
|
475 }
|
Chris@16
|
476
|
Chris@16
|
477 template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
|
Chris@16
|
478 bool operator<=(const std::pair<F,S> & a,
|
Chris@16
|
479 const structured_pair<FirstType,SecondType,Info,Layout> & b)
|
Chris@16
|
480 {
|
Chris@16
|
481 return ( ( a.first < b.first ) ||
|
Chris@16
|
482 (( a.first == b.first ) && ( a.second <= b.second )));
|
Chris@16
|
483 }
|
Chris@16
|
484
|
Chris@16
|
485 template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
|
Chris@16
|
486 bool operator>(const std::pair<F,S> & a,
|
Chris@16
|
487 const structured_pair<FirstType,SecondType,Info,Layout> & b)
|
Chris@16
|
488 {
|
Chris@16
|
489 return ( ( a.first > b.first ) ||
|
Chris@16
|
490 (( a.first == b.first ) && ( a.second > b.second )));
|
Chris@16
|
491 }
|
Chris@16
|
492
|
Chris@16
|
493 template< class FirstType, class SecondType, class Info, class Layout, class F, class S >
|
Chris@16
|
494 bool operator>=(const std::pair<F,S> & a,
|
Chris@16
|
495 const structured_pair<FirstType,SecondType,Info,Layout> & b)
|
Chris@16
|
496 {
|
Chris@16
|
497 return ( ( a.first > b.first ) ||
|
Chris@16
|
498 (( a.first == b.first ) && ( a.second >= b.second )));
|
Chris@16
|
499 }
|
Chris@16
|
500
|
Chris@16
|
501
|
Chris@16
|
502 namespace detail {
|
Chris@16
|
503
|
Chris@16
|
504 template< class FirstType, class SecondType, class Info, class Layout>
|
Chris@16
|
505 structured_pair<FirstType,SecondType,Info,Layout>
|
Chris@16
|
506 copy_with_first_replaced(structured_pair<FirstType,SecondType,Info,Layout> const& p,
|
Chris@16
|
507 BOOST_DEDUCED_TYPENAME ::boost::call_traits< BOOST_DEDUCED_TYPENAME
|
Chris@16
|
508 structured_pair<FirstType,SecondType,Info,Layout>::first_type>
|
Chris@16
|
509 ::param_type f)
|
Chris@16
|
510 {
|
Chris@16
|
511 return structured_pair<FirstType,SecondType,Info,Layout>(f,p.second,p.info);
|
Chris@16
|
512 }
|
Chris@16
|
513
|
Chris@16
|
514 template< class FirstType, class SecondType, class Layout>
|
Chris@16
|
515 structured_pair<FirstType,SecondType,::boost::mpl::na,Layout>
|
Chris@16
|
516 copy_with_first_replaced(structured_pair<FirstType,SecondType,::boost::mpl::na,Layout> const& p,
|
Chris@16
|
517 BOOST_DEDUCED_TYPENAME ::boost::call_traits< BOOST_DEDUCED_TYPENAME
|
Chris@16
|
518 structured_pair<FirstType,SecondType,::boost::mpl::na,Layout>::first_type>
|
Chris@16
|
519 ::param_type f)
|
Chris@16
|
520 {
|
Chris@16
|
521 return structured_pair<FirstType,SecondType,::boost::mpl::na,Layout>(f,p.second);
|
Chris@16
|
522 }
|
Chris@16
|
523
|
Chris@16
|
524 template< class FirstType, class SecondType, class Info, class Layout>
|
Chris@16
|
525 structured_pair<FirstType,SecondType,Info,Layout>
|
Chris@16
|
526 copy_with_second_replaced(structured_pair<FirstType,SecondType,Info,Layout> const& p,
|
Chris@16
|
527 BOOST_DEDUCED_TYPENAME ::boost::call_traits< BOOST_DEDUCED_TYPENAME
|
Chris@16
|
528 structured_pair<FirstType,SecondType,Info,Layout>::second_type>
|
Chris@16
|
529 ::param_type s)
|
Chris@16
|
530 {
|
Chris@16
|
531 return structured_pair<FirstType,SecondType,Info,Layout>(p.first,s,p.info);
|
Chris@16
|
532 }
|
Chris@16
|
533
|
Chris@16
|
534 template< class FirstType, class SecondType, class Layout>
|
Chris@16
|
535 structured_pair<FirstType,SecondType,::boost::mpl::na,Layout>
|
Chris@16
|
536 copy_with_second_replaced(structured_pair<FirstType,SecondType,::boost::mpl::na,Layout> const& p,
|
Chris@16
|
537 BOOST_DEDUCED_TYPENAME ::boost::call_traits< BOOST_DEDUCED_TYPENAME
|
Chris@16
|
538 structured_pair<FirstType,SecondType,::boost::mpl::na,Layout>::second_type>
|
Chris@16
|
539 ::param_type s)
|
Chris@16
|
540 {
|
Chris@16
|
541 return structured_pair<FirstType,SecondType,::boost::mpl::na,Layout>(p.first,s);
|
Chris@16
|
542 }
|
Chris@16
|
543
|
Chris@16
|
544 } // namespace detail
|
Chris@16
|
545
|
Chris@16
|
546
|
Chris@16
|
547 } // namespace relation
|
Chris@16
|
548 } // namespace bimaps
|
Chris@16
|
549 } // namespace boost
|
Chris@16
|
550
|
Chris@16
|
551 #endif // BOOST_BIMAP_RELATION_STRUCTURED_PAIR_HPP
|
Chris@16
|
552
|