-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Implement P2445R1 forward_like()
#2974
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.
LGTM!
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 don't really have a "problem" with how it's written right now, but I would prefer it if this was written closer to the wording of the paper; something like:
using _UnrefT = remove_reference_t<_Ty>;
using _UnrefU = remove_reference_t<_Uty>;
if constexpr (is_const_v<_UnrefT>) {
// _Copy_const = const _UnrefU
if constexpr (is_rvalue_reference_v<_Ty&&>) {
return static_cast<const _UnrefU&&>(_Ux);
} else {
return static_cast<const _UnrefU&>(_Ux);
}
} else {
// _Copy_const = _UnrefU
if constexpr (is_rvalue_reference_v<_Ty&&>) {
return static_cast<_UnrefU&&>(_Ux);
} else {
return static_cast<_UnrefU&>(_Ux);
}
}
@frederick-vs-ja @CaseyCarter @strega-nil-ms Thanks, this looks good! I added a preprocessor comment and slightly expanded the test coverage (mostly out of principle, not any real concern about library or compiler bugs). |
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Thanks for implementing this feature - I like to see the STL moving forward! 😹 😻 🚀 |
Co-authored-by: Stephan T. Lavavej <[email protected]>
Co-authored-by: Stephan T. Lavavej <[email protected]>
Fixes #2931.
Intentionally don't call
std::move
,std::forward
, orstd::as_const
. Also move_Can_reference
to<utility>
for error message.