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
Add a compatibility type for C++20's std::type_identity. #14915
Conversation
35a391e
to
151ed08
Compare
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.
I think we should again use a feature test macro in the C++20
check we run while configuring via CMake
.
@masterleinad Maybe like the last commit here? I think a good question is what we will do when we actually require C++20. Will we continue to check for the existence of features with these feature test macros? What if they are not satisfied? This is a question separate from the current patch, but one I'd be curious to hear how you think about for the long run. |
We discussed some time ago (#10340), that it's not a good idea, in general, to use the feature macros directly in our source code but rather while configuring using
We still have checks for |
Ah, thanks for the reminder. How about this commit? As for the general question: I see these checks as things that are hard to get rid of. If we still have checks for specific C++14 features, then that's likely not because we need them, but because nobody has removed them. But that is not a discussion we need to have here. |
7e74dd1
to
b51ef3f
Compare
I would agree that it's easy to forget to remove them but it's still a backard-comaptible change if we do. 🙂 |
using type = T; | ||
}; | ||
|
||
using identity = std_cxx20::type_identity<T>; |
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.
We should deprecate this properly when we change all uses in the library.
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.
Will do in the follow-up!
OK this way? |
We have long had a
identity
type. In C++20, there is finallystd::type_identity
we can built on instead. Import that intonamespace std_cxx20
and use it to defineidentity
.In a follow-up patch, I will switch all uses of
identity<T>
tostd_cxx20::type_identity<T>
. (Or, rather, tostd_cxx20::type_identity_t<T>
.