You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
3.7 KiB

  1. // 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. #include "main.h"
  10. void test_meta()
  11. {
  12. typedef float & FloatRef;
  13. typedef const float & ConstFloatRef;
  14. 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. VERIFY(( internal::is_same<float,internal::remove_all<const float&>::type >::value));
  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<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* const *&>::type >::value));
  25. VERIFY(( internal::is_same<float,internal::remove_all<float* const>::type >::value));
  26. // test add_const
  27. VERIFY(( internal::is_same< internal::add_const<float>::type, const float >::value));
  28. VERIFY(( internal::is_same< internal::add_const<float*>::type, float* const>::value));
  29. VERIFY(( internal::is_same< internal::add_const<float const*>::type, float const* const>::value));
  30. VERIFY(( internal::is_same< internal::add_const<float&>::type, float& >::value));
  31. // test remove_const
  32. VERIFY(( internal::is_same< internal::remove_const<float const* const>::type, float const* >::value));
  33. VERIFY(( internal::is_same< internal::remove_const<float const*>::type, float const* >::value));
  34. VERIFY(( internal::is_same< internal::remove_const<float* const>::type, float* >::value));
  35. // test add_const_on_value_type
  36. VERIFY(( internal::is_same< internal::add_const_on_value_type<float&>::type, float const& >::value));
  37. VERIFY(( internal::is_same< internal::add_const_on_value_type<float*>::type, float const* >::value));
  38. VERIFY(( internal::is_same< internal::add_const_on_value_type<float>::type, const float >::value));
  39. VERIFY(( internal::is_same< internal::add_const_on_value_type<const float>::type, const float >::value));
  40. VERIFY(( internal::is_same< internal::add_const_on_value_type<const float* const>::type, const float* const>::value));
  41. VERIFY(( internal::is_same< internal::add_const_on_value_type<float* const>::type, const float* const>::value));
  42. VERIFY(( internal::is_same<float,internal::remove_reference<float&>::type >::value));
  43. VERIFY(( internal::is_same<const float,internal::remove_reference<const float&>::type >::value));
  44. VERIFY(( internal::is_same<float,internal::remove_pointer<float*>::type >::value));
  45. VERIFY(( internal::is_same<const float,internal::remove_pointer<const float*>::type >::value));
  46. VERIFY(( internal::is_same<float,internal::remove_pointer<float* const >::type >::value));
  47. VERIFY(internal::meta_sqrt<1>::ret == 1);
  48. #define VERIFY_META_SQRT(X) VERIFY(internal::meta_sqrt<X>::ret == int(internal::sqrt(double(X))))
  49. VERIFY_META_SQRT(2);
  50. VERIFY_META_SQRT(3);
  51. VERIFY_META_SQRT(4);
  52. VERIFY_META_SQRT(5);
  53. VERIFY_META_SQRT(6);
  54. VERIFY_META_SQRT(8);
  55. VERIFY_META_SQRT(9);
  56. VERIFY_META_SQRT(15);
  57. VERIFY_META_SQRT(16);
  58. VERIFY_META_SQRT(17);
  59. VERIFY_META_SQRT(255);
  60. VERIFY_META_SQRT(256);
  61. VERIFY_META_SQRT(257);
  62. VERIFY_META_SQRT(1023);
  63. VERIFY_META_SQRT(1024);
  64. VERIFY_META_SQRT(1025);
  65. }