3e2a60a4   
   From: daniel.kruegler@googlemail.com   
      
   Am 13.02.2012 18:46, schrieb asif.lse:   
   > I have something like the following:   
   >   
   > template   
   > struct Outer   
   > {   
   > template class TraitsClass {} //the skeleton   
      
   You are missing a semicolon here after the definition of TraitsClass.   
      
   > template class Nested;   
   > template<> class Nested   
   > {   
   > };   
      
   You cannot define the specialization of Nested in class scope. The last   
   definition has to be moved to namespace scope like so:   
      
   template <>   
   template    
   class Outer::Nested   
   {   
   };   
      
   > };   
   >   
   > typedef Outer::Nested nested_t; //COMPILER IS COMPLAINING HERE - HOW   
   > TO GET THIS RIGHT?   
      
   In such cases I always recommend to quote the compiler complaint, because it   
   usually gives a good hint what's going wrong here.   
      
   > I want to get the typedef right because later I want to derive sub-   
   > classes from the nested class Outer::Nested and I am having a hard-   
   > time getting that syntax right as well. Can you help me?   
      
   No kidding intended, but you either must have had a *very* long night or you   
   need to get some more basic understanding of C++ templates ;-) [I hope you   
   forgive my mild form of sarcasm]   
      
   So let me reply with another question:   
      
   What do you expect what the meaning of Outer is without any template   
   arguments? Outer is a template and you need to provide some template argument   
   for the type "placeholder" (in all but some very rare situations). In   
   addition, Nested within Outer is    
   another template, so what do you expect what the meaning of Outer::Nested is   
   without providing another set of template arguments for the inner template?   
      
   Honestly, I have no idea (in this context), so we both must either agree, that   
   you missed to provide some arguments here, e.g. Outer::Nested, or   
   that you did not explain sufficiently precise what you *actually* want to   
   realize.   
      
   For example you might want to realize something like a "template-typedef". If   
   you have a so-called C++11-capable compiler (E.g. gcc4.7 or clang 3.x), you   
   can use a alias template for this, like   
      
   template   
   using nested_t = typename Outer::template Nested;   
      
   or - if you just have a good C++03 compiler you need to simulate this via a   
   wrapper template, e.g. like so   
      
   template   
   struct nested_t {   
    typedef typename Outer::template Nested type;   
   };   
      
   HTH & Greetings from Bremen,   
      
   Daniel Krügler   
      
      
      
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|