xref: /llvm-project/libcxx/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp (revision 57b08b0944046a6a57ee9b7b479181f548a5b9b4)
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 
9 // <array>
10 
11 // template <size_t I, class T, size_t N> T&& get(array<T, N>&& a);
12 
13 // UNSUPPORTED: c++98, c++03
14 
15 #include <array>
16 #include <memory>
17 #include <utility>
18 #include <cassert>
19 
20 // std::array is explicitly allowed to be initialized with A a = { init-list };.
21 // Disable the missing braces warning for this reason.
22 #include "disable_missing_braces_warning.h"
23 
24 int main()
25 {
26 
27     {
28         typedef std::unique_ptr<double> T;
29         typedef std::array<T, 1> C;
30         C c = {std::unique_ptr<double>(new double(3.5))};
31         T t = std::get<0>(std::move(c));
32         assert(*t == 3.5);
33     }
34 }
35