C++ parameter passing rules


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