Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame^] | 1 | // This file is part of Eigen, a lightweight C++ template library |
| 2 | // for linear algebra. Eigen itself is part of the KDE project. |
| 3 | // |
| 4 | // Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr> |
| 5 | // |
| 6 | // This Source Code Form is subject to the terms of the Mozilla |
| 7 | // Public License v. 2.0. If a copy of the MPL was not distributed |
| 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 9 | |
| 10 | #include "main.h" |
| 11 | |
| 12 | void test_eigen2_meta() |
| 13 | { |
| 14 | typedef float & FloatRef; |
| 15 | typedef const float & ConstFloatRef; |
| 16 | |
| 17 | VERIFY((ei_meta_if<(3<4),ei_meta_true, ei_meta_false>::ret::ret)); |
| 18 | VERIFY(( ei_is_same_type<float,float>::ret)); |
| 19 | VERIFY((!ei_is_same_type<float,double>::ret)); |
| 20 | VERIFY((!ei_is_same_type<float,float&>::ret)); |
| 21 | VERIFY((!ei_is_same_type<float,const float&>::ret)); |
| 22 | |
| 23 | VERIFY(( ei_is_same_type<float,ei_cleantype<const float&>::type >::ret)); |
| 24 | VERIFY(( ei_is_same_type<float,ei_cleantype<const float*>::type >::ret)); |
| 25 | VERIFY(( ei_is_same_type<float,ei_cleantype<const float*&>::type >::ret)); |
| 26 | VERIFY(( ei_is_same_type<float,ei_cleantype<float**>::type >::ret)); |
| 27 | VERIFY(( ei_is_same_type<float,ei_cleantype<float**&>::type >::ret)); |
| 28 | VERIFY(( ei_is_same_type<float,ei_cleantype<float* const *&>::type >::ret)); |
| 29 | VERIFY(( ei_is_same_type<float,ei_cleantype<float* const>::type >::ret)); |
| 30 | |
| 31 | VERIFY(( ei_is_same_type<float*,ei_unconst<const float*>::type >::ret)); |
| 32 | VERIFY(( ei_is_same_type<float&,ei_unconst<const float&>::type >::ret)); |
| 33 | VERIFY(( ei_is_same_type<float&,ei_unconst<ConstFloatRef>::type >::ret)); |
| 34 | |
| 35 | VERIFY(( ei_is_same_type<float&,ei_unconst<float&>::type >::ret)); |
| 36 | VERIFY(( ei_is_same_type<float,ei_unref<float&>::type >::ret)); |
| 37 | VERIFY(( ei_is_same_type<const float,ei_unref<const float&>::type >::ret)); |
| 38 | VERIFY(( ei_is_same_type<float,ei_unpointer<float*>::type >::ret)); |
| 39 | VERIFY(( ei_is_same_type<const float,ei_unpointer<const float*>::type >::ret)); |
| 40 | VERIFY(( ei_is_same_type<float,ei_unpointer<float* const >::type >::ret)); |
| 41 | |
| 42 | VERIFY(ei_meta_sqrt<1>::ret == 1); |
| 43 | #define VERIFY_META_SQRT(X) VERIFY(ei_meta_sqrt<X>::ret == int(ei_sqrt(double(X)))) |
| 44 | VERIFY_META_SQRT(2); |
| 45 | VERIFY_META_SQRT(3); |
| 46 | VERIFY_META_SQRT(4); |
| 47 | VERIFY_META_SQRT(5); |
| 48 | VERIFY_META_SQRT(6); |
| 49 | VERIFY_META_SQRT(8); |
| 50 | VERIFY_META_SQRT(9); |
| 51 | VERIFY_META_SQRT(15); |
| 52 | VERIFY_META_SQRT(16); |
| 53 | VERIFY_META_SQRT(17); |
| 54 | VERIFY_META_SQRT(255); |
| 55 | VERIFY_META_SQRT(256); |
| 56 | VERIFY_META_SQRT(257); |
| 57 | VERIFY_META_SQRT(1023); |
| 58 | VERIFY_META_SQRT(1024); |
| 59 | VERIFY_META_SQRT(1025); |
| 60 | } |