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

1

2 Answers 2

2

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&).

Sign up to request clarification or add additional context in comments.

Comments

1

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.

4 Comments

what does this mean actor(T0&,T1&)?
@aaa - a function taking a T0 and T1 both by reference and returning an actor by value.
thank you. I am actually somewhat familiar with function/function pointer syntax, but I have never seen it as template parameter.
@aaa to clarify, it's not somehow a function call (as it looks quite similar), but it's the type of a function.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.