Attached is a patch for constrained class templates. It's the 3rd time I've sent it.
I added some fixes for bugs discovered after the previous send, and added support for matching constrained declarations in out-of-class member function definitions. 2013-08-02 Andrew Sutton <andrew.n.sut...@gmail.com> * gcc/cp/pt.c (get_class_bindings): Pass the partial specialization for constraint evaluation. Evaluate constraints, resulting in deduction failure on error. (get_specializaing_template_decl), (get_specialization_constraints), (maybe_new_partial_specialization): New. (maybe_process_partial_specialization): Allow the creation of new types for constrained partial specializations. (process_partial_specialization): Modify the canonical type of constrained partial specializations. (resolve_template_scope): New. Match the template scope to a specialization with appropriate constraints. (lookup_template_class_1): Compare constraints when entering a template scope. Check constraints on lookup. Do not explicitly check alias constraints. (instantiate_class_template_1): Do not explicitly check constraints during class template instantiation. (tsubst_decl): Instantiate the constraints of template declarations. (more_specialized_class): Pass specializations to get_class_bindings(). Compare specialization constraints if the types are equivalent. (most_specialized_class): Pass specialization to get_class_bndings(). * gcc/cp/decl2.c (check_class_fn): Get the decl's requirements from either the current template reqs or from the template parameters. Allow overloading of constrained out-of-class member definitions. * gcc/cp/parser.c (cp_parser_parse_type_parameter): Attach requirements to the current template parameter list. (cp_parser_init_declarator): Parse requires clauses for out-of-class member definitions. Be sure to restore current constraints before exiting the function. (cp_parser_member_declarator): Restore the previous requirements in an early-exit branch. (cp_parser_late_parsing_for_member): Restore constraints after maybe_end_member_template_processing(). (cp_parser_template_declaration_after_exp): Attach constraints to the current template parameters. * gcc/cp/constraint.cc (reduce_template_id): Don't crash when omitting ()'s on constraint calls. (check_requirements): Don't evaluate dependent arguments. (check_constraints): Don't try to evaluate when arguments are dependent. (equivalent_constraints): Optimize the case when a and b are the same constraints. -- Andrew Sutton
template.patch
Description: Binary data