Debian Codegraph @

libstdc++-v3/testsuite/20_util/logical_traits/requirements/base_classes.cc

raw
1 // { dg-do compile { target c++17 } }
2
3 #include <type_traits>
4
5 template<int> struct T : std::true_type { };
6 template<int> struct F : std::false_type { };
7
8 // [meta.logical]/5: The specialization conjunction<B_1, ..., B_n> has a
9 // public and unambiguous base that is either:
10 // - the first type B_i in the list true_type, B_1, ..., B_n for which
11 // bool(B_i::value) is false, or
12 // - if there is no such B_i, the last type in the list.
13
14 static_assert(std::is_base_of_v<std::true_type, std::conjunction<>>);
15 static_assert(std::is_base_of_v<T<0>, std::conjunction<T<0>>>);
16 static_assert(std::is_base_of_v<F<0>, std::conjunction<F<0>>>);
17 static_assert(std::is_base_of_v<T<1>, std::conjunction<T<0>, T<1>>>);
18 static_assert(std::is_base_of_v<F<0>, std::conjunction<F<0>, F<1>>>);
19 static_assert(std::is_base_of_v<F<0>, std::conjunction<T<0>, F<0>, F<1>>>);
20 static_assert(std::is_base_of_v<F<0>, std::conjunction<T<0>, F<0>, T<1>, F<1>>>);
21
22 // [meta.logical]/10: The specialization disjunction<B_1, ..., B_n> has a
23 // public and unambiguous base that is either:
24 // - the first type B_i in the list false_type, B_1, ..., B_n for which
25 // bool(B_i::value) is true, or
26 // - if there is no such B_i, the last type in the list.
27
28 static_assert(std::is_base_of_v<std::false_type, std::disjunction<>>);
29 static_assert(std::is_base_of_v<T<0>, std::disjunction<T<0>>>);
30 static_assert(std::is_base_of_v<F<0>, std::disjunction<F<0>>>);
31 static_assert(std::is_base_of_v<T<0>, std::disjunction<T<0>, T<1>>>);
32 static_assert(std::is_base_of_v<F<1>, std::disjunction<F<0>, F<1>>>);
33 static_assert(std::is_base_of_v<T<0>, std::disjunction<T<0>, F<0>, F<1>>>);
34 static_assert(std::is_base_of_v<T<0>, std::disjunction<T<0>, F<0>, T<1>, F<1>>>);