times_value.pass.cpp 885 B

123456789101112131415161718192021222324252627282930313233
  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. // valarray& operator*=(const value_type& x);
  12. #include <valarray>
  13. #include <cassert>
  14. int main()
  15. {
  16. {
  17. typedef int T;
  18. T a1[] = {1, 2, 3, 4, 5};
  19. T a2[] = {6, 12, 18, 24, 30};
  20. const unsigned N = sizeof(a1)/sizeof(a1[0]);
  21. std::valarray<T> v1(a1, N);
  22. std::valarray<T> v2(a2, N);
  23. v1 *= 6;
  24. assert(v1.size() == v2.size());
  25. for (int i = 0; i < v1.size(); ++i)
  26. assert(v1[i] == v2[i]);
  27. }
  28. }