1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // implicitly generated array constructors / assignment operators
14 #include <type_traits>
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
26 #define TEST_NOT_COPY_ASSIGNABLE(T) ((void)0)
28 #define TEST_NOT_COPY_ASSIGNABLE(T) static_assert(!std::is_copy_assignable<T>::value, "")
35 int main(int, char**) {
38 typedef std::array
<T
, 3> C
;
39 C c
= {1.1, 2.2, 3.3};
42 static_assert(std::is_copy_constructible
<C
>::value
, "");
43 static_assert(std::is_copy_assignable
<C
>::value
, "");
47 typedef std::array
<const T
, 3> C
;
48 C c
= {1.1, 2.2, 3.3};
51 static_assert(std::is_copy_constructible
<C
>::value
, "");
52 TEST_NOT_COPY_ASSIGNABLE(C
);
56 typedef std::array
<T
, 0> 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.
66 typedef std::array
<const T
, 0> C
;
70 static_assert(std::is_copy_constructible
<C
>::value
, "");
71 TEST_NOT_COPY_ASSIGNABLE(C
);
75 typedef std::array
<T
, 0> C
;
79 static_assert(std::is_copy_constructible
<C
>::value
, "");
80 static_assert(std::is_copy_assignable
<C
>::value
, "");
84 typedef std::array
<const T
, 0> C
;
88 static_assert(std::is_copy_constructible
<C
>::value
, "");
89 TEST_NOT_COPY_ASSIGNABLE(C
);