aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2023-02-09 12:51:51 -0800
committerJason Merrill <jason@redhat.com>2023-03-09 10:25:45 -0500
commit148cbb153dafd6b21d83c00787acd430aec68a3d (patch)
tree0844e8d60e6ef3de63399d0227dbb191279a28d0 /gcc/doc
parentd11e088210a551235d3937f867ee1c8b19d02290 (diff)
downloadgcc-148cbb153dafd6b21d83c00787acd430aec68a3d.zip
gcc-148cbb153dafd6b21d83c00787acd430aec68a3d.tar.gz
gcc-148cbb153dafd6b21d83c00787acd430aec68a3d.tar.bz2
c++: add __is_deducible trait [PR105841]
C++20 class template argument deduction for an alias template involves adding a constraint that the template arguments for the alias template can be deduced from the return type of the deduction guide for the underlying class template. In the standard, this is modeled as defining a class template with a partial specialization, but it's much more efficient to implement with a trait that directly tries to perform the deduction. The first argument to the trait is a template rather than a type, so various places needed to be adjusted to accommodate that. PR c++/105841 gcc/ChangeLog: * doc/extend.texi (Type Traits):: Document __is_deducible. gcc/cp/ChangeLog: * cp-trait.def (IS_DEDUCIBLE): New. * cxx-pretty-print.cc (pp_cxx_trait): Handle non-type. * parser.cc (cp_parser_trait): Likewise. * tree.cc (cp_tree_equal): Likewise. * pt.cc (tsubst_copy_and_build): Likewise. (type_targs_deducible_from): New. (alias_ctad_tweaks): Use it. * semantics.cc (trait_expr_value): Handle CPTK_IS_DEDUCIBLE. (finish_trait_expr): Likewise. * constraint.cc (diagnose_trait_expr): Likewise. * cp-tree.h (type_targs_deducible_from): Declare. gcc/testsuite/ChangeLog: * g++.dg/ext/is_deducible1.C: New test.
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/extend.texi4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index c112291..b64a857 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -25213,6 +25213,10 @@ type. A diagnostic is produced if this requirement is not met.
If @code{type} is a cv-qualified class type, and not a union type
([basic.compound]) the trait is @code{true}, else it is @code{false}.
+@item __is_deducible (template, type)
+If template arguments for @code{template} can be deduced from
+@code{type} or obtained from default template arguments.
+
@item __is_empty (type)
If @code{__is_class (type)} is @code{false} then the trait is @code{false}.
Otherwise @code{type} is considered empty if and only if: @code{type}