times_value_valarray.pass.cpp 902 B

1234567891011121314151617181920212223242526272829303132
  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> valarray<T> operator*(const T& x, const valarray<T>& y);
  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 = 6 * v1;
  23. assert(v1.size() == v2.size());
  24. for (int i = 0; i < v2.size(); ++i)
  25. assert(v2[i] == a2[i]);
  26. }
  27. }