struct Messages
{
      template <typename V>
      static const char* message() {return "test mesage";}
};
template <int Min, class M=Messages>
struct Test: public M
{
    Test() 
    {
        M::message<int>(); //error: expected primary-expression before 'int'
    }
};
int main()
{
     Test<5, Messages> t;
}
I suspect this has to do with some mutual dependency, like the code of Test depends on the base class M whose method is specialized inside Test. Is this correct?
M::message is a dependent name since M is a template argument. The compiler cannot know that a dependent name is itself a template, therefore you need to specify this explicitly:
M::template message<int>();
Otherwise the compiler parses the code as though M::message were a value, which gives following angle brackets a different meaning (i.e. they are parsed as smaller-than and greater-than operators and not as template list delimiters). The compiler cannot recover from such a wrong parse.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With