On Fri, Apr 13, 2012 at 9:15 AM, Jeffrey Lee Hellrung, Jr. <jeffrey.hellrung@gmail.com> wrote:
On Fri, Apr 13, 2012 at 7:35 AM, John M. Dlugosz <mpbecey7gu@snkmail.com> wrote:
The plot thickens:

       class Universe : std::tr1::enable_shared_from_this<Universe> {
          const int answer;
       public:
          Universe (int a) : answer(a) {}
          std::string get_answer() const;
          void get_nothing() {}
          virtual void blahblah(); // !!!
          };




       Universe u1(42);
       foo (&Universe::get_answer, &u1);


Regarding my previous post on the definitions of foo,
if the class inherits from enable_shared_from this *and* contains a virtual function, then this call to foo doesn't work, giving funny template errors in boost::result_of.

It's really not so funny :)

&Universe::get_answer is not an object supporting function-call syntax, so using boost::result_of to query the result of function application is, strictly speaking, meaningless. Boost.Bind happens to have special support for pointers-to-member-functions, but not all Boost libraries do, since it's a relatively simple matter to wrap the pointer in boost::mem_fun (note: I've actually forgotten the precise name).

Regarding your initial message, on how to generically get the result type of a function object *or* a pointer-to-member-function, you'd need to create your own metafunction which dispatches to boost::result_of or Boost.FunctionTypes metafunctions depending on whether the argument is a pointer-to-member or not.

You could argue that the language should allow function-call syntax on pointers-to-member-functions (and pointers-to-member-objects) as it is allowed for ponters-to-functions, and...I might sympathize with you.

[snip errors]

HTH,

- Jeff


Okay, disregard most of this, I checked the Boost.ResultOf implementation in 1.49.0, it does support pointers-to-members. Sorry, my bad!

- Jeff