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.

60 lines
2.4 KiB

  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. #include "main.h"
  10. void test_eigen2_meta()
  11. {
  12. typedef float & FloatRef;
  13. typedef const float & ConstFloatRef;
  14. VERIFY((ei_meta_if<(3<4),ei_meta_true, ei_meta_false>::ret::ret));
  15. VERIFY(( ei_is_same_type<float,float>::ret));
  16. VERIFY((!ei_is_same_type<float,double>::ret));
  17. VERIFY((!ei_is_same_type<float,float&>::ret));
  18. VERIFY((!ei_is_same_type<float,const float&>::ret));
  19. VERIFY(( ei_is_same_type<float,ei_cleantype<const float&>::type >::ret));
  20. VERIFY(( ei_is_same_type<float,ei_cleantype<const float*>::type >::ret));
  21. VERIFY(( ei_is_same_type<float,ei_cleantype<const float*&>::type >::ret));
  22. VERIFY(( ei_is_same_type<float,ei_cleantype<float**>::type >::ret));
  23. VERIFY(( ei_is_same_type<float,ei_cleantype<float**&>::type >::ret));
  24. VERIFY(( ei_is_same_type<float,ei_cleantype<float* const *&>::type >::ret));
  25. VERIFY(( ei_is_same_type<float,ei_cleantype<float* const>::type >::ret));
  26. VERIFY(( ei_is_same_type<float*,ei_unconst<const float*>::type >::ret));
  27. VERIFY(( ei_is_same_type<float&,ei_unconst<const float&>::type >::ret));
  28. VERIFY(( ei_is_same_type<float&,ei_unconst<ConstFloatRef>::type >::ret));
  29. VERIFY(( ei_is_same_type<float&,ei_unconst<float&>::type >::ret));
  30. VERIFY(( ei_is_same_type<float,ei_unref<float&>::type >::ret));
  31. VERIFY(( ei_is_same_type<const float,ei_unref<const float&>::type >::ret));
  32. VERIFY(( ei_is_same_type<float,ei_unpointer<float*>::type >::ret));
  33. VERIFY(( ei_is_same_type<const float,ei_unpointer<const float*>::type >::ret));
  34. VERIFY(( ei_is_same_type<float,ei_unpointer<float* const >::type >::ret));
  35. VERIFY(ei_meta_sqrt<1>::ret == 1);
  36. #define VERIFY_META_SQRT(X) VERIFY(ei_meta_sqrt<X>::ret == int(ei_sqrt(double(X))))
  37. VERIFY_META_SQRT(2);
  38. VERIFY_META_SQRT(3);
  39. VERIFY_META_SQRT(4);
  40. VERIFY_META_SQRT(5);
  41. VERIFY_META_SQRT(6);
  42. VERIFY_META_SQRT(8);
  43. VERIFY_META_SQRT(9);
  44. VERIFY_META_SQRT(15);
  45. VERIFY_META_SQRT(16);
  46. VERIFY_META_SQRT(17);
  47. VERIFY_META_SQRT(255);
  48. VERIFY_META_SQRT(256);
  49. VERIFY_META_SQRT(257);
  50. VERIFY_META_SQRT(1023);
  51. VERIFY_META_SQRT(1024);
  52. VERIFY_META_SQRT(1025);
  53. }