diff options
author | Patrick Palka <ppalka@redhat.com> | 2022-08-31 10:04:54 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2022-08-31 10:04:54 -0400 |
commit | caaf9e66c498d9d6dc8be665d820ab45afa406ae (patch) | |
tree | 1501ff0207bbf18287c79320748fe7c782df96ca /libstdc++-v3 | |
parent | e47df5eb56c4e7aca0d3e50826e5aaa1887fa446 (diff) | |
download | gcc-caaf9e66c498d9d6dc8be665d820ab45afa406ae.zip gcc-caaf9e66c498d9d6dc8be665d820ab45afa406ae.tar.gz gcc-caaf9e66c498d9d6dc8be665d820ab45afa406ae.tar.bz2 |
libstdc++: Add test for std::con/disjunction's short circuiting
libstdc++-v3/ChangeLog:
* testsuite/20_util/logical_traits/requirements/short_circuit.cc: New test.
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/testsuite/20_util/logical_traits/requirements/short_circuit.cc | 26 |
1 files changed, 26 insertions, 0 deletions
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 0000000..86996b2 --- /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>); |