]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/experimental/array/make_array.cc
1 // { dg-do compile { target c++14 } }
3 // Copyright (C) 2015-2023 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 #include <experimental/array>
21 #include <functional> // for std::ref and std::reference_wrapper
26 MoveOnly(MoveOnly
&&) = default;
27 MoveOnly
& operator=(MoveOnly
&&) = default;
33 std::array
<char, 42> y
= std::experimental::to_array(x
);
34 std::array
<int, 5> z
= std::experimental::make_array(1,2,3,4,5);
35 std::array
<long, 3> zz
= std::experimental::make_array(1,2L, 3);
36 std::array
<MoveOnly
, 1> zzz
= std::experimental::make_array(MoveOnly
{});
38 auto good
= std::experimental::make_array
<
39 std::reference_wrapper
<int>>(std::ref(dummy
));
40 constexpr char x2
[42]{};
41 constexpr std::array
<char, 42> y2
= std::experimental::to_array(x2
);
42 constexpr std::array
<int, 5> z2
=
43 std::experimental::make_array(1,2,3,4,5);
44 constexpr std::array
<long, 3> zz2
45 = std::experimental::make_array(1,2L, 3);
46 constexpr std::array
<MoveOnly
, 1> zzz2
= std::experimental::make_array(MoveOnly
{});
55 auto arr
= std::experimental::make_array
<A
>(B
{}, C
{});
56 static_assert(std::is_same
<decltype(arr
), std::array
<A
, 2>>::value
, "");