-
Notifications
You must be signed in to change notification settings - Fork 7
[temp.param] Is a non-type template parameter that declares a reference a variable? #148
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
Comments
A template parameter object does have storage and lifetime, but it is seemly not considered as a variable. Template parameter objects and constexpr variables of object types have some common properties: both of them are usable in constant expressions, and shall have constant destruction. Currently these properties are repeatedly specified. I guess we should say that all NTTPs are not variables, or more precisely, declaration of a non-type template-parameter does not introduce an object or a reference (related to #82). And then we may specify that they (as _id-expression_s) are prvalues with some values or lvalues denoting some objects or functions (for scalar or non-scalar NTTPs respectively). (So that the original problem might be resolved in the way that a NTTP of a reference type is not itself a reference, it's just a glvalue constant expression denoting an object or a function.) |
From a more general way, I think most issues I recently submit here regarding the parameter-declarations that appear as template parameters are actually the core issue: which declaration declares variable. I agree with the opinion that all NTTP should not be a variable.
This is a bit contradictory to the definition of the variable. [basic.pre] p6 says
[temp.param] p8 says
we say the template parameter object denotes an object with static storage duration, and we say the id-expression(its name) denotes that object, which is exactly what the definition of variable tries to say. |
Another thing that should be noticed is, the parameter-declaration that appears in template-parameter is still a declaration. [basic.def] p1 says
Either the declaration only introduces a name(like a typedef declaration) or it introduces a name and entity. What does a parameter-declaration as a template parameter do? Does it introduce the name and entity? In the current, we say
If the parameter-declaration(as a template parameter) declares an entity, which one does it declare if we admit that the parameter-declaration is not a variable? This should be clarified. |
Full name of submitter (unless configured in github; will be published with the issue): Jim X
A parameter-declaration that appears in a function declaration declares a variable. How about it appears as a template parameter? The issue arises from https://stackoverflow.com/questions/62567395/is-it-a-defect-about-a-non-type-template-parameter-of-a-reference-type-that-ther?noredirect=1#comment130536482_62567395.
The opinion in the comment on the question is that: Since a template parameter does not have storage and lifetime, it cannot be considered a variable. However, this point is not clear in the current standard.
The text was updated successfully, but these errors were encountered: