|
Boost Users : |
Subject: Re: [Boost-users] [Range & c++0x Lambdas] Can this be done?
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2012-11-28 23:20:13
On Wed, Nov 28, 2012 at 7:35 PM, Nathan Crookston <
nathan.crookston_at_[hidden]> wrote:
[...]
> With or without a change to result_of, I believe there's value in allowing
> the user to explicitly specify the result_type of a callable object passed
> to transformed. Ticket #7748[1] contains a patch which permits that.
>
> Thanks,
> Nate
>
> [1] https://svn.boost.org/trac/boost/ticket/7748
>
I would think a preferable (in the sense of separation of concerns,
modularity, what-have-you) solution would be an addition to
Boost.Functional (or whatever) that basically wraps a callable object and
forces its result_type to be some specified template parameter. E.g.,
template< class F, class R >
struct result_binder
{
F f;
typedef R result_type;
template< class... T >
result_type operator()(T&&... x) const
{ return f(std::forward<T>(x)...); }
};
template< class R, class F >
result_binder<F,R>
bind_result(F&& f)
{ return result_binder<F,R>{std::forward<F>(f)}; }
[or something like that]
- Jeff
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net