IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    C++ parameter passing rules

    金庆发表于 2022-10-29 03:01:00
    love 0

    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


    金庆 2022-10-29 11:01 发表评论


沪ICP备19023445号-2号
友情链接