Skip to content

Implement P2445R1 forward_like() - #2974

Merged
Stephan T. Lavavej (StephanTLavavej) merged 16 commits into
microsoft:mainfrom
frederick-vs-ja:p2445r1
Aug 5, 2022
Merged

Implement P2445R1 forward_like()#2974
Stephan T. Lavavej (StephanTLavavej) merged 16 commits into
microsoft:mainfrom
frederick-vs-ja:p2445r1

Conversation

@frederick-vs-ja

Copy link
Copy Markdown
Contributor

Fixes#2931.

Intentionally don't call std::move, std::forward, or std::as_const. Also move _Can_reference to <utility> for error message.

@frederick-vs-ja
A. Jiang (frederick-vs-ja) requested a review from a team as a code ownerJuly 30, 2022 18:18
Comment threadstl/inc/utility Outdated
Comment threadstl/inc/utility Outdated
Comment threadtests/std/tests/P2445R1_forward_like/test.compile.pass.cpp Outdated
Comment threadtests/std/tests/P2445R1_forward_like/test.compile.pass.cpp Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

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>;
ifconstexpr (is_const_v<_UnrefT>) {
// _Copy_const = const _UnrefUifconstexpr (is_rvalue_reference_v<_Ty&&>) {
returnstatic_cast<const _UnrefU&&>(_Ux);
} else {
returnstatic_cast<const _UnrefU&>(_Ux);
}
} else {
// _Copy_const = _UnrefUifconstexpr (is_rvalue_reference_v<_Ty&&>) {
returnstatic_cast<_UnrefU&&>(_Ux);
} else {
returnstatic_cast<_UnrefU&>(_Ux);
}
}

Comment threadstl/inc/utility
Comment threadstl/inc/utility Outdated
Comment threadtests/std/tests/P2445R1_forward_like/test.compile.pass.cpp Outdated
Comment threadstl/inc/utility Outdated
Comment threadtests/std/tests/P2445R1_forward_like/test.compile.pass.cpp
@StephanTLavavej

Copy link
Copy Markdown
Member

A. Jiang (@frederick-vs-ja)Casey Carter (@CaseyCarter)nicole mazzuca (@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).

@StephanTLavavej

Copy link
Copy Markdown
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej

Copy link
Copy Markdown
Member

Thanks for implementing this feature - I like to see the STL moving forward! 😹 😻 🚀

nicole mazzuca (strega-nil) pushed a commit to strega-nil/stl that referenced this pull request Aug 6, 2022
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Igor Zhukov (fsb4000) pushed a commit to fsb4000/STL that referenced this pull request Aug 13, 2022
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cxx23C++23 feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

P2445R1 forward_like()

4 participants

@frederick-vs-ja@StephanTLavavej@CaseyCarter@strega-nil-ms