C++ 遍历循环表达示 auto, auto&, auto&&

  1. for(auto x : range)
    创建拷贝,无法修改range中的元素

  2. for(auto& x : range)
    可以修改range中的元素,但一般用以下这种

for(auto&& x : range)
  1. for(const auto & x : range)
    只读range中的元素
原文地址:https://www.cnblogs.com/yaos/p/14014210.html