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 32,713 of 33,346    |
|    DeMarcus to All    |
|    Re: Why isn't class a subset of class...    |
|    08 Dec 12 10:35:05    |
   
   -september.org> ced5b43b   
   From: use_my_alias_here_at_hotmail_com@tellus.orb.dotsrc.org   
      
   >> Actually that makes it even more desirable to allow TakeTemplate to   
   >> receive variadic templates or normal templates with any number of   
   >> arguments (as long as there are default arguments so it matches   
   >> TakeTemplate).   
   >   
   > But then, shouldn't the same also be possible with default function   
   > arguments?   
   >   
      
   Actually it's already possible today if you consider the following.   
      
   void takeFnc( void (*fnc)(int) ) {}   
   void fnc( int a, int b = 42 ) {}   
      
   int main()   
   {   
    takeFnc( fnc ); // Error!   
    return 0;   
   }   
      
   Now rearrange your code like this:   
      
   void takeFnc( void (*fnc)(int) ) {}   
   void fnc( int a, int b ) {}   
   void fnc( int a ) { int b = 42; }   
      
   int main()   
   {   
    takeFnc( fnc ); // It's now allowed.   
    return 0;   
   }   
      
   So the semantical question is: is a function with default arguments   
   actually several overloaded functions? If so, we should be able to use   
   them all.   
      
      
   Regards,   
   Daniel   
      
      
      
   --   
    [ 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)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca