
Hi, I wonder what is the correct way of declaring polymorphic function object result types and how to use result_of template with regard to argument types. If a function object receives arguments by reference, should its member result<> template be specialized for reference types as well? Also, should result_of<> for this function be instantiated with reference argument types? struct my_foo { template< typename > struct result; // Is this correct? template< typename ArgT > struct result< my_foo(ArgT) > { typedef ArgT type; }; // Or is this correct? template< typename ArgT > struct result< my_foo(ArgT const&) > { typedef ArgT type; }; template< typename ArgT > ArgT operator() (ArgT const& arg) const { return arg; } }; I realize that I can provide both result<> specializations and it will work either way. But when there are more than one argument the specializations begin to pile quickly. Consider also rvalue references and const and non-const qualified my_foo. Another question I have is how to use result_of<> when my_foo is external (i.e. provided by a third party library)? // Which one is the right way? typedef result_of< my_foo(int) >::type result_type1; typedef result_of< my_foo(int const&) >::type result_type2; I cannot know what result<> specializations are provided by my_foo, so probably there isn't an ultimate answer. But perhaps there are some guidelines or best practices? I've looked at result_of docs but there are no recommendations on this.