Implement P1814R0, CTAD for alias templates

Programming / Compilers / GCC - jason [138bc75d-0d04-0410-961f-82ee72b054a4] - 27 November 2019 22:05 EST

This patch implements C++20 class template argument deduction for alias templates, which works by a moderately arcane transformation of the deduction guides for the underlying class template. When implementing it, it seemed that I could simplify the rules in the draft a bit and get essentially the same effect; I'll be emailing the committee to that effect soon.

gcc/cp/
- pt.c (rewrite_tparm_list): Factor out of build_deduction_guide. (maybe_aggr_guide): Check for copy-init here. (alias_ctad_tweaks, deduction_guides_for): New. (ctor_deduction_guides_for): Factor out of do_class_deduction. (ctad_template_p): New.
- parser.c (cp_parser_simple_type_specifier): Use it.
- constraint.cc (append_constraint): New. gcc/c-family/
- c-cppbuiltin.c (c_cpp_builtins): Update __cpp_deduction_guides.

7dd9f591c3d Implement P1814R0, CTAD for alias templates.
gcc/c-family/ChangeLog | 4 +
gcc/c-family/c-cppbuiltin.c | 4 +-
gcc/cp/ChangeLog | 11 +
gcc/cp/call.c | 2 +-
gcc/cp/constraint.cc | 19 +
gcc/cp/cp-tree.h | 2 +
gcc/cp/parser.c | 3 +-
gcc/cp/pt.c | 481 ++++++++++++++++-----
gcc/cp/tree.c | 3 +
gcc/testsuite/g++.dg/cpp1z/class-deduction46.C | 2 +-
.../g++.dg/cpp2a/class-deduction-alias1.C | 27 ++
.../g++.dg/cpp2a/class-deduction-alias2.C | 22 +
gcc/testsuite/g++.dg/cpp2a/explicit11.C | 2 +-
gcc/testsuite/g++.dg/cpp2a/feat-cxx2a.C | 4 +-
14 files changed, 473 insertions(+), 113 deletions(-)

Upstream: gcc.gnu.org


  • Share