public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-2313] libstdc++: Add test for std::con/disjunction's short circuiting
@ 2022-08-31 14:05 Patrick Palka
  0 siblings, 0 replies; only message in thread
From: Patrick Palka @ 2022-08-31 14:05 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

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

commit r13-2313-gcaaf9e66c498d9d6dc8be665d820ab45afa406ae
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Aug 31 10:04:54 2022 -0400

    libstdc++: Add test for std::con/disjunction's short circuiting
    
    libstdc++-v3/ChangeLog:
    
            * testsuite/20_util/logical_traits/requirements/short_circuit.cc: New test.

Diff:
---
 .../logical_traits/requirements/short_circuit.cc   | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/libstdc++-v3/testsuite/20_util/logical_traits/requirements/short_circuit.cc b/libstdc++-v3/testsuite/20_util/logical_traits/requirements/short_circuit.cc
new file mode 100644
index 00000000000..86996b27fa5
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/logical_traits/requirements/short_circuit.cc
@@ -0,0 +1,26 @@
+// { dg-do compile { target c++17 } }
+
+#include <type_traits>
+
+template<class T> struct A { using type = typename T::type; };
+using invalid = A<void>;
+
+// [meta.logical]/3: For a specialization conjunction<B_1, ..., B_n>, if
+// there is a template type argument B_i for which bool(B_i::value) is false,
+// then instantiating conjunction<B_1, ..., B_n>::value does not require the
+// instantiation of B_j::value for j > i.
+
+static_assert(!std::conjunction_v<std::false_type, invalid>);
+static_assert(!std::conjunction_v<std::false_type, invalid, invalid>);
+static_assert(!std::conjunction_v<std::true_type, std::false_type, invalid>);
+static_assert(!std::conjunction_v<std::true_type, std::false_type, invalid, invalid>);
+
+// [meta.logical]/8: For a specialization disjunction<B_1, ..., B_n>, if
+// there is a template type argument B_i for which bool(B_i::value) is true,
+// then instantiating disjunction<B_1, ..., B_n>::value does not require the
+// instantiation of B_j::value for j > i.
+
+static_assert(std::disjunction_v<std::true_type, invalid>);
+static_assert(std::disjunction_v<std::true_type, invalid, invalid>);
+static_assert(std::disjunction_v<std::false_type, std::true_type, invalid>);
+static_assert(std::disjunction_v<std::false_type, std::true_type, invalid, invalid>);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-31 14:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-31 14:05 [gcc r13-2313] libstdc++: Add test for std::con/disjunction's short circuiting Patrick Palka

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