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,407 of 33,346   
   Daryle Walker to All   
   [C++11] Initializer lists vs. 0 or 1 ite   
   25 Aug 11 05:31:41   
   
   1c39e778   
   From: darylew@gmail.com   
      
   Hi.  I just started reading a copy of a C++ draft I got several months   
   ago (n3282.pdf, I think).  I have some quick questions.   
      
   1. Let's say my class can take several arguments of the same type.  I   
   also want to take zero arguments, as a default constructor, and one   
   argument as a conversion.   
      
   template < typename T >   
   class my_complex   
   {   
   public:   
       my_complex() = default;   
       my_complex( T first );   
       my_complex( std::initializer_list list );   
   //...   
   };   
      
   If I just use the initializer constructor, and get rid of the other   
   two, would I still need the braces when I use zero or one argument?   
   Or do I need all three constructors if I need brace-less construction   
   with zero or one arguments?   
      
   2.  Maybe I missed something, or I haven't read the applicable section   
   yet, but what's with the   
      
   class my_class   
   {   
   public:   
       void  f() &;   
       void  f() &&;   
   };   
      
   construct?  What's it do?  What's it for?  How does it differ from   
   returning a reference?   
      
   Daryle W.   
      
      
   --   
         [ 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