Re: C++11 features, move semantics?



<<Resending due to problem with my membership of gtkmm-list. Apologies
if you get this twice. If you have already replied to the list, can I
get you forward me your email.>>

On Wed, 2015-01-21 at 11:36 +0100, François Legendre wrote:
Hi,

For range based loop, why not use the name of the element (and not the indice) ?

-    for(unsigned i = 0; i < names.size(); i++)
-      std::cout << names[i] << "." << std::endl;
+    for(const auto& i : names)
+      std::cout << i << "." << std::endl;

+    for(const auto& name : names)
+      std::cout << name << "." << std::endl;


What about using:

        for (auto&& name: names)

?


-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel winder ekiga net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel winder org uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]