llvm.org GIT mirror llvm / fc9031c
C++11: Copy pointers with const auto * git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203254 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 5 years ago
1 changed file(s) with 5 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
746746 expensive.
747747
748748 As a rule of thumb, use ``const auto &`` unless you need to mutate or copy the
749 result.
749 result, and use ``const auto *`` when copying pointers.
750750
751751 .. code-block:: c++
752752
758758
759759 // Remove the reference if you really want a new copy.
760760 for (auto Val : Container) { Val.change(); saveSomewhere(Val); }
761
762 // Copy pointers, but make it clear that they're pointers.
763 for (const auto *Val : Container) { observe(*Val); }
764 for (auto *Val : Container) { Val->change(); }
761765
762766 Style Issues
763767 ============