0

i found this in this file: http://www.boost.org/doc/libs/1_43_0/boost/spirit/home/phoenix/core/actor.hpp

What does this syntax means?

struct actor ... {
        ...
        template <typename T0, typename T1>
        typename result<actor(T0&,T1&)>::type // this line

I know what typename and templates are, my question is about actor(T0&,T1&) syntax

thank you

Anycorn
  • 50,217
  • 42
  • 167
  • 261

2 Answers2

3

The full declaration from that file reads:

template <typename T0, typename T1>
typename result<actor(T0&,T1&)>::type
operator()(T0& _0, T1& _1) const
{
    /* snip */
}

If you break it down into chunks, it's easier to read:

template <typename T0, typename T1>

It's a template...

operator()(...) const

...a templated function-call operator function...

operator()(T0& _0, T1& _1) const

...which takes two arguments, by reference, of type T0 and T1...

typename result<...>::type

...and returns a result whose type is the type member of result...

typename result<actor(T0&,T1&)>::type

...where the type of result is paramaterised by the expression actor(T0&,T1&).

Blair Holloway
  • 15,969
  • 2
  • 29
  • 28
2

So this means that there is a template called result and within result is a type called type.

template <class T>
class result
{
public:
    typedef ... type;
};

So that line is using that type from the template.

Because the compiler does not know what result<actor(T0&,T1&)>::type is, you need to use typename to tell the compiler to treat it as a type.

Update

actor(T0&,T1&) is a function taking a T0& and a T1& and returning an actor by value.

R Samuel Klatchko
  • 74,869
  • 16
  • 134
  • 187