xor_valarray.pass.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 valarray& v);
  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[] = {6, 7, 8, 9, 10};
  20. T a3[] = {7, 5, 11, 13, 15};
  21. const unsigned N = sizeof(a1)/sizeof(a1[0]);
  22. std::valarray<T> v1(a1, N);
  23. std::valarray<T> v2(a2, N);
  24. std::valarray<T> v3(a3, N);
  25. v1 ^= v2;
  26. assert(v1.size() == v2.size());
  27. assert(v1.size() == v3.size());
  28. for (std::size_t i = 0; i < v1.size(); ++i)
  29. assert(v1[i] == v3[i]);
  30. }
  31. return 0;
  32. }