[PATCH] libstdc++: Fix std::get<T> for std::pair with reference members [PR121745]
Jonathan Wakely
jwakely@redhat.com
Wed Sep 3 09:29:31 GMT 2025
On Wed, 3 Sept 2025 at 10:21, Ville Voutilainen
<ville.voutilainen@gmail.com> wrote:
>
> 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.
We have testsuite/20_util/pair/ref_assign.cc (and also pass all libc++
tests, with the two pending patches I've submitted for std::pair).
More information about the Libstdc++
mailing list