TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
C++ Coding Standard

Rule:  INT#008Checked automatically with code checker

Synopsis:Use constant references (const &) instead of call-by-value, unless using a basic data type, a simple object or a pointer
Severity Level:7
Category:Class Interface


Method/function arguments are invoked according to call-by-value. This means that values are copied with invocations to constructors and destructors as a result. This does no harm for basic data types, simple objects and pointers, but reduces performance for complex objects. When arguments are passed using references (call-by-reference), only the reference itself is copied.

void SetComplexObject(const ComplexObject sName);    // Less efficient.
void SetComplexObject(const ComplexObject& rsName);  // More efficient.
A simple object is defined as an object that has at most 5 leave basic data types. E.g. both
struct Coordinate {
  int x;
  int y;
  int z;


class Product {
  Coordinate loc;
  float price;

are considered simple objects in this context.