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
P0732R2 Class types in non-type template parameters #2171
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed up some minor issues with the application of the motion. There's a few more things I'd like us to take a look at before we merge this.
source/templates.tex
Outdated
the type of the parameter is the type deduced | ||
for the variable \tcode{x} in the invented declaration: | ||
\begin{codeblock} | ||
T x = @\grammarterm{template-argument}@ ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe try removing the italic corection after template-argument? There's more whitespace there than I'd prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\itcorr[-1]
does help:
That's:
T x = @\grammarterm{template-argument}@ ;
T x = @\grammarterm{template-argument}\itcorr[-1]@ ;
T x = @\grammarterm{template-argument}\kern-0.3em@ ;
I'm going with the \itcorr
approach for consistency with what we do elsewhere. I think it also makes the left/right whitespace look more balanced than the 0.3em negative kerning hint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zygoloid Does the \itcorr[-1]
give you the same result as using \grammartermnc
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source/templates.tex
Outdated
contains a placeholder type\iref{dcl.spec.auto} | ||
or a placeholder for a deduced class type\iref{dcl.type.class.deduct}, | ||
the type of the parameter is the type deduced | ||
for the variable \tcode{x} in the invented declaration: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider removing the colon here.
source/templates.tex
Outdated
@@ -1328,6 +1337,10 @@ | |||
|
|||
const char p[] = "Vivisectionist"; | |||
X<int,p> x2; // OK | |||
|
|||
class A { constexpr A(const char*) {} }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example is wrong. Add a defaulted operator<=>
here to fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example is even more wrong: The type of the second template-parameter of X is still "const char *" and does not involve "A" at all.
source/templates.tex
Outdated
|
||
X<A, "Pyrophoricity"> x3; // OK, string literal is a constructor argument to A | ||
Y<"Pyrophoricity"> x3; // OK, string literal is a constructor argument to A |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the rationale for the change from X
to Y
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, I see it now. Looks like a change in P0732R2 was missing markup: I think we were supposed to change the rest of the example to:
template<class T, T p> class X {
/* ... */
};
X<const char*, "Studebaker"> x1; // error: string literal as template-argument
const char p[] = "Vivisectionist";
X<const char*,p> x2; // OK
The edits for decltype attributed to [dcl.type.class.deduct] were instead applied to [dcl.type.simple]. In [temp.param], the pointer-to-member case was struck, because it is subsumed by the more general bullet covering literal types. The first change attributed to [temp.type] was applied to [temp.arg.nontype] instead.
P0732R2 contained some changes to this section that were missing explicit markup; apply those changes too. Also fix missing definition of operator<=> in class type used as type of non-type template parameter.
3168163
to
e4f579e
Compare
Fixes #2118.