2817dc6f   
   From: alf.p.steinbach+usenet@gmail.com   
      
   On 29.02.2012 12:57, Roman W wrote:   
   > ===============================   
   > #include   
   >   
   > template struct wrapped   
   > {   
   > wrapped(const T&) {}   
   > };   
   >   
   > template wrapped wrappit(const T& x)   
   > {   
   > return wrapped(x);   
   > }   
   >   
   > template int run_function(const T& x, bool wrapped)   
   > {   
   > if (wrapped) {   
   > return 0;   
   > } else {   
   > return run_function(wrappit(x), true) + 1;   
   > }   
   > }   
   >   
   > int main()   
   > {   
   > std::cout<< run_function(0.5, false)<< std::endl;   
   > }   
   > ===============================   
   >   
   >   
   > It can never compile, but is it actually illegal according to the C++   
   > standard?   
      
   C++11 (from N3290) §14.7.1/15: "There is an implementation-defined   
   quantity that specifies the limit on the total depth of recursive   
   instantiations, which could involve more than one template. The result   
   of an infinite recursion in instantiation is undefined"   
      
      
   Cheers & hth.,   
      
   - Alf   
      
      
   --   
    [ 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)   
|