Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 33,265 of 33,346    |
|    Niklas to All    |
|    Problem with templates    |
|    09 Dec 13 15:17:36    |
   
   From: niklas.wernersson@googlemail.com   
      
   { Reformatted; please limit your lines to 70 chars -mod }   
      
   Hi,   
      
   I have a strange problem with templates in c++. I need to access a   
   singleton with template methods inside another templated class. The   
   problem is isolated in the following piece of code, which doesn’t   
   compile. For example, in gcc 4.7.3 you will get   
      
    ‘test.cpp:15:23: error: expected primary-expression before 'int'’,   
      
   which did not help me to identify the root of the problem. It will   
   compile if I remove any of the two templates, but I want both   
   templates. The code will also compile if I remove the bar() function   
   and replace it with ‘a’ directly. My problem is that I cannot see why   
   the bar() function is a problem here.   
      
   Any ideas? What exactly is the problem in the example below?   
      
   class A {   
   public:   
    template
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca