金庆的专栏

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  423 随笔 :: 0 文章 :: 454 评论 :: 0 Trackbacks

C++ parameter passing rules

From: https://www.modernescpp.com/index.php/c-core-guidelines-how-to-pass-function-parameters

Parameter passing expression rules:

  • F.15: Prefer simple and conventional ways of passing information
  • F.16: For “in” parameters, pass cheaply-copied types by value and others by reference to const
  • F.17: For “in-out” parameters, pass by reference to non-const
  • F.18: For “consume” parameters, pass by X&& and std::move the parameter
  • F.19: For “forward” parameters, pass by TP&& and only std::forward the parameter
  • F.20: For “out” output values, prefer return values to output parameters
  • F.21: To return multiple “out” values, prefer returning a tuple or struct
  • F.60: Prefer T* over T& when “no argument” is a valid option
posted on 2022-10-29 11:01 金庆 阅读(103) 评论(0)  编辑 收藏 引用 所属分类: 1. C/C++

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理