This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/55463] New: Result of std::mem_fn doesn't accept rvalues
- From: "lucdanton at free dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 25 Nov 2012 12:22:01 +0000
- Subject: [Bug libstdc++/55463] New: Result of std::mem_fn doesn't accept rvalues
- Auto-submitted: auto-generated
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.