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, c++11, c++14
10 // type_traits
11
12 // template<class... B> struct conjunction; // C++17
13 // template<class... B>
14 // constexpr bool conjunction_v = conjunction<B...>::value; // C++17
15
16 #include <type_traits>
17 #include <cassert>
18
19 #include "test_macros.h"
20
21 struct True { static constexpr bool value = true; };
22 struct False { static constexpr bool value = false; };
23
main(int,char **)24 int main(int, char**)
25 {
26 static_assert ( std::conjunction<>::value, "" );
27 static_assert ( std::conjunction<std::true_type >::value, "" );
28 static_assert (!std::conjunction<std::false_type>::value, "" );
29
30 static_assert ( std::conjunction_v<>, "" );
31 static_assert ( std::conjunction_v<std::true_type >, "" );
32 static_assert (!std::conjunction_v<std::false_type>, "" );
33
34 static_assert ( std::conjunction<std::true_type, std::true_type >::value, "" );
35 static_assert (!std::conjunction<std::true_type, std::false_type>::value, "" );
36 static_assert (!std::conjunction<std::false_type, std::true_type >::value, "" );
37 static_assert (!std::conjunction<std::false_type, std::false_type>::value, "" );
38
39 static_assert ( std::conjunction_v<std::true_type, std::true_type >, "" );
40 static_assert (!std::conjunction_v<std::true_type, std::false_type>, "" );
41 static_assert (!std::conjunction_v<std::false_type, std::true_type >, "" );
42 static_assert (!std::conjunction_v<std::false_type, std::false_type>, "" );
43
44 static_assert ( std::conjunction<std::true_type, std::true_type, std::true_type >::value, "" );
45 static_assert (!std::conjunction<std::true_type, std::false_type, std::true_type >::value, "" );
46 static_assert (!std::conjunction<std::false_type, std::true_type, std::true_type >::value, "" );
47 static_assert (!std::conjunction<std::false_type, std::false_type, std::true_type >::value, "" );
48 static_assert (!std::conjunction<std::true_type, std::true_type, std::false_type>::value, "" );
49 static_assert (!std::conjunction<std::true_type, std::false_type, std::false_type>::value, "" );
50 static_assert (!std::conjunction<std::false_type, std::true_type, std::false_type>::value, "" );
51 static_assert (!std::conjunction<std::false_type, std::false_type, std::false_type>::value, "" );
52
53 static_assert ( std::conjunction_v<std::true_type, std::true_type, std::true_type >, "" );
54 static_assert (!std::conjunction_v<std::true_type, std::false_type, std::true_type >, "" );
55 static_assert (!std::conjunction_v<std::false_type, std::true_type, std::true_type >, "" );
56 static_assert (!std::conjunction_v<std::false_type, std::false_type, std::true_type >, "" );
57 static_assert (!std::conjunction_v<std::true_type, std::true_type, std::false_type>, "" );
58 static_assert (!std::conjunction_v<std::true_type, std::false_type, std::false_type>, "" );
59 static_assert (!std::conjunction_v<std::false_type, std::true_type, std::false_type>, "" );
60 static_assert (!std::conjunction_v<std::false_type, std::false_type, std::false_type>, "" );
61
62 static_assert ( std::conjunction<True >::value, "" );
63 static_assert (!std::conjunction<False>::value, "" );
64
65 static_assert ( std::conjunction_v<True >, "" );
66 static_assert (!std::conjunction_v<False>, "" );
67
68 return 0;
69 }
70