default.pass.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. // array();
  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 "test_macros.h"
  15. #include "disable_missing_braces_warning.h"
  16. struct NoDefault {
  17. NoDefault(int) {}
  18. };
  19. int main(int, char**)
  20. {
  21. {
  22. typedef double T;
  23. typedef std::array<T, 3> C;
  24. C c;
  25. assert(c.size() == 3);
  26. }
  27. {
  28. typedef double T;
  29. typedef std::array<T, 0> C;
  30. C c;
  31. assert(c.size() == 0);
  32. }
  33. {
  34. typedef std::array<NoDefault, 0> C;
  35. C c;
  36. assert(c.size() == 0);
  37. C c1 = {};
  38. assert(c1.size() == 0);
  39. C c2 = {{}};
  40. assert(c2.size() == 0);
  41. }
  42. return 0;
  43. }