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.
00003 //
00004 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.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_meta()
00028 {
00029   typedef float & FloatRef;
00030   typedef const float & ConstFloatRef;
00031   
00032   VERIFY((internal::conditional<(3<4),internal::true_type, internal::false_type>::type::value));
00033   VERIFY(( internal::is_same<float,float>::value));
00034   VERIFY((!internal::is_same<float,double>::value));
00035   VERIFY((!internal::is_same<float,float&>::value));
00036   VERIFY((!internal::is_same<float,const float&>::value));
00037   
00038   VERIFY(( internal::is_same<float,internal::remove_all<const float&>::type >::value));
00039   VERIFY(( internal::is_same<float,internal::remove_all<const float*>::type >::value));
00040   VERIFY(( internal::is_same<float,internal::remove_all<const float*&>::type >::value));
00041   VERIFY(( internal::is_same<float,internal::remove_all<float**>::type >::value));
00042   VERIFY(( internal::is_same<float,internal::remove_all<float**&>::type >::value));
00043   VERIFY(( internal::is_same<float,internal::remove_all<float* const *&>::type >::value));
00044   VERIFY(( internal::is_same<float,internal::remove_all<float* const>::type >::value));
00045 
00046   // test add_const
00047   VERIFY(( internal::is_same< internal::add_const<float>::type, const float >::value));
00048   VERIFY(( internal::is_same< internal::add_const<float*>::type, float* const>::value));
00049   VERIFY(( internal::is_same< internal::add_const<float const*>::type, float const* const>::value));
00050   VERIFY(( internal::is_same< internal::add_const<float&>::type, float& >::value));
00051 
00052   // test remove_const
00053   VERIFY(( internal::is_same< internal::remove_const<float const* const>::type, float const* >::value));
00054   VERIFY(( internal::is_same< internal::remove_const<float const*>::type, float const* >::value));
00055   VERIFY(( internal::is_same< internal::remove_const<float* const>::type, float* >::value));
00056 
00057   // test add_const_on_value_type
00058   VERIFY(( internal::is_same< internal::add_const_on_value_type<float&>::type, float const& >::value));
00059   VERIFY(( internal::is_same< internal::add_const_on_value_type<float*>::type, float const* >::value));
00060 
00061   VERIFY(( internal::is_same< internal::add_const_on_value_type<float>::type, const float >::value));
00062   VERIFY(( internal::is_same< internal::add_const_on_value_type<const float>::type, const float >::value));
00063 
00064   VERIFY(( internal::is_same< internal::add_const_on_value_type<const float* const>::type, const float* const>::value));
00065   VERIFY(( internal::is_same< internal::add_const_on_value_type<float* const>::type, const float* const>::value));
00066   
00067   VERIFY(( internal::is_same<float,internal::remove_reference<float&>::type >::value));
00068   VERIFY(( internal::is_same<const float,internal::remove_reference<const float&>::type >::value));
00069   VERIFY(( internal::is_same<float,internal::remove_pointer<float*>::type >::value));
00070   VERIFY(( internal::is_same<const float,internal::remove_pointer<const float*>::type >::value));
00071   VERIFY(( internal::is_same<float,internal::remove_pointer<float* const >::type >::value));
00072   
00073   VERIFY(internal::meta_sqrt<1>::ret == 1);
00074   #define VERIFY_META_SQRT(X) VERIFY(internal::meta_sqrt<X>::ret == int(internal::sqrt(double(X))))
00075   VERIFY_META_SQRT(2);
00076   VERIFY_META_SQRT(3);
00077   VERIFY_META_SQRT(4);
00078   VERIFY_META_SQRT(5);
00079   VERIFY_META_SQRT(6);
00080   VERIFY_META_SQRT(8);
00081   VERIFY_META_SQRT(9);
00082   VERIFY_META_SQRT(15);
00083   VERIFY_META_SQRT(16);
00084   VERIFY_META_SQRT(17);
00085   VERIFY_META_SQRT(255);
00086   VERIFY_META_SQRT(256);
00087   VERIFY_META_SQRT(257);
00088   VERIFY_META_SQRT(1023);
00089   VERIFY_META_SQRT(1024);
00090   VERIFY_META_SQRT(1025);
00091 }


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:31:59