Skip to content

Do not return const values

Returning a const value does not make sense, the client is able to copy the value into a non-const object anyway. It also disables move semantics, which is a constraint that has no benefits.

const Widget getWidget() { /* ... */ }
// ...
auto widget = getWidget() // Creates a mutable copy
widget.change(); // Able to change