http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55463



             Bug #: 55463

           Summary: Result of std::mem_fn doesn't accept rvalues

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: libstdc++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: lucdan...@free.fr





Created attachment 28769

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28769

Reproducible testcase



$ g++-snapshot --version

g++-snapshot (Debian 20120915-1) 4.8.0 20120915 (experimental) [trunk revision

191353



The following program doesn't compile:



#include <functional>

#include <memory>



// or can be std::unique_ptr as well

template<typename T> using Ptr = std::unique_ptr<T>;



struct foo { void bar() {} };



int main()

{

    Ptr<foo> p { new foo };

    // This is fine

    std::mem_fn(&foo::bar)(p);

    // This isn't

    std::mem_fn(&foo::bar)(std::move(p));

}



As far as I can tell, that's because _Mem_fn<_Res (_Class::*)(_ArgTypes...)>

has an operator() that only accepts _Tp& for smart pointers.

Reply via email to