Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2008-03-11 10:43:39


Markus Werle wrote:
> Hi!
>
> In the section "Expression Nodes as Fusion Sequences"
> you show the follwing code
>
> struct fun_t {};
> terminal<fun_t>::type const fun = {{}};
>
> // ...
> fusion::for_each(
> fusion::transform(
> // pop_front() removes the "fun" child
> fusion::pop_front(fun(1,2,3,4))
> // Extract the ints from the terminal nodes
> , functional::arg<>()
> )
> , display()
> );
>
>
> It did not became clear to me why a terminal<fun_t>::type
> can be initialized with 4 integer arguments.

"fun" is an object. It is already initialized.

> I thought terminal<fun_t>::type is equivalent to
> expr< tag::terminal, args0< fun_t >, 0 >
> and should take no args at all.
> Could you clarify this?

"fun(1,2,3,4)" is an invocation of an overloaded function call operator.
Proto is an expression template library ... all operators are overloaded
to build expression trees. This operator builds a tree node representing
a function invocation.

HTH,

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

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