l-september.org> daa5bb8a   
   From: troplin@bluewin.ch   
      
   DeMarcus wrote:   
   >>> 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; }   
      
   Probably you mean:   
   void fnc( int a ) { fnc(a, 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.   
      
   I tend to disagree on the semantical part. A default parameter gives you   
   the guarantee, that both functions are the same, just with one parameter   
   fixed.   
   With overloaded functions on the other hand each overload can have an   
   entirely different functionality. And usually this is also the case, since   
   otherwise you could use default parameters.   
      
   Anyway, regardless whether they are semantically different or not, they are   
   not the same in C++, and that's the relevant part.   
      
   It's a bit like the difference between:   
   typedef A B;   
   and:   
   class B : public A {};   
   They are both similar but not equivalent.   
      
   Tobi   
      
      
   --   
    [ 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)   
|