equal_value_valarray.pass.cpp 942 B

12345678910111213141516171819202122232425262728293031323334
  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[] = {false, true, false, false, false};
  22. const unsigned N = sizeof(a2)/sizeof(a2[0]);
  23. std::valarray<T> v2(a2, N);
  24. std::valarray<bool> v3 = 2 == v2;
  25. assert(v2.size() == v3.size());
  26. for (int i = 0; i < v3.size(); ++i)
  27. assert(v3[i] == a3[i]);
  28. }
  29. }