diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-03-07 17:23:29 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-03-07 17:23:29 +0000 |
commit | fc9031cdffa3063ef747bd3a98833f164d07fc4a (patch) | |
tree | 203051082d127a05bdca47dc34485e275407a32a /docs/CodingStandards.rst | |
parent | ac4c4a88441fdb8611834b0cfeb11979e7839d4d (diff) | |
download | llvm-fc9031cdffa3063ef747bd3a98833f164d07fc4a.tar.gz llvm-fc9031cdffa3063ef747bd3a98833f164d07fc4a.tar.bz2 llvm-fc9031cdffa3063ef747bd3a98833f164d07fc4a.tar.xz |
C++11: Copy pointers with const auto *
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203254 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/CodingStandards.rst')
-rw-r--r-- | docs/CodingStandards.rst | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/docs/CodingStandards.rst b/docs/CodingStandards.rst index a762bf358e..f9685d69ad 100644 --- a/docs/CodingStandards.rst +++ b/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 ============ |