From: Patrick Palka Date: Sat, 27 Aug 2022 14:15:55 +0000 (-0400) Subject: libstdc++: Add test for std::con/disjunction's base class X-Git-Tag: basepoints/gcc-14~4971 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cace77f4fb8df18c01dfdf9040cc944eedef1147;p=thirdparty%2Fgcc.git libstdc++: Add test for std::con/disjunction's base class libstdc++-v3/ChangeLog: * testsuite/20_util/logical_traits/requirements/base_classes.cc: New test. --- diff --git a/libstdc++-v3/testsuite/20_util/logical_traits/requirements/base_classes.cc b/libstdc++-v3/testsuite/20_util/logical_traits/requirements/base_classes.cc new file mode 100644 index 000000000000..9067a3b670ed --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/logical_traits/requirements/base_classes.cc @@ -0,0 +1,34 @@ +// { dg-do compile { target c++17 } } + +#include + +template struct T : std::true_type { }; +template struct F : std::false_type { }; + +// [meta.logical]/5: The specialization conjunction has a +// public and unambiguous base that is either: +// - the first type B_i in the list true_type, B_1, ..., B_n for which +// bool(B_i::value) is false, or +// - if there is no such B_i, the last type in the list. + +static_assert(std::is_base_of_v>); +static_assert(std::is_base_of_v, std::conjunction>>); +static_assert(std::is_base_of_v, std::conjunction>>); +static_assert(std::is_base_of_v, std::conjunction, T<1>>>); +static_assert(std::is_base_of_v, std::conjunction, F<1>>>); +static_assert(std::is_base_of_v, std::conjunction, F<0>, F<1>>>); +static_assert(std::is_base_of_v, std::conjunction, F<0>, T<1>, F<1>>>); + +// [meta.logical]/10: The specialization disjunction has a +// public and unambiguous base that is either: +// - the first type B_i in the list false_type, B_1, ..., B_n for which +// bool(B_i::value) is true, or +// - if there is no such B_i, the last type in the list. + +static_assert(std::is_base_of_v>); +static_assert(std::is_base_of_v, std::disjunction>>); +static_assert(std::is_base_of_v, std::disjunction>>); +static_assert(std::is_base_of_v, std::disjunction, T<1>>>); +static_assert(std::is_base_of_v, std::disjunction, F<1>>>); +static_assert(std::is_base_of_v, std::disjunction, F<0>, F<1>>>); +static_assert(std::is_base_of_v, std::disjunction, F<0>, T<1>, F<1>>>);