Skip to content
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

Merged
merged 2 commits into from Jun 19, 2018

Conversation

jensmaurer
Copy link
Member

Fixes #2118.

@jensmaurer jensmaurer added this to the post-2018-06 milestone Jun 12, 2018
Copy link
Member

@zygoloid zygoloid left a 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.

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}@ ;
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a hard one. Fiddling with the italics correction doesn't change anything (same before and after):
before

\kern to the rescue:
kern

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\itcorr[-1] does help:

screenshot from 2018-06-18 17-00-27

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.

Copy link
Contributor

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@godbyk It didn't, but that's because \grammartermnc was broken. Fixed in 1478e7c.

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:
Copy link
Member

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.

@@ -1328,6 +1337,10 @@

const char p[] = "Vivisectionist";
X<int,p> x2; // OK

class A { constexpr A(const char*) {} };
Copy link
Member

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.

Copy link
Member Author

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.


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
Copy link
Member

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?

Copy link
Member

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.
@zygoloid zygoloid merged commit aa8e85e into master Jun 19, 2018
@jensmaurer jensmaurer deleted the motions-2018-06-cwg-6 branch October 19, 2019 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants