[PATCH] libstdc++: Fix std::get<T> for std::pair with reference members [PR121745]

Ville Voutilainen ville.voutilainen@gmail.com
Wed Sep 3 09:21:05 GMT 2025


On Wed, 3 Sept 2025 at 12:12, Jonathan Wakely <jwakely@redhat.com> wrote:
> > I want to also see following test being added, that explains why we want to use:
> > std::forward<_Tp>(__p.second);
> > Instead of, seemingly more obvious:
> > std::move(__p).second -> this will produce int& instead of int&&
>
> Good idea. I think I should probably just extend the testcase to cover
> every combination of lvalue/rvalue members, lvalue/rvalue pairs, and
> const/non-const pairs.

If you could, also take a look at similar coverage for assignment
operators and constructors. There was that recent
misguided suggestion to replace forwards with moves; our
implementation uses forward in assignments and constructors,
but surely doesn't hurt to try to make sure the tests for those cover
reference elements.


More information about the Libstdc++ mailing list