c++ – Meaning of C ++ typedef with 3 arguments

Question: Question:

I'm reading the Boost.Proto Users' Guide.

typedef typename Context::template eval<Expr>::result_type type;

I don't understand the meaning of the syntax.
http://www.boost.org/doc/libs/1_57_0/doc/html/proto/users_guide.html#boost_proto.users_guide.back_end.expression_evaluation.proto_eval

I thought the C ++ typedef had two arguments, but is there three possible cases?

If so, what does it mean?
Or, if there are only two typedef arguments, what does the typename Context :: template in the above syntax mean?

I'm ashamed to say that I've briefly reviewed how to use typedefs, but I don't understand the meaning of the above syntax. The URL to the hint and the explanation about the typedef will be helpful, so please do not hesitate to contact us.

Answer: Answer:

At first glance it looks like four, but one of them is a修飾つき識別子and part of the type notation.
I'm giving a type alias with a typedef, but the original type name that already exists Context::template evel<Expr>::result_type
New alias type
So the typedef has two arguments.

Context::template is a nested name specifier.
ISO / IEC 14882: 1998 JIS X 3014: 2003 5.1 –7
Limits the search for subsequent identifiers eval<Expr>::result_type to the Context class name.
typename is required because it is necessary to specify that result_type is a type.

typedef struct mystruct value_type;

Is the same as not saying three arguments to a typedef.

Scroll to Top