-
Notifications
You must be signed in to change notification settings - Fork 749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[temp.param] p8 The value category of the non-type non-class non-reference parameter #4921
Comments
[expr.prim.id.unqual] says
So, is it a variable? [basic.pre] p6 says a "variable is introduced by the declaration of [...] an object." I think a scalar template parameter should not be an object (it does not occupy storage, has no storage duration, and doesn't really have lifetime), and I agree we could be clearer in [intro.object], with particular attention to "template parameter object" (which is, in fact, an object). |
The definition for declaration of an object is never clear in the current draft, that is, the concept of a variable that has a dependency on that definition is not clear here. My argument is, the grammars of a non-type template parameter and of function's parameter are both parameter-declaration, however, the latter does introduce the variables. How do we interpret that difference? Moreover, for "does not occupy storage, has no storage duration, and doesn't really have lifetime" these concepts are not clear for non-type template parameters since these concepts are cross-referenced with each other. For template parameter object, [expr.prim.id.unqual] has explicitly says it is an lvalue. |
As long as we never ask about lifetime and storage duration for a scalar template parameter, we don't have to say anything about it. (There is a lingering issue with the relationship of variable and object in general: a local variable has several objects attached to it when the function is called recursively.) I don't think it's the grammar that needs to make the difference here; it's enough to say that a scalar template parameter is not an object. The it can't be a variable and thus cannot be an lvalue, which is what we want. |
Right, that would be sufficient to fix this issue. |
Proposal:
|
That would imply that a non-type scalar template parameter declares an object. In my view, it doesn't. |
Ah, correct. The proposal is wrong. |
The note that follows [temp.param] p8 says the category of such parameter is prvalue, however it is not a normative rule, and the note indicates that [expr.prim.id.unqual] has a concret interpretation. [expr.prim.id.unqual] says a variable is a lvalue. Since the grammar of a non-type template-parameter is parameter-declaration, which is the same with a function's parameter(a function's parameters are variables), hence the value category of such a template-parameter is a lvalue?
The text was updated successfully, but these errors were encountered: