max.pass.cpp 990 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // <valarray>
  10. // template<class T> class valarray;
  11. // value_type max() const;
  12. #include <valarray>
  13. #include <cassert>
  14. int main()
  15. {
  16. {
  17. typedef double T;
  18. T a1[] = {1.5, 2.5, -3, 4, -5.5};
  19. const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
  20. std::valarray<T> v1(a1, N1);
  21. assert(v1.max() == 4.0);
  22. }
  23. {
  24. typedef double T;
  25. std::valarray<T> v1;
  26. v1.max();
  27. }
  28. {
  29. typedef double T;
  30. T a1[] = {1.5, 2.5, -3, 4, -5.5};
  31. const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
  32. std::valarray<T> v1(a1, N1);
  33. assert((2*v1).max() == 8.0);
  34. }
  35. }