[Development] RFC: more liberal 'auto' rules?

Marc Mutz marc.mutz at kdab.com
Mon Dec 7 15:44:42 CET 2015


On Monday 07 December 2015 13:48:58 Ziller Eike wrote:
> I do not think that more usage of ‘auto’ will make any code (or
> refactorings of it) ‘safer’. IMO this is only about convenience and
> readability.

  std::map<std::string, std::string> stdMap = ...;

  for (const std::pair<std::string, std::string> &e : stdMap)
      doSomething(e.first, e.second);

  for (const auto &e : stdMap)
      doSomething(e.first, e.second);

The second loop is at least two orders of magnitude faster (doSomething() is 
an out-of-line no-op).

Thanks,
Marc

-- 
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts



More information about the Development mailing list