[Bug libstdc++/57283] missing typedefs in specialized std::mem_fn for member variables

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed May 15 11:42:00 GMT 2013


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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Lin Yi-Li from comment #2)
> Sorry I missed that 'pm is a pointer to member function...'.
> 
> I know that C++11 has lambda, but using std::mem_fn is sometimes much clear.

You can still use std::mem_fn, the problem is with std::not1, which only works
with the C++98 function object protocol.

> But according to standard, value from std::mem_fn for variable will not be
> able to work with std::not1. Even if the usage is similiar to the one for
> member function takes no argument.

It's similar but not the same, for a member function the result_type is the
return type and the argument_type is dictated by the cv-qualifiers of the
member function, i.e. for a const member function the argument_type is 'const
T*', but for a member variable the result_type depends on whether you call it
with a const or non-const argument.

Should mem_fn(&cls::value) have result_type=int& and argument_type=cls*
or result_type=const int& and argument_type=const cls*?
The result of mem_fn(&cls::value) is polymorphic.

> So is it possible to be an enhancement?

It might be possible to generalize std::unary_negate, but that's for the
standard committee not GCC's bugzilla.



More information about the Gcc-bugs mailing list