Skip to content

Conversation

@frederick-vs-ja
Copy link
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 frederick-vs-ja requested a review from a team as a code owner July 30, 2022 18:18
@StephanTLavavej StephanTLavavej added the cxx23 C++23 feature label Jul 30, 2022
@strega-nil-ms strega-nil-ms self-assigned this Aug 2, 2022
Copy link
Contributor

@CaseyCarter CaseyCarter left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@strega-nil-ms strega-nil-ms left a 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);
    }
}

@strega-nil-ms strega-nil-ms removed their assignment Aug 3, 2022
@StephanTLavavej
Copy link
Member

@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).

@StephanTLavavej StephanTLavavej self-assigned this Aug 5, 2022
@StephanTLavavej
Copy link
Member

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

@StephanTLavavej StephanTLavavej merged commit 577269c into microsoft:main Aug 5, 2022
@StephanTLavavej
Copy link
Member

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

@frederick-vs-ja frederick-vs-ja deleted the p2445r1 branch August 5, 2022 23:58
strega-nil pushed a commit to strega-nil/stl that referenced this pull request Aug 6, 2022
fsb4000 pushed a commit to fsb4000/STL that referenced this pull request Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cxx23 C++23 feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

P2445R1 forward_like()

4 participants