get_rv.pass.cpp 1018 B

12345678910111213141516171819202122232425262728293031323334353637
  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. // template <size_t I, class T, size_t N> T&& get(array<T, N>&& a);
  10. // UNSUPPORTED: c++98, c++03
  11. #include <array>
  12. #include <memory>
  13. #include <utility>
  14. #include <cassert>
  15. // std::array is explicitly allowed to be initialized with A a = { init-list };.
  16. // Disable the missing braces warning for this reason.
  17. #include "test_macros.h"
  18. #include "disable_missing_braces_warning.h"
  19. int main(int, char**)
  20. {
  21. {
  22. typedef std::unique_ptr<double> T;
  23. typedef std::array<T, 1> C;
  24. C c = {std::unique_ptr<double>(new double(3.5))};
  25. T t = std::get<0>(std::move(c));
  26. assert(*t == 3.5);
  27. }
  28. return 0;
  29. }