Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Non-const reference parameters are still not allowed #148

@achanana

Description

@achanana

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 &amp;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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions