Boost logo

Boost :

Subject: Re: [boost] Does boost help in creating generic function wrappers?
From: Andy Venikov (avenikov_at_[hidden])
Date: 2010-07-15 16:52:18


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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk