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,224 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 14:00:34   
   
   From: daniel.kruegler@googlemail.com   
      
   On 2013-09-30 09:15, Daryle Walker wrote:   
   > On Sunday, September 29, 2013 10:00:05 PM UTC-4, Daryle Walker wrote:   
   >> Code like:   
   >>   
   >>       template < unsigned N >   
   >>       class MyClass   
   >>       {   
   >>       public:   
   >>           //...   
   >>           template < typename ...Args > bool MyFunc( Args &&...args );   
   >>           bool MyFunc( std::array &a );   
   >>           //...   
   >>       };   
   >>   
   >> 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.   
   >>   
   >> I know that you can use a std::initializer_list as a function   
   >> parameter and it'll work, but can you use any type that can use a   
   >> braced-list (assuming the right parameter type)?   
   >   
   > Found the answer while wandering around StackOverflow.   
   >   
   > The class definition is fine.   
      
   No, it is not (see my other reply).   
      
   > But when calling the code, I have to use   
   > std::array's proper double braces to work.  I guess sloppy brace placement   
   > won't work; any such foolishness will match std::initializer_list first.   
      
   I don't see any std::initializer_list in your example code. The   
   additional problem that you were stumbling across was due to   
      
   http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1270   
      
   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