]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/icl/include/boost/icl/type_traits/is_combinable.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / icl / include / boost / icl / type_traits / is_combinable.hpp
CommitLineData
7c673cae
FG
1/*-----------------------------------------------------------------------------+
2Copyright (c) 2008-2009: Joachim Faulhaber
3+------------------------------------------------------------------------------+
4 Distributed under the Boost Software License, Version 1.0.
5 (See accompanying file LICENCE.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt)
7+-----------------------------------------------------------------------------*/
8#ifndef BOOST_ICL_IS_COMBINABLE_HPP_JOFA_090115
9#define BOOST_ICL_IS_COMBINABLE_HPP_JOFA_090115
10
11#include <boost/mpl/bool.hpp>
12#include <boost/mpl/if.hpp>
13#include <boost/mpl/and.hpp>
14#include <boost/mpl/or.hpp>
15#include <boost/mpl/not.hpp>
16#include <boost/type_traits/is_same.hpp>
17#include <boost/icl/type_traits/is_concept_equivalent.hpp>
18#include <boost/icl/type_traits/is_interval_container.hpp>
19
20namespace boost{namespace icl
21{
22
23template<class Type>
24struct is_overloadable
25{
26 typedef is_overloadable<Type> type;
27 BOOST_STATIC_CONSTANT(bool, value =
28 (boost::is_same<Type, typename Type::overloadable_type>::value)
29 );
30};
31
32
33//------------------------------------------------------------------------------
34template<class LeftT, class RightT>
35struct is_codomain_equal
36{
37 typedef is_codomain_equal<LeftT, RightT> type;
38 BOOST_STATIC_CONSTANT(bool, value =
39 (boost::is_same<typename LeftT::codomain_type,
40 typename RightT::codomain_type>::value)
41 );
42};
43
44//NOTE: Equality of compare order implies the equality of the domain_types
45template<class LeftT, class RightT>
46struct is_key_compare_equal
47{
48 typedef is_key_compare_equal<LeftT, RightT> type;
49 BOOST_STATIC_CONSTANT(bool, value =
50 (boost::is_same<typename LeftT::key_compare,
51 typename RightT::key_compare>::value)
52 );
53};
54
55template<class LeftT, class RightT>
56struct is_codomain_type_equal
57{
58 typedef is_codomain_type_equal<LeftT, RightT> type;
59 BOOST_STATIC_CONSTANT(bool, value =
60 (mpl::and_<is_key_compare_equal<LeftT, RightT>,
61 is_codomain_equal<LeftT, RightT> >::value)
62 );
63};
64
65
66// For equal containers concepts, domain order and codomain type must match.
67template<template<class>class IsConcept, class LeftT, class RightT>
68struct is_concept_compatible
69{
70 typedef is_concept_compatible<IsConcept, LeftT, RightT> type;
71 BOOST_STATIC_CONSTANT(bool, value =
72 (mpl::and_<
73 IsConcept<LeftT>
74 , IsConcept<RightT>
75 , is_codomain_type_equal<LeftT, RightT>
76 >::value)
77 );
78};
79
80template<template<class>class LeftConcept,
81 template<class>class RightConcept,
82 class LeftT, class RightT>
83struct is_concept_combinable
84{
85 typedef is_concept_combinable<LeftConcept, RightConcept, LeftT, RightT> type;
86 BOOST_STATIC_CONSTANT(bool, value =
87 (mpl::and_<
88 LeftConcept<LeftT>
89 , RightConcept<RightT>
90 , is_key_compare_equal<LeftT, RightT>
91 >::value)
92 );
93};
94
95template<class LeftT, class RightT>
96struct is_intra_combinable
97{
98 typedef is_intra_combinable<LeftT, RightT> type;
99 BOOST_STATIC_CONSTANT(bool, value =
100 (mpl::or_<
101 is_concept_compatible<is_interval_set, LeftT, RightT>
102 , is_concept_compatible<is_interval_map, LeftT, RightT>
103 >::value)
104 );
105};
106
107//------------------------------------------------------------------------------
108
109
110//------------------------------------------------------------------------------
111template<class LeftT, class RightT>
112struct is_cross_combinable
113{
114 typedef is_cross_combinable<LeftT, RightT> type;
115 BOOST_STATIC_CONSTANT(bool, value =
116 (mpl::or_<
117 is_concept_combinable<is_interval_set, is_interval_map, LeftT, RightT>
118 , is_concept_combinable<is_interval_map, is_interval_set, LeftT, RightT>
119 >::value)
120 );
121};
122
123template<class LeftT, class RightT>
124struct is_inter_combinable
125{
126 typedef is_inter_combinable<LeftT, RightT> type;
127 BOOST_STATIC_CONSTANT(bool, value =
128 (mpl::or_<is_intra_combinable<LeftT,RightT>,
129 is_cross_combinable<LeftT,RightT> >::value)
130 );
131};
132
133//------------------------------------------------------------------------------
134// is_fragment_of
135//------------------------------------------------------------------------------
136template<class FragmentT, class Type>
137struct is_fragment_of
138{
139 typedef is_fragment_of type;
140 BOOST_STATIC_CONSTANT(bool, value = false);
141};
142
143template<class Type>
144struct is_fragment_of<typename Type::element_type, Type>
145{
146 typedef is_fragment_of type;
147 BOOST_STATIC_CONSTANT(bool, value = true);
148};
149
150template<class Type>
151struct is_fragment_of<typename Type::segment_type, Type>
152{
153 typedef is_fragment_of type;
154 BOOST_STATIC_CONSTANT(bool, value = true);
155};
156
157//------------------------------------------------------------------------------
158// is_key_of
159//------------------------------------------------------------------------------
160template<class KeyT, class Type>
161struct is_key_of
162{
163 typedef is_key_of type;
164 BOOST_STATIC_CONSTANT(bool, value = false);
165};
166
167template<class Type>
168struct is_key_of<typename Type::domain_type, Type>
169{
170 typedef is_key_of type;
171 BOOST_STATIC_CONSTANT(bool, value = true);
172};
173
174template<class Type>
175struct is_key_of<typename Type::interval_type, Type>
176{
177 typedef is_key_of type;
178 BOOST_STATIC_CONSTANT(bool, value = true);
179};
180
181//------------------------------------------------------------------------------
182// is_interval_set_derivative
183//------------------------------------------------------------------------------
184template<class Type, class AssociateT>
185struct is_interval_set_derivative;
186
187template<class Type>
188struct is_interval_set_derivative<Type, typename Type::domain_type>
189{
190 typedef is_interval_set_derivative type;
191 BOOST_STATIC_CONSTANT(bool, value = (is_interval_container<Type>::value));
192};
193
194template<class Type>
195struct is_interval_set_derivative<Type, typename Type::interval_type>
196{
197 typedef is_interval_set_derivative type;
198 BOOST_STATIC_CONSTANT(bool, value = (is_interval_container<Type>::value));
199};
200
201template<class Type, class AssociateT>
202struct is_interval_set_derivative
203{
204 typedef is_interval_set_derivative<Type, AssociateT> type;
205 BOOST_STATIC_CONSTANT(bool, value = false);
206};
207
208//------------------------------------------------------------------------------
209// is_interval_map_derivative
210//------------------------------------------------------------------------------
211template<class Type, class AssociateT>
212struct is_interval_map_derivative;
213
214template<class Type>
215struct is_interval_map_derivative<Type, typename Type::domain_mapping_type>
216{
217 typedef is_interval_map_derivative type;
218 BOOST_STATIC_CONSTANT(bool, value = (is_interval_container<Type>::value));
219};
220
221template<class Type>
222struct is_interval_map_derivative<Type, typename Type::interval_mapping_type>
223{
224 typedef is_interval_map_derivative type;
225 BOOST_STATIC_CONSTANT(bool, value = (is_interval_container<Type>::value));
226};
227
228template<class Type>
229struct is_interval_map_derivative<Type, typename Type::value_type>
230{
231 typedef is_interval_map_derivative type;
232 BOOST_STATIC_CONSTANT(bool, value = (is_interval_container<Type>::value));
233};
234
235template<class Type, class AssociateT>
236struct is_interval_map_derivative
237{
238 typedef is_interval_map_derivative<Type, AssociateT> type;
239 BOOST_STATIC_CONSTANT(bool, value = false);
240};
241
242//------------------------------------------------------------------------------
243// is_intra_derivative
244//------------------------------------------------------------------------------
245template<class Type, class AssociateT>
246struct is_intra_derivative
247{
248 typedef is_intra_derivative<Type, AssociateT> type;
249 BOOST_STATIC_CONSTANT(bool, value =
250 (mpl::or_
251 <
252 mpl::and_<is_interval_set<Type>,
253 is_interval_set_derivative<Type, AssociateT> >
254 , mpl::and_<is_interval_map<Type>,
255 is_interval_map_derivative<Type, AssociateT> >
256 >::value)
257 );
258};
259
260template<class Type, class AssociateT>
261struct is_cross_derivative
262{
263 typedef is_cross_derivative<Type, AssociateT> type;
264 BOOST_STATIC_CONSTANT(bool, value =
265 (mpl::and_<
266 is_interval_map<Type>
267 , is_interval_set_derivative<Type, AssociateT>
268 >::value)
269 );
270};
271
272template<class Type, class AssociateT>
273struct is_inter_derivative
274{
275 typedef is_inter_derivative<Type, AssociateT> type;
276 BOOST_STATIC_CONSTANT(bool, value =
277 (mpl::or_<
278 is_intra_derivative<Type, AssociateT>
279 , is_cross_derivative<Type, AssociateT>
280 >::value)
281 );
282};
283
284//------------------------------------------------------------------------------
285//- right combinable
286//------------------------------------------------------------------------------
287
288template<class GuideT, class CompanionT>
289struct is_interval_set_right_combinable
290{
291 typedef is_interval_set_right_combinable<GuideT, CompanionT> type;
292 BOOST_STATIC_CONSTANT(bool, value =
293 (mpl::and_
294 <
295 is_interval_set<GuideT>
296 , mpl::or_
297 <
298 is_interval_set_derivative<GuideT, CompanionT>
299 , is_concept_compatible<is_interval_set, GuideT, CompanionT>
300 >
301 >::value)
302 );
303};
304
305template<class GuideT, class CompanionT>
306struct is_interval_map_right_intra_combinable //NOTE equivalent to is_fragment_type_of
307{
308 typedef is_interval_map_right_intra_combinable<GuideT, CompanionT> type;
309 BOOST_STATIC_CONSTANT(bool, value =
310 (mpl::and_
311 <
312 is_interval_map<GuideT>
313 , mpl::or_
314 <
315 is_interval_map_derivative<GuideT, CompanionT>
316 , is_concept_compatible<is_interval_map, GuideT, CompanionT>
317 >
318 >::value)
319 );
320};
321
322template<class GuideT, class CompanionT>
323struct is_interval_map_right_cross_combinable //NOTE equivalent to key_type_of<Comp, Guide>
324{
325 typedef is_interval_map_right_cross_combinable<GuideT, CompanionT> type;
326 BOOST_STATIC_CONSTANT(bool, value =
327 (mpl::and_
328 <
329 is_interval_map<GuideT>
330 , mpl::or_
331 <
332 is_cross_derivative<GuideT, CompanionT>
333 , is_concept_combinable<is_interval_map, is_interval_set, GuideT, CompanionT>
334 >
335 >::value)
336 );
337};
338
339template<class GuideT, class CompanionT>
340struct is_interval_map_right_inter_combinable
341{
342 typedef is_interval_map_right_inter_combinable<GuideT, CompanionT> type;
343 BOOST_STATIC_CONSTANT(bool, value =
344 (mpl::or_<
345 is_interval_map_right_intra_combinable<GuideT, CompanionT>
346 , is_interval_map_right_cross_combinable<GuideT, CompanionT>
347 >::value)
348 );
349};
350
351
352template<class GuideT, class CompanionT>
353struct is_right_intra_combinable
354{
355 typedef is_right_intra_combinable<GuideT, CompanionT> type;
356 BOOST_STATIC_CONSTANT(bool, value =
357 (mpl::or_
358 <
359 is_interval_set_right_combinable<GuideT, CompanionT>
360 , is_interval_map_right_intra_combinable<GuideT, CompanionT>
361 >::value)
362 );
363};
364
365template<class GuideT, class CompanionT>
366struct is_right_inter_combinable
367{
368 typedef is_right_inter_combinable<GuideT, CompanionT> type;
369 BOOST_STATIC_CONSTANT(bool, value =
370 (mpl::or_
371 <
372 is_interval_set_right_combinable<GuideT, CompanionT>
373 , is_interval_map_right_inter_combinable<GuideT, CompanionT>
374 >::value)
375 );
376};
377
378template<class GuideT, class IntervalSetT>
379struct combines_right_to_interval_set
380{
381 typedef combines_right_to_interval_set<GuideT, IntervalSetT> type;
382 BOOST_STATIC_CONSTANT(bool, value =
383 (is_concept_combinable<is_interval_container, is_interval_set,
384 GuideT, IntervalSetT>::value)
385 );
386};
387
388template<class GuideT, class IntervalMapT>
389struct combines_right_to_interval_map
390{
391 typedef combines_right_to_interval_map<GuideT, IntervalMapT> type;
392 BOOST_STATIC_CONSTANT(bool, value =
393 (is_concept_compatible<is_interval_map, GuideT, IntervalMapT>::value) );
394};
395
396template<class GuideT, class IntervalContainerT>
397struct combines_right_to_interval_container
398{
399 typedef combines_right_to_interval_container<GuideT, IntervalContainerT> type;
400 BOOST_STATIC_CONSTANT(bool, value =
401 (mpl::or_<combines_right_to_interval_set<GuideT, IntervalContainerT>,
402 combines_right_to_interval_map<GuideT, IntervalContainerT> >::value)
403 );
404};
405
406
407
408//------------------------------------------------------------------------------
409//- segmentational_fineness
410//------------------------------------------------------------------------------
411template<class Type> struct unknown_fineness
412{
413 typedef unknown_fineness<Type> type;
414 static const int value = 0;
415};
416
417template<class Type> struct known_fineness
418{
419 typedef known_fineness<Type> type;
420 static const int value = Type::fineness;
421};
422
423template<class Type>struct segmentational_fineness
424{
425 typedef segmentational_fineness<Type> type;
426 static const int value =
427 mpl::if_<is_interval_container<Type>,
428 known_fineness<Type>,
429 unknown_fineness<Type>
430 >::type::value;
431};
432
433
434//------------------------------------------------------------------------------
435// is_interval_set_companion
436//------------------------------------------------------------------------------
437
438// CompanionT is either an interval_set or a derivative of set level:
439// element_type=domain_type, segment_type=interval_type
440template<class GuideT, class CompanionT> struct is_interval_set_companion
441{
442 typedef is_interval_set_companion<GuideT,CompanionT> type;
443 BOOST_STATIC_CONSTANT(bool, value =
444 (mpl::or_
445 <
446 combines_right_to_interval_set<GuideT,CompanionT>
447 , is_interval_set_derivative<GuideT,CompanionT>
448 >::value)
449 );
450};
451
452
453//------------------------------------------------------------------------------
454// is_interval_map_companion
455//------------------------------------------------------------------------------
456
457template<class GuideT, class CompanionT> struct is_interval_map_companion
458{
459 typedef is_interval_map_companion<GuideT,CompanionT> type;
460 BOOST_STATIC_CONSTANT(bool, value =
461 (mpl::or_
462 <
463 combines_right_to_interval_map<GuideT,CompanionT>
464 , is_interval_map_derivative<GuideT,CompanionT>
465 >::value)
466 );
467};
468
469
470//------------------------------------------------------------------------------
471//- is_coarser_interval_{set,map}_companion
472//------------------------------------------------------------------------------
473template<class GuideT, class CompanionT>
474struct is_coarser_interval_set_companion
475{
476 typedef is_coarser_interval_set_companion<GuideT, CompanionT> type;
477 BOOST_STATIC_CONSTANT(bool, value =
478 (mpl::and_
479 <
480 is_interval_set_companion<GuideT, CompanionT>
481 , mpl::bool_<( segmentational_fineness<GuideT>::value
482 > segmentational_fineness<CompanionT>::value)>
483 >::value)
484 );
485};
486
487template<class GuideT, class CompanionT>
488struct is_coarser_interval_map_companion
489{
490 typedef is_coarser_interval_map_companion<GuideT, CompanionT> type;
491 BOOST_STATIC_CONSTANT(bool, value =
492 (mpl::and_
493 <
494 is_interval_map_companion<GuideT, CompanionT>
495 , mpl::bool_<( segmentational_fineness<GuideT>::value
496 > segmentational_fineness<CompanionT>::value)>
497 >::value)
498 );
499};
500
501//------------------------------------------------------------------------------
502// is_binary_interval_{set,map}_combinable
503//------------------------------------------------------------------------------
504template<class GuideT, class CompanionT>
505struct is_binary_interval_set_combinable
506{
507 typedef is_binary_interval_set_combinable<GuideT,CompanionT> type;
508 static const int value =
509 mpl::and_< is_interval_set<GuideT>
510 , is_coarser_interval_set_companion<GuideT, CompanionT>
511 >::value;
512};
513
514template<class GuideT, class CompanionT>
515struct is_binary_interval_map_combinable
516{
517 typedef is_binary_interval_map_combinable<GuideT,CompanionT> type;
518 static const int value =
519 mpl::and_< is_interval_map<GuideT>
520 , is_coarser_interval_map_companion<GuideT, CompanionT>
521 >::value;
522};
523
524template<class GuideT, class CompanionT>
525struct is_binary_intra_combinable
526{
527 typedef is_binary_intra_combinable<GuideT,CompanionT> type;
528 BOOST_STATIC_CONSTANT(bool, value =
529 (mpl::or_<is_binary_interval_set_combinable<GuideT, CompanionT>,
530 is_binary_interval_map_combinable<GuideT, CompanionT>
531 >::value)
532 );
533};
534
535template<class GuideT, class CompanionT>
536struct is_binary_cross_combinable
537{
538 typedef is_binary_cross_combinable<GuideT,CompanionT> type;
539 BOOST_STATIC_CONSTANT(bool, value =
540 (mpl::and_
541 < is_interval_map<GuideT>
542 , mpl::or_< is_coarser_interval_map_companion<GuideT, CompanionT>
543 , is_interval_set_companion<GuideT, CompanionT> >
544 >::value)
545 );
546};
547
548template<class GuideT, class CompanionT>
549struct is_binary_inter_combinable
550{
551 typedef is_binary_inter_combinable<GuideT,CompanionT> type;
552 BOOST_STATIC_CONSTANT(bool, value =
553 (mpl::or_
554 <
555 mpl::and_<is_interval_map<GuideT>,
556 is_binary_cross_combinable<GuideT, CompanionT> >
557 , mpl::and_<is_interval_set<GuideT>,
558 is_binary_intra_combinable<GuideT, CompanionT> >
559 >::value)
560 );
561};
562
563
564}} // namespace icl boost
565
566#endif
567
568