blob: 3302c5887fadb3b565e118ba71ac7fad33163b4e [file] [log] [blame]
Narayan Kamathc981c482012-11-02 10:59:05 +00001// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.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
12void test_meta()
13{
Narayan Kamathc981c482012-11-02 10:59:05 +000014 VERIFY((internal::conditional<(3<4),internal::true_type, internal::false_type>::type::value));
15 VERIFY(( internal::is_same<float,float>::value));
16 VERIFY((!internal::is_same<float,double>::value));
17 VERIFY((!internal::is_same<float,float&>::value));
18 VERIFY((!internal::is_same<float,const float&>::value));
19
20 VERIFY(( internal::is_same<float,internal::remove_all<const float&>::type >::value));
21 VERIFY(( internal::is_same<float,internal::remove_all<const float*>::type >::value));
22 VERIFY(( internal::is_same<float,internal::remove_all<const float*&>::type >::value));
23 VERIFY(( internal::is_same<float,internal::remove_all<float**>::type >::value));
24 VERIFY(( internal::is_same<float,internal::remove_all<float**&>::type >::value));
25 VERIFY(( internal::is_same<float,internal::remove_all<float* const *&>::type >::value));
26 VERIFY(( internal::is_same<float,internal::remove_all<float* const>::type >::value));
27
28 // test add_const
29 VERIFY(( internal::is_same< internal::add_const<float>::type, const float >::value));
30 VERIFY(( internal::is_same< internal::add_const<float*>::type, float* const>::value));
31 VERIFY(( internal::is_same< internal::add_const<float const*>::type, float const* const>::value));
32 VERIFY(( internal::is_same< internal::add_const<float&>::type, float& >::value));
33
34 // test remove_const
35 VERIFY(( internal::is_same< internal::remove_const<float const* const>::type, float const* >::value));
36 VERIFY(( internal::is_same< internal::remove_const<float const*>::type, float const* >::value));
37 VERIFY(( internal::is_same< internal::remove_const<float* const>::type, float* >::value));
38
39 // test add_const_on_value_type
40 VERIFY(( internal::is_same< internal::add_const_on_value_type<float&>::type, float const& >::value));
41 VERIFY(( internal::is_same< internal::add_const_on_value_type<float*>::type, float const* >::value));
42
43 VERIFY(( internal::is_same< internal::add_const_on_value_type<float>::type, const float >::value));
44 VERIFY(( internal::is_same< internal::add_const_on_value_type<const float>::type, const float >::value));
45
46 VERIFY(( internal::is_same< internal::add_const_on_value_type<const float* const>::type, const float* const>::value));
47 VERIFY(( internal::is_same< internal::add_const_on_value_type<float* const>::type, const float* const>::value));
48
49 VERIFY(( internal::is_same<float,internal::remove_reference<float&>::type >::value));
50 VERIFY(( internal::is_same<const float,internal::remove_reference<const float&>::type >::value));
51 VERIFY(( internal::is_same<float,internal::remove_pointer<float*>::type >::value));
52 VERIFY(( internal::is_same<const float,internal::remove_pointer<const float*>::type >::value));
53 VERIFY(( internal::is_same<float,internal::remove_pointer<float* const >::type >::value));
54
55 VERIFY(internal::meta_sqrt<1>::ret == 1);
Carlos Hernandez7faaa9f2014-08-05 17:53:32 -070056 #define VERIFY_META_SQRT(X) VERIFY(internal::meta_sqrt<X>::ret == int(std::sqrt(double(X))))
Narayan Kamathc981c482012-11-02 10:59:05 +000057 VERIFY_META_SQRT(2);
58 VERIFY_META_SQRT(3);
59 VERIFY_META_SQRT(4);
60 VERIFY_META_SQRT(5);
61 VERIFY_META_SQRT(6);
62 VERIFY_META_SQRT(8);
63 VERIFY_META_SQRT(9);
64 VERIFY_META_SQRT(15);
65 VERIFY_META_SQRT(16);
66 VERIFY_META_SQRT(17);
67 VERIFY_META_SQRT(255);
68 VERIFY_META_SQRT(256);
69 VERIFY_META_SQRT(257);
70 VERIFY_META_SQRT(1023);
71 VERIFY_META_SQRT(1024);
72 VERIFY_META_SQRT(1025);
73}