OSDN Git Service

modified: utilsrc/src/Admin/Makefile
[eos/others.git] / utiltools / X86MAC64 / cuda / include / thrust / detail / type_traits / minimum_type.h
1 /*
2  *  Copyright 2008-2012 NVIDIA Corporation
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  */
16
17 #pragma once
18
19 #include <thrust/detail/type_traits.h>
20
21 namespace thrust
22 {
23
24 namespace detail
25
26
27 namespace minimum_type_detail
28 {
29
30 //
31 // Returns the minimum type or is empty
32 // if T1 and T2 are unrelated.
33 //
34 template <typename T1, typename T2, bool GreaterEqual, bool LessEqual> struct minimum_type_impl {};
35   
36 template <typename T1, typename T2>
37 struct minimum_type_impl<T1,T2,true,false>
38 {
39   typedef T2 type;
40 }; // end minimum_type_impl
41
42 template <typename T1, typename T2>
43 struct minimum_type_impl<T1,T2,false,true>
44 {
45   typedef T1 type;
46 }; // end minimum_type_impl
47
48 template <typename T1, typename T2>
49 struct minimum_type_impl<T1,T2,true,true>
50 {
51   typedef T1 type;
52 }; // end minimum_type_impl
53
54 template <typename T1, typename T2>
55 struct primitive_minimum_type
56   : minimum_type_detail::minimum_type_impl<
57       T1,
58       T2,
59       ::thrust::detail::is_convertible<T1,T2>::value,
60       ::thrust::detail::is_convertible<T2,T1>::value
61     >
62 {
63 }; // end primitive_minimum_type
64
65 // because some types are not convertible (even to themselves)
66 // specialize primitive_minimum_type for when both types are identical
67 template <typename T>
68 struct primitive_minimum_type<T,T>
69 {
70   typedef T type;
71 }; // end primitive_minimum_type
72
73 // XXX this belongs somewhere more general
74 struct any_conversion
75 {
76   template<typename T> operator T (void);
77 };
78
79 } // end minimum_type_detail
80
81 template<typename T1,
82          typename T2  = minimum_type_detail::any_conversion,
83          typename T3  = minimum_type_detail::any_conversion,
84          typename T4  = minimum_type_detail::any_conversion,
85          typename T5  = minimum_type_detail::any_conversion,
86          typename T6  = minimum_type_detail::any_conversion,
87          typename T7  = minimum_type_detail::any_conversion,
88          typename T8  = minimum_type_detail::any_conversion,
89          typename T9  = minimum_type_detail::any_conversion,
90          typename T10 = minimum_type_detail::any_conversion,
91          typename T11 = minimum_type_detail::any_conversion,
92          typename T12 = minimum_type_detail::any_conversion,
93          typename T13 = minimum_type_detail::any_conversion,
94          typename T14 = minimum_type_detail::any_conversion,
95          typename T15 = minimum_type_detail::any_conversion,
96          typename T16 = minimum_type_detail::any_conversion>
97   struct minimum_type;
98
99 // base case
100 template<typename T1, typename T2>
101   struct minimum_type<T1,T2>
102     : minimum_type_detail::primitive_minimum_type<T1,T2>
103 {};
104
105 template<typename T1, typename T2>
106   struct lazy_minimum_type
107     : minimum_type<
108         typename T1::type,
109         typename T2::type
110       >
111 {};
112
113 // carefully avoid referring to a nested ::type which may not exist
114 template<typename T1,  typename T2,  typename T3,  typename T4,
115          typename T5,  typename T6,  typename T7,  typename T8,
116          typename T9,  typename T10, typename T11, typename T12,
117          typename T13, typename T14, typename T15, typename T16>
118   struct minimum_type
119     : lazy_minimum_type<
120         lazy_minimum_type<
121           lazy_minimum_type<
122             minimum_type<
123               T1,T2
124             >,
125             minimum_type<
126               T3,T4
127             >
128           >,
129           lazy_minimum_type<
130             minimum_type<
131               T5,T6
132             >,
133             minimum_type<
134               T7,T8
135             >
136           >
137         >,
138         lazy_minimum_type<
139           lazy_minimum_type<
140             minimum_type<
141               T9,T10
142             >,
143             minimum_type<
144               T11,T12
145             >
146           >,
147           lazy_minimum_type<
148             minimum_type<
149               T13,T14
150             >,
151             minimum_type<
152               T15,T16
153             >
154           >
155         >
156       >
157 {};
158
159 } // end detail
160
161 } // end thrust
162