and_value_valarray.pass.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. // template<class T>
  12. // valarray<bool>
  13. // operator&&(const T& x, const valarray<T>& y);
  14. #include <valarray>
  15. #include <cassert>
  16. int main()
  17. {
  18. {
  19. typedef int T;
  20. T a2[] = {1, 2, 3, 4, 0};
  21. bool a3[] = {true, true, true, true, false};
  22. const unsigned N = sizeof(a2)/sizeof(a2[0]);
  23. std::valarray<T> v2(a2, N);
  24. std::valarray<bool> v3 = 5 && v2;
  25. assert(v2.size() == v3.size());
  26. for (int i = 0; i < v3.size(); ++i)
  27. assert(v3[i] == a3[i]);
  28. }
  29. {
  30. typedef int T;
  31. T a2[] = {1, 2, 3, 4, 0};
  32. bool a3[] = {false, false, false, false, false};
  33. const unsigned N = sizeof(a2)/sizeof(a2[0]);
  34. std::valarray<T> v2(a2, N);
  35. std::valarray<bool> v3 = 0 && v2;
  36. assert(v2.size() == v3.size());
  37. for (int i = 0; i < v3.size(); ++i)
  38. assert(v3[i] == a3[i]);
  39. }
  40. }