This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] fix libstdc++/55463 calling mem_fn with rvalues


On 26 November 2012 23:51, Jonathan Wakely wrote:
>         PR libstdc++/55463
>         * include/std/functional (_Mem_fn): Handle rvalue objects. Add
>         noexcept-specifications.
>         * testsuite/20_util/function_objects/mem_fn/55463.cc: New.
>         * testsuite/20_util/bind/ref_neg.cc: Adjust dg-error line numbers.
>
> Tested x86_64-linux, committed to trunk.

That patch had some problems, fixed by this patch.  This also makes
the _Mem_fn call wrapper use perfect forwarding, avoiding an extra
copy when calling a member function that takes its arguments by value.

        * include/std/functional (_Mem_fn): Constrain function call operators
        to avoid ambiguities. Use perfect forwarding.
        * testsuite/20_util/function_objects/mem_fn/55463.cc: Additional
        tests.
        * testsuite/20_util/function_objects/mem_fn/forward.cc: New.
        * testsuite/20_util/bind/ref_neg.cc: Adjust dg-error line numbers.

Tested x86_64-linux, committed to trunk.


P.S. I have a major refactoring of mem_fn ready for when G++ supports
ref-qualifiers on member functions (tested with clang++) which avoids
having to repeat the current implementation three times for
&-qualified and &&-qualified member functions.  I might commit that
soon anyway because it already makes the existing code shorter, and
makes it trivial to add ref-qualifier support.

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]