![]() |
Eigen-unsupported
3.3.3
|
00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. 00003 // 00004 // Copyright (C) 2013 Christian Seiler <christian@iwakd.de> 00005 // 00006 // This Source Code Form is subject to the terms of the Mozilla 00007 // Public License v. 2.0. If a copy of the MPL was not distributed 00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 00009 00010 #ifndef EIGEN_CXX11META_H 00011 #define EIGEN_CXX11META_H 00012 00013 #include <vector> 00014 #include "EmulateArray.h" 00015 00016 // Emulate the cxx11 functionality that we need if the compiler doesn't support it. 00017 // Visual studio 2015 doesn't advertise itself as cxx11 compliant, although it 00018 // supports enough of the standard for our needs 00019 #if __cplusplus > 199711L || EIGEN_COMP_MSVC >= 1900 00020 00021 #include "CXX11Workarounds.h" 00022 00023 namespace Eigen { 00024 00025 namespace internal { 00026 00033 template<typename... tt> 00034 struct type_list { constexpr static int count = sizeof...(tt); }; 00035 00036 template<typename t, typename... tt> 00037 struct type_list<t, tt...> { constexpr static int count = sizeof...(tt) + 1; typedef t first_type; }; 00038 00039 template<typename T, T... nn> 00040 struct numeric_list { constexpr static std::size_t count = sizeof...(nn); }; 00041 00042 template<typename T, T n, T... nn> 00043 struct numeric_list<T, n, nn...> { constexpr static std::size_t count = sizeof...(nn) + 1; constexpr static T first_value = n; }; 00044 00045 /* numeric list constructors 00046 * 00047 * equivalencies: 00048 * constructor result 00049 * typename gen_numeric_list<int, 5>::type numeric_list<int, 0,1,2,3,4> 00050 * typename gen_numeric_list_reversed<int, 5>::type numeric_list<int, 4,3,2,1,0> 00051 * typename gen_numeric_list_swapped_pair<int, 5,1,2>::type numeric_list<int, 0,2,1,3,4> 00052 * typename gen_numeric_list_repeated<int, 0, 5>::type numeric_list<int, 0,0,0,0,0> 00053 */ 00054 00055 template<typename T, std::size_t n, T start = 0, T... ii> struct gen_numeric_list : gen_numeric_list<T, n-1, start, start + n-1, ii...> {}; 00056 template<typename T, T start, T... ii> struct gen_numeric_list<T, 0, start, ii...> { typedef numeric_list<T, ii...> type; }; 00057 00058 template<typename T, std::size_t n, T start = 0, T... ii> struct gen_numeric_list_reversed : gen_numeric_list_reversed<T, n-1, start, ii..., start + n-1> {}; 00059 template<typename T, T start, T... ii> struct gen_numeric_list_reversed<T, 0, start, ii...> { typedef numeric_list<T, ii...> type; }; 00060 00061 template<typename T, std::size_t n, T a, T b, T start = 0, T... ii> struct gen_numeric_list_swapped_pair : gen_numeric_list_swapped_pair<T, n-1, a, b, start, (start + n-1) == a ? b : ((start + n-1) == b ? a : (start + n-1)), ii...> {}; 00062 template<typename T, T a, T b, T start, T... ii> struct gen_numeric_list_swapped_pair<T, 0, a, b, start, ii...> { typedef numeric_list<T, ii...> type; }; 00063 00064 template<typename T, std::size_t n, T V, T... nn> struct gen_numeric_list_repeated : gen_numeric_list_repeated<T, n-1, V, V, nn...> {}; 00065 template<typename T, T V, T... nn> struct gen_numeric_list_repeated<T, 0, V, nn...> { typedef numeric_list<T, nn...> type; }; 00066 00067 /* list manipulation: concatenate */ 00068 00069 template<class a, class b> struct concat; 00070 00071 template<typename... as, typename... bs> struct concat<type_list<as...>, type_list<bs...>> { typedef type_list<as..., bs...> type; }; 00072 template<typename T, T... as, T... bs> struct concat<numeric_list<T, as...>, numeric_list<T, bs...> > { typedef numeric_list<T, as..., bs...> type; }; 00073 00074 template<typename... p> struct mconcat; 00075 template<typename a> struct mconcat<a> { typedef a type; }; 00076 template<typename a, typename b> struct mconcat<a, b> : concat<a, b> {}; 00077 template<typename a, typename b, typename... cs> struct mconcat<a, b, cs...> : concat<a, typename mconcat<b, cs...>::type> {}; 00078 00079 /* list manipulation: extract slices */ 00080 00081 template<int n, typename x> struct take; 00082 template<int n, typename a, typename... as> struct take<n, type_list<a, as...>> : concat<type_list<a>, typename take<n-1, type_list<as...>>::type> {}; 00083 template<int n> struct take<n, type_list<>> { typedef type_list<> type; }; 00084 template<typename a, typename... as> struct take<0, type_list<a, as...>> { typedef type_list<> type; }; 00085 template<> struct take<0, type_list<>> { typedef type_list<> type; }; 00086 00087 template<typename T, int n, T a, T... as> struct take<n, numeric_list<T, a, as...>> : concat<numeric_list<T, a>, typename take<n-1, numeric_list<T, as...>>::type> {}; 00088 template<typename T, int n> struct take<n, numeric_list<T>> { typedef numeric_list<T> type; }; 00089 template<typename T, T a, T... as> struct take<0, numeric_list<T, a, as...>> { typedef numeric_list<T> type; }; 00090 template<typename T> struct take<0, numeric_list<T>> { typedef numeric_list<T> type; }; 00091 00092 template<typename T, int n, T... ii> struct h_skip_helper_numeric; 00093 template<typename T, int n, T i, T... ii> struct h_skip_helper_numeric<T, n, i, ii...> : h_skip_helper_numeric<T, n-1, ii...> {}; 00094 template<typename T, T i, T... ii> struct h_skip_helper_numeric<T, 0, i, ii...> { typedef numeric_list<T, i, ii...> type; }; 00095 template<typename T, int n> struct h_skip_helper_numeric<T, n> { typedef numeric_list<T> type; }; 00096 template<typename T> struct h_skip_helper_numeric<T, 0> { typedef numeric_list<T> type; }; 00097 00098 template<int n, typename... tt> struct h_skip_helper_type; 00099 template<int n, typename t, typename... tt> struct h_skip_helper_type<n, t, tt...> : h_skip_helper_type<n-1, tt...> {}; 00100 template<typename t, typename... tt> struct h_skip_helper_type<0, t, tt...> { typedef type_list<t, tt...> type; }; 00101 template<int n> struct h_skip_helper_type<n> { typedef type_list<> type; }; 00102 template<> struct h_skip_helper_type<0> { typedef type_list<> type; }; 00103 00104 template<int n> 00105 struct h_skip { 00106 template<typename T, T... ii> 00107 constexpr static inline typename h_skip_helper_numeric<T, n, ii...>::type helper(numeric_list<T, ii...>) { return typename h_skip_helper_numeric<T, n, ii...>::type(); } 00108 template<typename... tt> 00109 constexpr static inline typename h_skip_helper_type<n, tt...>::type helper(type_list<tt...>) { return typename h_skip_helper_type<n, tt...>::type(); } 00110 }; 00111 00112 template<int n, typename a> struct skip { typedef decltype(h_skip<n>::helper(a())) type; }; 00113 00114 template<int start, int count, typename a> struct slice : take<count, typename skip<start, a>::type> {}; 00115 00116 /* list manipulation: retrieve single element from list */ 00117 00118 template<int n, typename x> struct get; 00119 00120 template<int n, typename a, typename... as> struct get<n, type_list<a, as...>> : get<n-1, type_list<as...>> {}; 00121 template<typename a, typename... as> struct get<0, type_list<a, as...>> { typedef a type; }; 00122 00123 template<typename T, int n, T a, T... as> struct get<n, numeric_list<T, a, as...>> : get<n-1, numeric_list<T, as...>> {}; 00124 template<typename T, T a, T... as> struct get<0, numeric_list<T, a, as...>> { constexpr static T value = a; }; 00125 00126 /* always get type, regardless of dummy; good for parameter pack expansion */ 00127 00128 template<typename T, T dummy, typename t> struct id_numeric { typedef t type; }; 00129 template<typename dummy, typename t> struct id_type { typedef t type; }; 00130 00131 /* equality checking, flagged version */ 00132 00133 template<typename a, typename b> struct is_same_gf : is_same<a, b> { constexpr static int global_flags = 0; }; 00134 00135 /* apply_op to list */ 00136 00137 template< 00138 bool from_left, // false 00139 template<typename, typename> class op, 00140 typename additional_param, 00141 typename... values 00142 > 00143 struct h_apply_op_helper { typedef type_list<typename op<values, additional_param>::type...> type; }; 00144 template< 00145 template<typename, typename> class op, 00146 typename additional_param, 00147 typename... values 00148 > 00149 struct h_apply_op_helper<true, op, additional_param, values...> { typedef type_list<typename op<additional_param, values>::type...> type; }; 00150 00151 template< 00152 bool from_left, 00153 template<typename, typename> class op, 00154 typename additional_param 00155 > 00156 struct h_apply_op 00157 { 00158 template<typename... values> 00159 constexpr static typename h_apply_op_helper<from_left, op, additional_param, values...>::type helper(type_list<values...>) 00160 { return typename h_apply_op_helper<from_left, op, additional_param, values...>::type(); } 00161 }; 00162 00163 template< 00164 template<typename, typename> class op, 00165 typename additional_param, 00166 typename a 00167 > 00168 struct apply_op_from_left { typedef decltype(h_apply_op<true, op, additional_param>::helper(a())) type; }; 00169 00170 template< 00171 template<typename, typename> class op, 00172 typename additional_param, 00173 typename a 00174 > 00175 struct apply_op_from_right { typedef decltype(h_apply_op<false, op, additional_param>::helper(a())) type; }; 00176 00177 /* see if an element is in a list */ 00178 00179 template< 00180 template<typename, typename> class test, 00181 typename check_against, 00182 typename h_list, 00183 bool last_check_positive = false 00184 > 00185 struct contained_in_list; 00186 00187 template< 00188 template<typename, typename> class test, 00189 typename check_against, 00190 typename h_list 00191 > 00192 struct contained_in_list<test, check_against, h_list, true> 00193 { 00194 constexpr static bool value = true; 00195 }; 00196 00197 template< 00198 template<typename, typename> class test, 00199 typename check_against, 00200 typename a, 00201 typename... as 00202 > 00203 struct contained_in_list<test, check_against, type_list<a, as...>, false> : contained_in_list<test, check_against, type_list<as...>, test<check_against, a>::value> {}; 00204 00205 template< 00206 template<typename, typename> class test, 00207 typename check_against 00208 EIGEN_TPL_PP_SPEC_HACK_DEFC(typename, empty) 00209 > 00210 struct contained_in_list<test, check_against, type_list<EIGEN_TPL_PP_SPEC_HACK_USE(empty)>, false> { constexpr static bool value = false; }; 00211 00212 /* see if an element is in a list and check for global flags */ 00213 00214 template< 00215 template<typename, typename> class test, 00216 typename check_against, 00217 typename h_list, 00218 int default_flags = 0, 00219 bool last_check_positive = false, 00220 int last_check_flags = default_flags 00221 > 00222 struct contained_in_list_gf; 00223 00224 template< 00225 template<typename, typename> class test, 00226 typename check_against, 00227 typename h_list, 00228 int default_flags, 00229 int last_check_flags 00230 > 00231 struct contained_in_list_gf<test, check_against, h_list, default_flags, true, last_check_flags> 00232 { 00233 constexpr static bool value = true; 00234 constexpr static int global_flags = last_check_flags; 00235 }; 00236 00237 template< 00238 template<typename, typename> class test, 00239 typename check_against, 00240 typename a, 00241 typename... as, 00242 int default_flags, 00243 int last_check_flags 00244 > 00245 struct contained_in_list_gf<test, check_against, type_list<a, as...>, default_flags, false, last_check_flags> : contained_in_list_gf<test, check_against, type_list<as...>, default_flags, test<check_against, a>::value, test<check_against, a>::global_flags> {}; 00246 00247 template< 00248 template<typename, typename> class test, 00249 typename check_against 00250 EIGEN_TPL_PP_SPEC_HACK_DEFC(typename, empty), 00251 int default_flags, 00252 int last_check_flags 00253 > 00254 struct contained_in_list_gf<test, check_against, type_list<EIGEN_TPL_PP_SPEC_HACK_USE(empty)>, default_flags, false, last_check_flags> { constexpr static bool value = false; constexpr static int global_flags = default_flags; }; 00255 00256 /* generic reductions */ 00257 00258 template< 00259 typename Reducer, 00260 typename... Ts 00261 > struct reduce; 00262 00263 template< 00264 typename Reducer 00265 > struct reduce<Reducer> 00266 { 00267 constexpr static inline int run() { return Reducer::Identity; } 00268 }; 00269 00270 template< 00271 typename Reducer, 00272 typename A 00273 > struct reduce<Reducer, A> 00274 { 00275 constexpr static inline A run(A a) { return a; } 00276 }; 00277 00278 template< 00279 typename Reducer, 00280 typename A, 00281 typename... Ts 00282 > struct reduce<Reducer, A, Ts...> 00283 { 00284 constexpr static inline auto run(A a, Ts... ts) -> decltype(Reducer::run(a, reduce<Reducer, Ts...>::run(ts...))) { 00285 return Reducer::run(a, reduce<Reducer, Ts...>::run(ts...)); 00286 } 00287 }; 00288 00289 /* generic binary operations */ 00290 00291 struct sum_op { 00292 template<typename A, typename B> EIGEN_DEVICE_FUNC constexpr static inline auto run(A a, B b) -> decltype(a + b) { return a + b; } 00293 static constexpr int Identity = 0; 00294 }; 00295 struct product_op { 00296 template<typename A, typename B> EIGEN_DEVICE_FUNC constexpr static inline auto run(A a, B b) -> decltype(a * b) { return a * b; } 00297 static constexpr int Identity = 1; 00298 }; 00299 00300 struct logical_and_op { template<typename A, typename B> constexpr static inline auto run(A a, B b) -> decltype(a && b) { return a && b; } }; 00301 struct logical_or_op { template<typename A, typename B> constexpr static inline auto run(A a, B b) -> decltype(a || b) { return a || b; } }; 00302 00303 struct equal_op { template<typename A, typename B> constexpr static inline auto run(A a, B b) -> decltype(a == b) { return a == b; } }; 00304 struct not_equal_op { template<typename A, typename B> constexpr static inline auto run(A a, B b) -> decltype(a != b) { return a != b; } }; 00305 struct lesser_op { template<typename A, typename B> constexpr static inline auto run(A a, B b) -> decltype(a < b) { return a < b; } }; 00306 struct lesser_equal_op { template<typename A, typename B> constexpr static inline auto run(A a, B b) -> decltype(a <= b) { return a <= b; } }; 00307 struct greater_op { template<typename A, typename B> constexpr static inline auto run(A a, B b) -> decltype(a > b) { return a > b; } }; 00308 struct greater_equal_op { template<typename A, typename B> constexpr static inline auto run(A a, B b) -> decltype(a >= b) { return a >= b; } }; 00309 00310 /* generic unary operations */ 00311 00312 struct not_op { template<typename A> constexpr static inline auto run(A a) -> decltype(!a) { return !a; } }; 00313 struct negation_op { template<typename A> constexpr static inline auto run(A a) -> decltype(-a) { return -a; } }; 00314 struct greater_equal_zero_op { template<typename A> constexpr static inline auto run(A a) -> decltype(a >= 0) { return a >= 0; } }; 00315 00316 00317 /* reductions for lists */ 00318 00319 // using auto -> return value spec makes ICC 13.0 and 13.1 crash here, so we have to hack it 00320 // together in front... (13.0 doesn't work with array_prod/array_reduce/... anyway, but 13.1 00321 // does... 00322 template<typename... Ts> 00323 constexpr inline decltype(reduce<product_op, Ts...>::run((*((Ts*)0))...)) arg_prod(Ts... ts) 00324 { 00325 return reduce<product_op, Ts...>::run(ts...); 00326 } 00327 00328 template<typename... Ts> 00329 constexpr inline decltype(reduce<sum_op, Ts...>::run((*((Ts*)0))...)) arg_sum(Ts... ts) 00330 { 00331 return reduce<sum_op, Ts...>::run(ts...); 00332 } 00333 00334 /* reverse arrays */ 00335 00336 template<typename Array, int... n> 00337 constexpr inline Array h_array_reverse(Array arr, numeric_list<int, n...>) 00338 { 00339 return {{array_get<sizeof...(n) - n - 1>(arr)...}}; 00340 } 00341 00342 template<typename T, std::size_t N> 00343 constexpr inline array<T, N> array_reverse(array<T, N> arr) 00344 { 00345 return h_array_reverse(arr, typename gen_numeric_list<int, N>::type()); 00346 } 00347 00348 00349 /* generic array reductions */ 00350 00351 // can't reuse standard reduce() interface above because Intel's Compiler 00352 // *really* doesn't like it, so we just reimplement the stuff 00353 // (start from N - 1 and work down to 0 because specialization for 00354 // n == N - 1 also doesn't work in Intel's compiler, so it goes into 00355 // an infinite loop) 00356 template<typename Reducer, typename T, std::size_t N, std::size_t n = N - 1> 00357 struct h_array_reduce { 00358 EIGEN_DEVICE_FUNC constexpr static inline auto run(array<T, N> arr, T identity) -> decltype(Reducer::run(h_array_reduce<Reducer, T, N, n - 1>::run(arr, identity), array_get<n>(arr))) 00359 { 00360 return Reducer::run(h_array_reduce<Reducer, T, N, n - 1>::run(arr, identity), array_get<n>(arr)); 00361 } 00362 }; 00363 00364 template<typename Reducer, typename T, std::size_t N> 00365 struct h_array_reduce<Reducer, T, N, 0> 00366 { 00367 EIGEN_DEVICE_FUNC constexpr static inline T run(const array<T, N>& arr, T) 00368 { 00369 return array_get<0>(arr); 00370 } 00371 }; 00372 00373 template<typename Reducer, typename T> 00374 struct h_array_reduce<Reducer, T, 0> 00375 { 00376 EIGEN_DEVICE_FUNC constexpr static inline T run(const array<T, 0>&, T identity) 00377 { 00378 return identity; 00379 } 00380 }; 00381 00382 template<typename Reducer, typename T, std::size_t N> 00383 EIGEN_DEVICE_FUNC constexpr inline auto array_reduce(const array<T, N>& arr, T identity) -> decltype(h_array_reduce<Reducer, T, N>::run(arr, identity)) 00384 { 00385 return h_array_reduce<Reducer, T, N>::run(arr, identity); 00386 } 00387 00388 /* standard array reductions */ 00389 00390 template<typename T, std::size_t N> 00391 EIGEN_DEVICE_FUNC constexpr inline auto array_sum(const array<T, N>& arr) -> decltype(array_reduce<sum_op, T, N>(arr, static_cast<T>(0))) 00392 { 00393 return array_reduce<sum_op, T, N>(arr, static_cast<T>(0)); 00394 } 00395 00396 template<typename T, std::size_t N> 00397 EIGEN_DEVICE_FUNC constexpr inline auto array_prod(const array<T, N>& arr) -> decltype(array_reduce<product_op, T, N>(arr, static_cast<T>(1))) 00398 { 00399 return array_reduce<product_op, T, N>(arr, static_cast<T>(1)); 00400 } 00401 00402 template<typename t> 00403 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE t array_prod(const std::vector<t>& a) { 00404 eigen_assert(a.size() > 0); 00405 t prod = 1; 00406 for (size_t i = 0; i < a.size(); ++i) { prod *= a[i]; } 00407 return prod; 00408 } 00409 00410 /* zip an array */ 00411 00412 template<typename Op, typename A, typename B, std::size_t N, int... n> 00413 constexpr inline array<decltype(Op::run(A(), B())),N> h_array_zip(array<A, N> a, array<B, N> b, numeric_list<int, n...>) 00414 { 00415 return array<decltype(Op::run(A(), B())),N>{{ Op::run(array_get<n>(a), array_get<n>(b))... }}; 00416 } 00417 00418 template<typename Op, typename A, typename B, std::size_t N> 00419 constexpr inline array<decltype(Op::run(A(), B())),N> array_zip(array<A, N> a, array<B, N> b) 00420 { 00421 return h_array_zip<Op>(a, b, typename gen_numeric_list<int, N>::type()); 00422 } 00423 00424 /* zip an array and reduce the result */ 00425 00426 template<typename Reducer, typename Op, typename A, typename B, std::size_t N, int... n> 00427 constexpr inline auto h_array_zip_and_reduce(array<A, N> a, array<B, N> b, numeric_list<int, n...>) -> decltype(reduce<Reducer, typename id_numeric<int,n,decltype(Op::run(A(), B()))>::type...>::run(Op::run(array_get<n>(a), array_get<n>(b))...)) 00428 { 00429 return reduce<Reducer, typename id_numeric<int,n,decltype(Op::run(A(), B()))>::type...>::run(Op::run(array_get<n>(a), array_get<n>(b))...); 00430 } 00431 00432 template<typename Reducer, typename Op, typename A, typename B, std::size_t N> 00433 constexpr inline auto array_zip_and_reduce(array<A, N> a, array<B, N> b) -> decltype(h_array_zip_and_reduce<Reducer, Op, A, B, N>(a, b, typename gen_numeric_list<int, N>::type())) 00434 { 00435 return h_array_zip_and_reduce<Reducer, Op, A, B, N>(a, b, typename gen_numeric_list<int, N>::type()); 00436 } 00437 00438 /* apply stuff to an array */ 00439 00440 template<typename Op, typename A, std::size_t N, int... n> 00441 constexpr inline array<decltype(Op::run(A())),N> h_array_apply(array<A, N> a, numeric_list<int, n...>) 00442 { 00443 return array<decltype(Op::run(A())),N>{{ Op::run(array_get<n>(a))... }}; 00444 } 00445 00446 template<typename Op, typename A, std::size_t N> 00447 constexpr inline array<decltype(Op::run(A())),N> array_apply(array<A, N> a) 00448 { 00449 return h_array_apply<Op>(a, typename gen_numeric_list<int, N>::type()); 00450 } 00451 00452 /* apply stuff to an array and reduce */ 00453 00454 template<typename Reducer, typename Op, typename A, std::size_t N, int... n> 00455 constexpr inline auto h_array_apply_and_reduce(array<A, N> arr, numeric_list<int, n...>) -> decltype(reduce<Reducer, typename id_numeric<int,n,decltype(Op::run(A()))>::type...>::run(Op::run(array_get<n>(arr))...)) 00456 { 00457 return reduce<Reducer, typename id_numeric<int,n,decltype(Op::run(A()))>::type...>::run(Op::run(array_get<n>(arr))...); 00458 } 00459 00460 template<typename Reducer, typename Op, typename A, std::size_t N> 00461 constexpr inline auto array_apply_and_reduce(array<A, N> a) -> decltype(h_array_apply_and_reduce<Reducer, Op, A, N>(a, typename gen_numeric_list<int, N>::type())) 00462 { 00463 return h_array_apply_and_reduce<Reducer, Op, A, N>(a, typename gen_numeric_list<int, N>::type()); 00464 } 00465 00466 /* repeat a value n times (and make an array out of it 00467 * usage: 00468 * array<int, 16> = repeat<16>(42); 00469 */ 00470 00471 template<int n> 00472 struct h_repeat 00473 { 00474 template<typename t, int... ii> 00475 constexpr static inline array<t, n> run(t v, numeric_list<int, ii...>) 00476 { 00477 return {{ typename id_numeric<int, ii, t>::type(v)... }}; 00478 } 00479 }; 00480 00481 template<int n, typename t> 00482 constexpr array<t, n> repeat(t v) { return h_repeat<n>::run(v, typename gen_numeric_list<int, n>::type()); } 00483 00484 /* instantiate a class by a C-style array */ 00485 template<class InstType, typename ArrType, std::size_t N, bool Reverse, typename... Ps> 00486 struct h_instantiate_by_c_array; 00487 00488 template<class InstType, typename ArrType, std::size_t N, typename... Ps> 00489 struct h_instantiate_by_c_array<InstType, ArrType, N, false, Ps...> 00490 { 00491 static InstType run(ArrType* arr, Ps... args) 00492 { 00493 return h_instantiate_by_c_array<InstType, ArrType, N - 1, false, Ps..., ArrType>::run(arr + 1, args..., arr[0]); 00494 } 00495 }; 00496 00497 template<class InstType, typename ArrType, std::size_t N, typename... Ps> 00498 struct h_instantiate_by_c_array<InstType, ArrType, N, true, Ps...> 00499 { 00500 static InstType run(ArrType* arr, Ps... args) 00501 { 00502 return h_instantiate_by_c_array<InstType, ArrType, N - 1, false, ArrType, Ps...>::run(arr + 1, arr[0], args...); 00503 } 00504 }; 00505 00506 template<class InstType, typename ArrType, typename... Ps> 00507 struct h_instantiate_by_c_array<InstType, ArrType, 0, false, Ps...> 00508 { 00509 static InstType run(ArrType* arr, Ps... args) 00510 { 00511 (void)arr; 00512 return InstType(args...); 00513 } 00514 }; 00515 00516 template<class InstType, typename ArrType, typename... Ps> 00517 struct h_instantiate_by_c_array<InstType, ArrType, 0, true, Ps...> 00518 { 00519 static InstType run(ArrType* arr, Ps... args) 00520 { 00521 (void)arr; 00522 return InstType(args...); 00523 } 00524 }; 00525 00526 template<class InstType, typename ArrType, std::size_t N, bool Reverse = false> 00527 InstType instantiate_by_c_array(ArrType* arr) 00528 { 00529 return h_instantiate_by_c_array<InstType, ArrType, N, Reverse>::run(arr); 00530 } 00531 00532 } // end namespace internal 00533 00534 } // end namespace Eigen 00535 00536 #else // Non C++11, fallback to emulation mode 00537 00538 #include "EmulateCXX11Meta.h" 00539 00540 #endif 00541 00542 #endif // EIGEN_CXX11META_H