public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Patrick Palka <ppalka@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r13-2236] libstdc++: Add test for std::con/disjunction's base class
Date: Sat, 27 Aug 2022 14:16:38 +0000 (GMT)	[thread overview]
Message-ID: <20220827141638.1CB89381E088@sourceware.org> (raw)

https://gcc.gnu.org/g:cace77f4fb8df18c01dfdf9040cc944eedef1147

commit r13-2236-gcace77f4fb8df18c01dfdf9040cc944eedef1147
Author: Patrick Palka <ppalka@redhat.com>
Date:   Sat Aug 27 10:15:55 2022 -0400

    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:
---
 .../logical_traits/requirements/base_classes.cc    | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)

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 00000000000..9067a3b670e
--- /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 <type_traits>
+
+template<int> struct T : std::true_type { };
+template<int> struct F : std::false_type { };
+
+// [meta.logical]/5: The specialization conjunction<B_1, ..., B_n> 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<std::true_type, std::conjunction<>>);
+static_assert(std::is_base_of_v<T<0>, std::conjunction<T<0>>>);
+static_assert(std::is_base_of_v<F<0>, std::conjunction<F<0>>>);
+static_assert(std::is_base_of_v<T<1>, std::conjunction<T<0>, T<1>>>);
+static_assert(std::is_base_of_v<F<0>, std::conjunction<F<0>, F<1>>>);
+static_assert(std::is_base_of_v<F<0>, std::conjunction<T<0>, F<0>, F<1>>>);
+static_assert(std::is_base_of_v<F<0>, std::conjunction<T<0>, F<0>, T<1>, F<1>>>);
+
+// [meta.logical]/10: The specialization disjunction<B_1, ..., B_n> 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<std::false_type, std::disjunction<>>);
+static_assert(std::is_base_of_v<T<0>, std::disjunction<T<0>>>);
+static_assert(std::is_base_of_v<F<0>, std::disjunction<F<0>>>);
+static_assert(std::is_base_of_v<T<0>, std::disjunction<T<0>, T<1>>>);
+static_assert(std::is_base_of_v<F<1>, std::disjunction<F<0>, F<1>>>);
+static_assert(std::is_base_of_v<T<0>, std::disjunction<T<0>, F<0>, F<1>>>);
+static_assert(std::is_base_of_v<T<0>, std::disjunction<T<0>, F<0>, T<1>, F<1>>>);

                 reply	other threads:[~2022-08-27 14:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220827141638.1CB89381E088@sourceware.org \
    --to=ppalka@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).