[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / libcxx / test / std / containers / sequences / array / array.cons / implicit_copy.pass.cpp
blobc0e205c8322a499ecdcbdaf8b152cef4559b13f4
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 //===----------------------------------------------------------------------===//
9 // <array>
11 // implicitly generated array constructors / assignment operators
13 #include <array>
14 #include <type_traits>
15 #include <cassert>
16 #include "test_macros.h"
18 // std::array is explicitly allowed to be initialized with A a = { init-list };.
19 // Disable the missing braces warning for this reason.
20 #include "disable_missing_braces_warning.h"
22 // In C++03 the copy assignment operator is not deleted when the implicitly
23 // generated operator would be ill-formed; like in the case of a struct with a
24 // const member.
25 #if TEST_STD_VER < 11
26 #define TEST_NOT_COPY_ASSIGNABLE(T) ((void)0)
27 #else
28 #define TEST_NOT_COPY_ASSIGNABLE(T) static_assert(!std::is_copy_assignable<T>::value, "")
29 #endif
31 struct NoDefault {
32 NoDefault(int) {}
35 int main(int, char**) {
37 typedef double T;
38 typedef std::array<T, 3> C;
39 C c = {1.1, 2.2, 3.3};
40 C c2 = c;
41 c2 = c;
42 static_assert(std::is_copy_constructible<C>::value, "");
43 static_assert(std::is_copy_assignable<C>::value, "");
46 typedef double T;
47 typedef std::array<const T, 3> C;
48 C c = {1.1, 2.2, 3.3};
49 C c2 = c;
50 ((void)c2);
51 static_assert(std::is_copy_constructible<C>::value, "");
52 TEST_NOT_COPY_ASSIGNABLE(C);
55 typedef double T;
56 typedef std::array<T, 0> C;
57 C c = {};
58 C c2 = c;
59 c2 = c;
60 static_assert(std::is_copy_constructible<C>::value, "");
61 static_assert(std::is_copy_assignable<C>::value, "");
64 // const arrays of size 0 should disable the implicit copy assignment operator.
65 typedef double T;
66 typedef std::array<const T, 0> C;
67 C c = {{}};
68 C c2 = c;
69 ((void)c2);
70 static_assert(std::is_copy_constructible<C>::value, "");
71 TEST_NOT_COPY_ASSIGNABLE(C);
74 typedef NoDefault T;
75 typedef std::array<T, 0> C;
76 C c = {};
77 C c2 = c;
78 c2 = c;
79 static_assert(std::is_copy_constructible<C>::value, "");
80 static_assert(std::is_copy_assignable<C>::value, "");
83 typedef NoDefault T;
84 typedef std::array<const T, 0> C;
85 C c = {{}};
86 C c2 = c;
87 ((void)c2);
88 static_assert(std::is_copy_constructible<C>::value, "");
89 TEST_NOT_COPY_ASSIGNABLE(C);
93 return 0;