Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7636611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:43:34+00:00 2026-05-31T07:43:34+00:00

struct Messages { template <typename V> static const char* message() {return test mesage;} };

  • 0
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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:43:36+00:00Added an answer on May 31, 2026 at 7:43 am

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

struct Div { int i; int j; }; class A { public: A(); Div&
template <typename vec1, typename vec2> class fakevector { public: /* Do something */ };
I have a class template <typename T> struct Trait { typedef std::false_type IsGood; };
The following small example shows my problem: template<class T> struct X { static void
struct { char a; int b; } x; Why would one define a struct
struct Drink { public string Name { get; private set; } public int Popularity
struct ID3v2_header{ char tag[3]; char ver[2]; char flag; int size; }; ID3v2_header readID3v2_head(string file){
I have a metafunction: struct METAFUNCION { template<class T> struct apply { typedef T
Having the following code: template<typename T, typename OutStream = std::ostream> struct print { OutStream
I have the following code: template<typename T, typename Allocator = std::allocator<T> > class Carray

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.