C++ parameter passing rules
Posted 金庆
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C++ parameter passing rules相关的知识,希望对你有一定的参考价值。
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
以上是关于C++ parameter passing rules的主要内容,如果未能解决你的问题,请参考以下文章
pass by value和pass by reference在C++中有啥区别?
What exactly is the parameter e (event) and why pass it to JavaScript functions?
doris: shell invoke .sql script for doris and passing values for parameters in sql script.
thinkphp迁移工具报错implode(): Passing glue string after array is deprecated. Swap the parameters
SSIS Passing Parameters to an ADO .NET Source query;向ado.net数据源传递参数。
Unity Error executing result=instance->m_Sound->lock()An invalid parameter was passed to this func