]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/iterator/detail/minimum_category.hpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
804f9186f05d9883734b50592918b4d42b9b90b8
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / iterator / detail / minimum_category.hpp
1 // Copyright David Abrahams 2003. Use, modification and distribution is\r
2 // subject to the Boost Software License, Version 1.0. (See accompanying\r
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\r
4 #ifndef MINIMUM_CATEGORY_DWA20031119_HPP\r
5 # define MINIMUM_CATEGORY_DWA20031119_HPP\r
6 \r
7 # include <boost/type_traits/is_convertible.hpp>\r
8 # include <boost/type_traits/is_same.hpp>\r
9 \r
10 # include <boost/mpl/aux_/lambda_support.hpp>\r
11 \r
12 namespace boost { namespace detail { \r
13 //\r
14 // Returns the minimum category type or error_type\r
15 // if T1 and T2 are unrelated.\r
16 //\r
17 // For compilers not supporting is_convertible this only\r
18 // works with the new boost return and traversal category\r
19 // types. The exact boost _types_ are required. No derived types\r
20 // will work. \r
21 //\r
22 //\r
23 template <bool GreaterEqual, bool LessEqual>\r
24 struct minimum_category_impl\r
25 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300)\r
26 {\r
27     template <class T1, class T2> struct apply\r
28     {\r
29         typedef T2 type;\r
30     };\r
31     typedef void type;\r
32 }\r
33 # endif \r
34 ;\r
35 \r
36 template <class T1, class T2>\r
37 struct error_not_related_by_convertibility;\r
38   \r
39 template <>\r
40 struct minimum_category_impl<true,false>\r
41 {\r
42     template <class T1, class T2> struct apply\r
43     {\r
44         typedef T2 type;\r
45     };\r
46 };\r
47 \r
48 template <>\r
49 struct minimum_category_impl<false,true>\r
50 {\r
51     template <class T1, class T2> struct apply\r
52     {\r
53         typedef T1 type;\r
54     };\r
55 };\r
56 \r
57 template <>\r
58 struct minimum_category_impl<true,true>\r
59 {\r
60     template <class T1, class T2> struct apply\r
61     {\r
62         BOOST_STATIC_ASSERT((is_same<T1,T2>::value));\r
63         typedef T1 type;\r
64     };\r
65 };\r
66 \r
67 template <>\r
68 struct minimum_category_impl<false,false>\r
69 {\r
70     template <class T1, class T2> struct apply\r
71     : error_not_related_by_convertibility<T1,T2>\r
72     {\r
73     };\r
74 };\r
75 \r
76 template <class T1 = mpl::_1, class T2 = mpl::_2>\r
77 struct minimum_category\r
78 {\r
79     typedef minimum_category_impl< \r
80 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300) // ETI workaround\r
81         is_same<T2,int>::value ||\r
82 # endif \r
83         ::boost::is_convertible<T1,T2>::value\r
84       , ::boost::is_convertible<T2,T1>::value\r
85 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300) // ETI workaround\r
86         || is_same<T1,int>::value\r
87 # endif \r
88     > outer;\r
89 \r
90     typedef typename outer::template apply<T1,T2> inner;\r
91     typedef typename inner::type type;\r
92       \r
93     BOOST_MPL_AUX_LAMBDA_SUPPORT(2,minimum_category,(T1,T2))\r
94 };\r
95     \r
96 template <>\r
97 struct minimum_category<mpl::_1,mpl::_2>\r
98 {\r
99     template <class T1, class T2>\r
100     struct apply : minimum_category<T1,T2>\r
101     {};\r
102 \r
103     BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2,minimum_category,(mpl::_1,mpl::_2))\r
104 };\r
105 \r
106 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300) // ETI workaround\r
107 template <>\r
108 struct minimum_category<int,int>\r
109 {\r
110     typedef int type;\r
111 };\r
112 # endif\r
113     \r
114 }} // namespace boost::detail\r
115 \r
116 #endif // MINIMUM_CATEGORY_DWA20031119_HPP\r