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 33,221 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to Daryle Walker   
   Re: Is using a braced-list as a function   
   30 Sep 13 00:13:16   
   
   From: daniel.kruegler@googlemail.com   
      
   On 2013-09-30 04:56, Daryle Walker wrote:   
   >   
   > Code like:   
   >   
   >       template < unsigned N >   
   >       class MyClass   
   >       {   
   >       public:   
   >           //...   
   >           template < typename ...Args >   
   >           bool MyFunc( Args &&...args );   
   >   
   >           bool MyFunc( std::array &a );   
      
   Take a second look at your argument type: This is an lvalue reference to   
   non-const std::array<>. How would you expect to bind a temporary to an   
   lvalue reference to non-const T?   
      
   > The two "MyFunc" methods call the hidden "MyFuncImpl" to do their   
   > work.  I can make calls like "MyFunc(a, b, c)" just fine.  But when I   
   > try "MyFunc({d, e, f})" to trigger the std::array overload, I get   
   > complaints on no candidate being found; that initializer-list (the   
   > internal compiler concept, not necessarily std::initializer_list)   
   > couldn't convert to anything appropriate.   
      
   Understandable. Fix your function argument type to "const   
   std::array&" and it should work.   
      
   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)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca