Bug 24800 - tr1::mem_fn returns a function object that does not inherit from std::unary_function/binary_function
Summary: tr1::mem_fn returns a function object that does not inherit from std::unary_f...
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.0.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-11 16:21 UTC by John Maddock
Modified: 2005-11-13 04:25 UTC (History)
3 users (show)

See Also:
Host: linux.x86
Target: linux.x86
Build: linux.x86
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Test case (caution complicated) (2.31 KB, application/octet-stream)
2005-11-11 18:42 UTC, John Maddock
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Maddock 2005-11-11 16:21:48 UTC
The title say it all really, the function object returned from mem_fn is an unspecified type that:

"3.5:

2 The simple call wrapper shall be derived from std::unary_function<cv T*, Ret > when pm is a pointer to
member function with cv-qualifier cv and taking no arguments, where Ret is pm’s return type.
3 The simple call wrapper shall be derived from std::binary_function<cv T*, T1, Ret > when pm is a
pointer to member function with cv-qualifier cv and taking one argument of type T1, where Ret is pm’s return
type."

However my tests indicate that this inheritance is not taking place, and in any case the nested members result_type and argument_type are not present in the function object returned.

Regards, John Maddock.
Comment 1 Paolo Carlini 2005-11-11 16:44:02 UTC
Can you please attach a simple testcase? Thanks.
Comment 2 John Maddock 2005-11-11 18:42:27 UTC
Created attachment 10218 [details]
Test case (caution complicated)

The attached test cases are rather complex - sorry but it's easier to give you all the bad news at once :-)

They also depend on Boost, and you'll need to change the include from <functional> to <tr1/functional> to mesh with gcc's current (non-conforming?) include style.

As for the original bug report: it's easy to verify by inspecting the source that _Mem_fn has no base class as required.

Hope this gives you what you need.

John Maddock
Comment 3 Paolo Carlini 2005-11-12 11:27:26 UTC
(In reply to comment #2)
> As for the original bug report: it's easy to verify by inspecting the source
> that _Mem_fn has no base class as required.

I beg to disagree. Have you really checked the actual versions of it for
member function taking no argument and taking one argument? If I do that
in the straightforward way, that is looking at the -E output, the expected
bases are there. In other terms, functional_iterate.h looks fine to me.

> Hope this gives you what you need.

Well, to date, not really, to be honest. I would appreciate a decently
sized testcase (eventually, what are we going to put in the testsuite,
otherwise?!?) or at least reaching a minimum of consensus about the matter
by looking at the sources...

Thanks in advance for your help.
Comment 4 Doug Gregor 2005-11-12 11:33:16 UTC
This is not a bug. TR1 3.5 refers to member function pointers, not member data pointers as in the submitted test case. mem_fn has no result_type for member data pointers because the constness of the result type depends on the constness of the argument type; use result_of to get the appropriate result type given the argument type. See also TR1 DR 10.24 "Mem_fn result_type for pointer to data member".
Comment 5 John Maddock 2005-11-12 17:53:29 UTC
Thanks for the clarification Doug: having re-read the text, the issues list, and scratched my head for a while I agree with you.  I'll update the Boost test case appropriately.

Feel free to close this one down as invalid (it appears I don't have permission to do that).

Regards, John.
Comment 6 Paolo Carlini 2005-11-13 04:25:17 UTC
Agreed.