This is the mail archive of the gcc-bugs@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]

[Bug libstdc++/55463] New: Result of std::mem_fn doesn't accept rvalues


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: unassigned@gcc.gnu.org
        ReportedBy: lucdanton@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.


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