[PATCH] D110641: Implement P0857R0 -Part B: requires clause for template-template params

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 28 12:47:07 PDT 2021


erichkeane added a comment.

Ok, Aaron and I are pretty confused here I think (based on offline discussions), so I'm hoping for some guidance.

`ParseTemplateTemplateParameter` does all the work to parse a template-template parameter, then calls `ActOnTemplateTemplateParameter`, which handles adding the top-level name to the scope (as well as warning if the params list is 0).

Additionally, we noticed that:

`template<template<typename T> class C = std::enable_if_t<T::value>> struct s{};`

Is illegal in all compilers, `T` is not available in the `enable_if_t` call.  This makes a lot of sense to me, since the `T` is essentially worthless: It can never be matched, it never gets a concrete type, etc.

However, the test failure above does the equivilant of:

`template<template<typename T> requires T::value class C> struct s{};`

I note that MSVC and GCC accept this (no idea about EDG).  However, this seems worthless/useless for the same reason.  I guess it somewhat makes sense that the requires clause associated with the template-template-parameter-parameter-list should have access to names from the list, but they are still seemingly worthless to me.

My expectation is that I could implement this by introducing a new `Scope` that contains all the names of the template-template-parameter-list and goes out of scope as soon as we're done with the `requires` clause.  It seems strange to do so (and ends up having an `ActOnTemplateTemplateParameterParameterList` for this purpose, plus some level of 'pop-scope'), but seems consistent with the other compilers?

I guess what I'm saying is in addition to the other questions raised above regarding whether these requires clauses are useful AT ALL, is that we likely require guidance to finish implementing this paper


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110641/new/

https://reviews.llvm.org/D110641



More information about the cfe-commits mailing list