Boost logo

Boost :

Subject: Re: [boost] [range] treating N-ary function with N-1 default args as unary
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2012-06-30 22:42:44

On 01/07/2012 01:18, Vicente J. Botet Escriba wrote:

> Could a lambda help on this context?
> int main()
> {
> int A[5];
> A | boost::adaptors::transformed([](int a){ return foo(a);});
> }

The OP already pointed this one out. It's not satisfying because it
requires specifying the type of the first argument.

Something you could do in C++11

int main()
      struct foo_type
           template<class Sig>
           struct result;

           template<class This, class A0>
           struct result<This(A0)>
                typedef decltype(foo(declval<A0>())) type;

           template<class A0>
           typename result<foo_(A0&&)>::type operator()(A0&& a0) const
                return foo(forward<A0>(a0));
      foo_type foo_;
      int A[5];
      A | boost::adaptors::transformed(foo_);

The functor could be generated by a macro that would just take the
function name and the number of arguments.

Boost list run by bdawes at, gregod at, cpdaniel at, john at