
Steven Watanabe wrote:
... and then wrap it in a forward_adapter:
template <typename Func> inline forward_adapter<my_wrapper<Func> > wrap(Func const & in);
Yes that's exactly what I mean.
But now this fails to compile:
wrap(f)(n, 10); //Fails, because 10 is passed as int const &
Since 10 is passed as int const&, T2 should be deduced as const int. This can't be the problem.
Well, you're absolutely right. I totally missed that T would be imbued with const from the argument. On top of that, my test program was still calling the old wrap function (the one that returned wrapper directly, without using forward_adapter), so I jumped to the conclusion that the compiler error was due to non-const reference. BTW, defining result<> seems to be not necessary, but I think it's a good idea to have it. Sorry for the confusion and Thanks! Andy.