M::message
is a dependent name since M
is an argument to the template. The compiler cannot know that the dependent name is the template itself, so you need to explicitly specify this:
M::template message<int>();
Otherwise, the compiler analyzes the code as if the value of M::message
was a value that gives the following angle brackets of a different value (i.e., they are parsed as smaller, larger and larger than operators, and not as delimiters of template lists) . The compiler cannot recover from such improper parsing.
source share