首页 > 编程语言 > 详细

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

时间:2019-12-25 01:40:21      阅读:801      评论:0      收藏:0      [点我收藏+]
  1. for(auto x : range)
    创建拷贝,无法修改range中的元素

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

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

原文:https://www.cnblogs.com/yaos/p/12094304.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!