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 | // UNSUPPORTED: c++03 |
10 | |
11 | // "support/test_convertible.h" |
12 | |
13 | #include "test_convertible.h" |
14 | |
15 | #include "test_macros.h" |
16 | |
17 | struct ImplicitDefault { |
18 | ImplicitDefault() {} |
19 | }; |
20 | static_assert(test_convertible<ImplicitDefault>(), "Must be convertible" ); |
21 | |
22 | struct ExplicitDefault { |
23 | explicit ExplicitDefault() {} |
24 | }; |
25 | static_assert(!test_convertible<ExplicitDefault>(), "Must not be convertible" ); |
26 | |
27 | struct ImplicitInt { |
28 | ImplicitInt(int) {} |
29 | }; |
30 | static_assert(test_convertible<ImplicitInt, int>(), "Must be convertible" ); |
31 | |
32 | struct ExplicitInt { |
33 | explicit ExplicitInt(int) {} |
34 | }; |
35 | static_assert(!test_convertible<ExplicitInt, int>(), "Must not be convertible" ); |
36 | |
37 | struct ImplicitCopy { |
38 | ImplicitCopy(ImplicitCopy const&) {} |
39 | }; |
40 | static_assert(test_convertible<ImplicitCopy, ImplicitCopy>(), "Must be convertible" ); |
41 | |
42 | struct ExplicitCopy { |
43 | explicit ExplicitCopy(ExplicitCopy const&) {} |
44 | }; |
45 | static_assert(!test_convertible<ExplicitCopy, ExplicitCopy>(), "Must not be convertible" ); |
46 | |
47 | struct ImplicitMove { |
48 | ImplicitMove(ImplicitMove&&) {} |
49 | }; |
50 | static_assert(test_convertible<ImplicitMove, ImplicitMove>(), "Must be convertible" ); |
51 | |
52 | struct ExplicitMove { |
53 | explicit ExplicitMove(ExplicitMove&&) {} |
54 | }; |
55 | static_assert(!test_convertible<ExplicitMove, ExplicitMove>(), "Must not be convertible" ); |
56 | |
57 | struct ImplicitArgs { |
58 | ImplicitArgs(int, int, int) {} |
59 | }; |
60 | static_assert(test_convertible<ImplicitArgs, int, int, int>(), "Must be convertible" ); |
61 | |
62 | struct ExplicitArgs { |
63 | explicit ExplicitArgs(int, int, int) {} |
64 | }; |
65 | static_assert(!test_convertible<ExplicitArgs, int, int, int>(), "Must not be convertible" ); |
66 | |
67 | int main(int, char**) { |
68 | // Nothing to do |
69 | |
70 | return 0; |
71 | } |
72 | |