eigen2_meta.cpp
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra. Eigen itself is part of the KDE project.
00003 //
00004 // Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
00005 //
00006 // Eigen is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 3 of the License, or (at your option) any later version.
00010 //
00011 // Alternatively, you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License as
00013 // published by the Free Software Foundation; either version 2 of
00014 // the License, or (at your option) any later version.
00015 //
00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License and a copy of the GNU General Public License along with
00023 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00024 
00025 #include "main.h"
00026 
00027 void test_eigen2_meta()
00028 {
00029   typedef float & FloatRef;
00030   typedef const float & ConstFloatRef;
00031   
00032   VERIFY((ei_meta_if<(3<4),ei_meta_true, ei_meta_false>::ret::ret));
00033   VERIFY(( ei_is_same_type<float,float>::ret));
00034   VERIFY((!ei_is_same_type<float,double>::ret));
00035   VERIFY((!ei_is_same_type<float,float&>::ret));
00036   VERIFY((!ei_is_same_type<float,const float&>::ret));
00037   
00038   VERIFY(( ei_is_same_type<float,ei_cleantype<const float&>::type >::ret));
00039   VERIFY(( ei_is_same_type<float,ei_cleantype<const float*>::type >::ret));
00040   VERIFY(( ei_is_same_type<float,ei_cleantype<const float*&>::type >::ret));
00041   VERIFY(( ei_is_same_type<float,ei_cleantype<float**>::type >::ret));
00042   VERIFY(( ei_is_same_type<float,ei_cleantype<float**&>::type >::ret));
00043   VERIFY(( ei_is_same_type<float,ei_cleantype<float* const *&>::type >::ret));
00044   VERIFY(( ei_is_same_type<float,ei_cleantype<float* const>::type >::ret));
00045 
00046   VERIFY(( ei_is_same_type<float*,ei_unconst<const float*>::type >::ret));
00047   VERIFY(( ei_is_same_type<float&,ei_unconst<const float&>::type >::ret));
00048   VERIFY(( ei_is_same_type<float&,ei_unconst<ConstFloatRef>::type >::ret));
00049   
00050   VERIFY(( ei_is_same_type<float&,ei_unconst<float&>::type >::ret));
00051   VERIFY(( ei_is_same_type<float,ei_unref<float&>::type >::ret));
00052   VERIFY(( ei_is_same_type<const float,ei_unref<const float&>::type >::ret));
00053   VERIFY(( ei_is_same_type<float,ei_unpointer<float*>::type >::ret));
00054   VERIFY(( ei_is_same_type<const float,ei_unpointer<const float*>::type >::ret));
00055   VERIFY(( ei_is_same_type<float,ei_unpointer<float* const >::type >::ret));
00056   
00057   VERIFY(ei_meta_sqrt<1>::ret == 1);
00058   #define VERIFY_META_SQRT(X) VERIFY(ei_meta_sqrt<X>::ret == int(ei_sqrt(double(X))))
00059   VERIFY_META_SQRT(2);
00060   VERIFY_META_SQRT(3);
00061   VERIFY_META_SQRT(4);
00062   VERIFY_META_SQRT(5);
00063   VERIFY_META_SQRT(6);
00064   VERIFY_META_SQRT(8);
00065   VERIFY_META_SQRT(9);
00066   VERIFY_META_SQRT(15);
00067   VERIFY_META_SQRT(16);
00068   VERIFY_META_SQRT(17);
00069   VERIFY_META_SQRT(255);
00070   VERIFY_META_SQRT(256);
00071   VERIFY_META_SQRT(257);
00072   VERIFY_META_SQRT(1023);
00073   VERIFY_META_SQRT(1024);
00074   VERIFY_META_SQRT(1025);
00075 }


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:32:38