[cfe-dev] [concepts] Should requires-expressions contain a decl?
Hubert Tong via cfe-dev
cfe-dev at lists.llvm.org
Tue Jul 10 06:39:41 PDT 2018
On Mon, Jul 9, 2018 at 2:21 AM, Saar Raz via cfe-dev <cfe-dev at lists.llvm.org
> wrote:
> Hey,
> I'm working on our concepts implementation and am pretty close to
> finishing the implementation. All that's left is requires-expressions which
> I have the code mostly written for, and am testing it now.
> I came across a dilemma with requires-expressions and would like to know
> what you guys think should happen.
> We have requires expressions which declare local parameters - parameters
> that need to be visible in the body of the requires-expression. The current
> machinery would require such decls to reside in a declcontext which itself
> should be a decl as it stands today.
>
Agreed that we need Decls for the parameters, and the requires-expression
is a reasonable place for the DeclContext. I am not sure if making the
expression itself also a Decl helps or harms, but trying it probably does
not hurt.
> Should requires-expr therefore be an expression linked to a generated
> decl? The closest existing thing to this would be a lambda expression, but
> lambda expressions cannot appear in unevaluated contexts while
> requires-expressions clearly can.
>
We *do* allow lambda expressions in unevaluated operands now (see P0315);
however, the rules are set up so that we can avoid mangling their content
or comparing them within a translation unit.
For the purposes of *requires-expression*s, we will need to both be able to
mangle their content and compare them within a translation unit (for
redeclaration matching).
The comparison will need to adjust for the difference between the Decls in
one instance and the Decls in another. The Standard should probably be
adjusted so that the names of the local parameters are ignored for the
purpose of determining whether expressions involving template parameters
are equivalent.
> Also, requires expressions as I have them now can contain another kind of
> declaration - when using a constrained-parameter requirement (e.g. requires
> {{ 0 } -> Same<int>;} ), a template parameter list with one parameter is
> generated.
>
I believe for the similar case of "auto" variables, we produce the template
parameter list on the stack.
>
> My initial thought seems to indicate a "RequiresExprBodyDecl : Decl,
> DeclContext" is requires here, but I may be missing some implications of
> this right now - are there any inherent problems with having this sort of
> declaration generated here?
>
> Thanks :)
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180710/e9be9987/attachment.html>
More information about the cfe-dev
mailing list