home bbs files messages ]

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 31,878 of 33,346   
   Helmut Jarausch to Helmut Zeisel   
   Re: could not deduce template argument f   
   01 Feb 12 10:29:10   
   
   4884188b   
   From: jarausch@igpm.rwth-aachen.de   
      
   On Tue, 31 Jan 2012 14:36:39 -0800, Helmut Zeisel wrote:   
      
   > Why does the code below not compile?   
   >   
   > VC 2010 says   
   >   
   >    error C2784: 'void f(double [m][n])' : could not deduce template   
   > argument for 'double [m][n]' from 'double [2][3]'   
   >   
   > GCC 4.5.3 says   
   >   
   >   error: no matching function for call to `f(double [2][3])'   
   >   
   > Explicitely saying f<2,3>(a) works in both cases.   
   >   
   >   
   > Helmut   
   >   
   > ===========   
   >   
   > #include    
   >   
   > template void f(double a[m][n])   
   > {   
   >   std::cout << "m=" << m << " n=" << n << std::endl;   
   > };   
   >   
   > int main()   
   > {   
   >   double a[2][3];   
   >   f(a);   
   >   return 0;   
   > }   
      
   I'd use the new std::array. Even gcc-4.5.3 has it if you use  -std=c++0x.   
   I think your case is one of the reasons for std::array having been added   
   to the standard library. I wouldn't use a C-array ever again.   
      
   Helmut.   
      
      
   --   
         [ 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