|
Boost : |
Subject: Re: [boost] [range] treating N-ary function with N-1 default args as unary
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2012-07-03 10:28:58
Mathias Gaunard wrote:
> 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()(
^^^^
That clearly is a typo and I'm not certain what you actually meant.
> 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.
Wouldn't there need to be a different macro for each number of actual arguments? That is, one for unary, one for binary, etc. or did you mean something else?
_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer using std::disclaimer;
Dev Tools & Components
Susquehanna International Group, LLP http://www.sig.com
________________________________
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk