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

Less redundant 'typename' in type-id-only contexts #5212

Closed
wants to merge 2 commits into from

Conversation

zhihaoy
Copy link
Contributor

@zhihaoy zhihaoy commented Jan 18, 2022

  • default argument of a type-parameter of a template cleared
  • defining-type-id cleared
  • type-id of a static_cast, const_cast, reinterpret_cast, or dynamic_cast cleared
  • trailing-return-type no instance
  • new-type-id probably no instance

I'm not very sure about the static_cast<T::type*> ones.

Closes: #3637

@jwakely
Copy link
Member

jwakely commented Jan 18, 2022

I'm not very sure about the static_cast<T::type*> ones.

And that's exactly why LWG haven't expressed any desire to rush into this.

One of the major implementations hasn't even implemented the feature yet.

@zhihaoy
Copy link
Contributor Author

zhihaoy commented Jan 18, 2022

I'm not very sure about the static_cast<T::type*> ones.

And that's exactly why LWG haven't expressed any desire to rush into this.

One of the major implementations hasn't even implemented the feature yet.

GCC and MSVC accept this. Clang's implementation under review has test cases for this case https://reviews.llvm.org/D53847:

dynamic_cast<T::tclass *>(new B)
const_cast<const T::type *>(Ptr)

I think I understand what does "smallest enclosing" mean here now; http://wg21.link/p1787 said this instead:

A qualified or unqualified name is said to be in a type-only context if it is the terminal name of [...]
a type-specifier of a [...] type-id of a static_­cast, const_­cast, reinterpret_­cast, or dynamic_­cast
[temp.res.general]/4.2

@@ -6548,13 +6548,13 @@
\begin{codeblock}
template<class InputIterator>
using @\placeholder{iter-value-type}@ =
typename iterator_traits<InputIterator>::value_type; // \expos
iterator_traits<InputIterator>::value_type; // \expos
template<class InputIterator>
using @\placeholder{iter-key-type}@ = remove_const_t<
typename iterator_traits<InputIterator>::value_type::first_type>; // \expos
Copy link
Contributor Author

Choose a reason for hiding this comment

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

http://wg21.link/p2165r3 will get rid of the other typenames in this code block.

@wg21bot wg21bot added the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Feb 21, 2022
@AlisdairM
Copy link
Contributor

See also https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2150r0.html
My intent is to revisit this paper as an editorial NB comment against C++23, where LWG review each option to omit typename in different contexts, before setting the editorial policy. I expect this will be too disruptive for C++23 at this point, but hope to get the policy review to apply to the C++26 Draft immediately it is created, before any new work starts.

@tkoeppe
Copy link
Contributor

tkoeppe commented Sep 16, 2022

Could you please split this up into smaller commits or PRs? Please reopen if and when you want to resume this.

@tkoeppe tkoeppe closed this Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs rebase The pull request needs a git rebase to resolve merge conflicts.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Eliminate redundant use of typename throughout library P2150
5 participants