swap.fail.cpp 926 B

12345678910111213141516171819202122232425262728293031
  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. // <array>
  9. // void swap(array& a);
  10. #include <array>
  11. #include <cassert>
  12. // std::array is explicitly allowed to be initialized with A a = { init-list };.
  13. // Disable the missing braces warning for this reason.
  14. #include "disable_missing_braces_warning.h"
  15. int main(int, char**) {
  16. {
  17. typedef double T;
  18. typedef std::array<const T, 0> C;
  19. C c = {};
  20. C c2 = {};
  21. // expected-error-re@array:* {{static_assert failed {{.*}}"cannot swap zero-sized array of type 'const T'"}}
  22. c.swap(c2); // expected-note {{requested here}}
  23. }
  24. return 0;
  25. }