26 #ifndef MLN_TRAIT_VALUE_INTERNAL_COMP_HH
27 # define MLN_TRAIT_VALUE_INTERNAL_COMP_HH
36 # include <mln/metal/bool.hh>
37 # include <mln/metal/if.hh>
50 template <
typename V>
struct value_;
61 template <
typename T,
typename Tr,
unsigned i>
64 template <
typename T,
typename Tr>
65 struct bind_comp<
T, Tr, 0 >
67 typedef typename Tr::comp_0
ret;
68 static ret on(
const T& v)
70 return Tr::get_comp_0(v);
74 template <
typename T,
typename Tr>
75 struct bind_comp<
T, Tr, 1 >
77 typedef typename Tr::comp_1
ret;
78 static ret on(
const T& v)
80 return Tr::get_comp_1(v);
84 template <
typename T,
typename Tr>
85 struct bind_comp<
T, Tr, 2 >
87 typedef typename Tr::comp_2
ret;
88 static ret on(
const T& v)
90 return Tr::get_comp_2(v);
94 template <
typename T,
typename Tr>
95 struct bind_comp<
T, Tr, 3 >
97 typedef typename Tr::comp_3
ret;
98 static ret on(
const T& v)
100 return Tr::get_comp_3(v);
104 template <
typename T,
typename Tr>
105 struct bind_comp<
T, Tr, 4 >
107 typedef typename Tr::comp_4
ret;
108 static ret on(
const T& v)
110 return Tr::get_comp_4(v);
114 template <
typename T,
typename Tr>
115 struct bind_comp<
T, Tr, 5 >
117 typedef typename Tr::comp_5
ret;
118 static ret on(
const T& v)
120 return Tr::get_comp_5(v);
124 template <
typename T,
typename Tr>
125 struct bind_comp<
T, Tr, 6 >
127 typedef typename Tr::comp_6
ret;
128 static ret on(
const T& v)
130 return Tr::get_comp_6(v);
134 template <
typename T,
typename Tr>
135 struct bind_comp<
T, Tr, 7 >
137 typedef typename Tr::comp_7
ret;
138 static ret on(
const T& v)
140 return Tr::get_comp_7(v);
144 template <
typename T,
typename Tr>
145 struct bind_comp<
T, Tr, 8 >
147 typedef typename Tr::comp_8
ret;
148 static ret on(
const T& v)
150 return Tr::get_comp_8(v);
154 template <
typename T,
typename Tr>
155 struct bind_comp<
T, Tr, 9 >
157 typedef typename Tr::comp_9
ret;
158 static ret on(
const T& v)
160 return Tr::get_comp_9(v);
167 template <
typename T,
typename C,
typename Tr,
unsigned i>
168 struct get_comp_helper
171 static ret on(
const T& v)
177 template <
typename T,
typename Tr,
unsigned i>
178 struct get_comp_helper<
T, void, Tr, i >
180 typedef bind_comp<T, Tr, i> helper;
181 typedef typename helper::ret
ret;
182 static ret on(
const T& v)
184 return helper::on(v);
198 template <
typename T,
unsigned i,
unsigned dim>
199 struct get_comp_with_regular_
201 typedef mln::trait::value_<T> Tr;
202 typedef typename Tr::comp C;
203 typedef get_comp_helper<T, C, Tr, i> helper;
204 typedef typename helper::ret
ret;
206 static ret on(
const T& v)
208 return helper::on(v);
212 template <
typename T>
213 struct get_comp_with_regular_<
T, 0, 1 >
217 static ret on(
const T& v)
223 template <
typename T,
unsigned i,
unsigned dim>
224 struct get_comp : get_comp_with_regular_<T, i, dim>
230 template <
typename T,
unsigned i,
unsigned dim>
231 struct get_comp_with_C_array
235 static ret on(
const T (&v)[dim])
241 template <
typename T,
unsigned i,
unsigned dim>
242 struct get_comp<
T[dim], i, dim > : get_comp_with_C_array<T, i, dim>
250 template <
typename T,
unsigned i>
252 :
private metal::bool_< (i < mln::trait::value_<T>::dim) >::check_t
254 enum { dim = mln::trait::value_<T>::dim };
255 typedef get_comp<T, i, dim> helper;
256 typedef typename helper::ret ret;
258 static ret on(const T& v)
260 return helper::on(v);