modulo_value.pass.cpp 949 B

1234567891011121314151617181920212223242526272829303132333435
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // <valarray>
  9. // template<class T> class valarray;
  10. // valarray& operator%=(const value_type& x);
  11. #include <valarray>
  12. #include <cassert>
  13. #include <cstddef>
  14. int main(int, char**)
  15. {
  16. {
  17. typedef int T;
  18. T a1[] = {1, 2, 3, 4, 5};
  19. T a2[] = {1, 2, 0, 1, 2};
  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 %= 3;
  24. assert(v1.size() == v2.size());
  25. for (std::size_t i = 0; i < v1.size(); ++i)
  26. assert(v1[i] == v2[i]);
  27. }
  28. return 0;
  29. }