-
Notifications
You must be signed in to change notification settings - Fork 295
Closed
Labels
Description
The Google C++ Style Guide seems to have allowed using non-const references as parameters, I see not reason why not to allow them here too. (runtime/references)
Relevant styleguide changes (google/styleguide@57cd341...gh-pages):
- Input parameters are usually values or <code>const</code> references, while output and input/output parameters will be non-<code>const</code> pointers.
+ Input parameters should usually be values or <code>const</code> references, while required (non-nullable) output and input/output parameters should usually be references.
- All parameters passed by reference must be labeled <code>const</code>.
- In C, if a function needs to modify a variable, the parameter must use a pointer, eg <code>int foo(int *pval)</code>. In C++, the function can alternatively declare a reference parameter: <code>int foo(int &val)</code>
- Within function parameter lists all references must be
<code>const</code>:
- In fact it is a very strong convention in Google code that input arguments are values or <code>const</code> references while output arguments are pointers. Input parameters may be <code>const</code> pointers, but we never allow non-<code>const</code> reference parameters except when required by convention, e.g., <code>swap()</code>.
Most changes seem to come from this recent commit:
google/styleguide@7a7a2f510efe7d7fc (May 20th, 2020)
wp-seth, xzhan96, ljishen, oushu1huangweiyang1, nikgraf and 5 more