summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-03-07 17:23:29 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-03-07 17:23:29 +0000
commit6b3d6a4fe9013c3737fb3226d12cd691da05686b (patch)
tree207094e110c0df2d3e4632412e83d8496201bfc2
parent0990e05d43b40ac8c1242610db0029cc12be45e7 (diff)
downloadbcm5719-llvm-6b3d6a4fe9013c3737fb3226d12cd691da05686b.tar.gz
bcm5719-llvm-6b3d6a4fe9013c3737fb3226d12cd691da05686b.zip
C++11: Copy pointers with const auto *
llvm-svn: 203254
-rw-r--r--llvm/docs/CodingStandards.rst6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/docs/CodingStandards.rst b/llvm/docs/CodingStandards.rst
index a762bf358e3..f9685d69ad5 100644
--- a/llvm/docs/CodingStandards.rst
+++ b/llvm/docs/CodingStandards.rst
@@ -747,7 +747,7 @@ is a copy. Particularly in range-based ``for`` loops, careless copies are
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
============
OpenPOWER on IntegriCloud