[llvm] r203254 - C++11: Copy pointers with const auto *

Duncan P. N. Exon Smith dexonsmith at apple.com
Fri Mar 7 09:23:30 PST 2014


Author: dexonsmith
Date: Fri Mar  7 11:23:29 2014
New Revision: 203254

URL: http://llvm.org/viewvc/llvm-project?rev=203254&view=rev
Log:
C++11: Copy pointers with const auto *

Modified:
    llvm/trunk/docs/CodingStandards.rst

Modified: llvm/trunk/docs/CodingStandards.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CodingStandards.rst?rev=203254&r1=203253&r2=203254&view=diff
==============================================================================
--- llvm/trunk/docs/CodingStandards.rst (original)
+++ llvm/trunk/docs/CodingStandards.rst Fri Mar  7 11:23:29 2014
@@ -747,7 +747,7 @@ is a copy.  Particularly in range-based
 expensive.
 
 As a rule of thumb, use ``const auto &`` unless you need to mutate or copy the
-result.
+result, and use ``const auto *`` when copying pointers.
 
 .. code-block:: c++
 
@@ -760,6 +760,10 @@ result.
   // Remove the reference if you really want a new copy.
   for (auto Val : Container) { Val.change(); saveSomewhere(Val); }
 
+  // Copy pointers, but make it clear that they're pointers.
+  for (const auto *Val : Container) { observe(*Val); }
+  for (auto *Val : Container) { Val->change(); }
+
 Style Issues
 ============
 





More information about the llvm-commits mailing list