public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: Add test for std::con/disjunction's base class
@ 2022-08-26  1:04 Patrick Palka
  2022-08-26  8:01 ` Jonathan Wakely
  0 siblings, 1 reply; 3+ messages in thread
From: Patrick Palka @ 2022-08-26  1:04 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++, Patrick Palka

Tested on x86_64-pc-linux-gnu, does this look OK for trunk?

libstdc++-v3/ChangeLog:

	* testsuite/20_util/logical_traits/requirements/base_classes.cc: New test.
---
 .../requirements/base_classes.cc              | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 libstdc++-v3/testsuite/20_util/logical_traits/requirements/base_classes.cc

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..6699037bb14
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/logical_traits/requirements/base_classes.cc
@@ -0,0 +1,37 @@
+// { dg-do compile { target c++17 } }
+
+#include <utility>
+
+using std::true_type;
+using std::false_type;
+
+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 Bi, the last type in the list.
+
+static_assert(std::is_base_of_v<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 Bi, the last type in the list.
+
+static_assert(std::is_base_of_v<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>>>);
-- 
2.37.2.382.g795ea8776b


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libstdc++: Add test for std::con/disjunction's base class
  2022-08-26  1:04 [PATCH] libstdc++: Add test for std::con/disjunction's base class Patrick Palka
@ 2022-08-26  8:01 ` Jonathan Wakely
  2022-08-26  8:01   ` Jonathan Wakely
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2022-08-26  8:01 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches, libstdc++

On Fri, 26 Aug 2022, 02:06 Patrick Palka via Libstdc++, <
libstdc++@gcc.gnu.org> wrote:

> Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
>
> libstdc++-v3/ChangeLog:
>
>         * testsuite/20_util/logical_traits/requirements/base_classes.cc:
> New test.
> ---
>  .../requirements/base_classes.cc              | 37 +++++++++++++++++++
>  1 file changed, 37 insertions(+)
>  create mode 100644
> libstdc++-v3/testsuite/20_util/logical_traits/requirements/base_classes.cc
>
> 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..6699037bb14
> --- /dev/null
> +++
> b/libstdc++-v3/testsuite/20_util/logical_traits/requirements/base_classes.cc
> @@ -0,0 +1,37 @@
> +// { dg-do compile { target c++17 } }
> +
> +#include <utility>
>

<type_traits> instead

OK with that change, thanks.


+
> +using std::true_type;
> +using std::false_type;
> +
> +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 Bi, the last type in the list.
> +
> +static_assert(std::is_base_of_v<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 Bi, the last type in the list.
> +
> +static_assert(std::is_base_of_v<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>>>);
> --
> 2.37.2.382.g795ea8776b
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libstdc++: Add test for std::con/disjunction's base class
  2022-08-26  8:01 ` Jonathan Wakely
@ 2022-08-26  8:01   ` Jonathan Wakely
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2022-08-26  8:01 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches, libstdc++

[-- Attachment #1: Type: text/plain, Size: 2804 bytes --]

On Fri, 26 Aug 2022, 02:06 Patrick Palka via Libstdc++, <
libstdc++@gcc.gnu.org> wrote:

> Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
>
> libstdc++-v3/ChangeLog:
>
>         * testsuite/20_util/logical_traits/requirements/base_classes.cc:
> New test.
> ---
>  .../requirements/base_classes.cc              | 37 +++++++++++++++++++
>  1 file changed, 37 insertions(+)
>  create mode 100644
> libstdc++-v3/testsuite/20_util/logical_traits/requirements/base_classes.cc
>
> 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..6699037bb14
> --- /dev/null
> +++
> b/libstdc++-v3/testsuite/20_util/logical_traits/requirements/base_classes.cc
> @@ -0,0 +1,37 @@
> +// { dg-do compile { target c++17 } }
> +
> +#include <utility>
>

<type_traits> instead

OK with that change, thanks.


+
> +using std::true_type;
> +using std::false_type;
> +
> +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 Bi, the last type in the list.
> +
> +static_assert(std::is_base_of_v<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 Bi, the last type in the list.
> +
> +static_assert(std::is_base_of_v<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>>>);
> --
> 2.37.2.382.g795ea8776b
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-26  8:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-26  1:04 [PATCH] libstdc++: Add test for std::con/disjunction's base class Patrick Palka
2022-08-26  8:01 ` Jonathan Wakely
2022-08-26  8:01   ` Jonathan Wakely

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).