passByType
Enforces how parameters of configured types are passed. Large types should
be taken by const reference, cheap types by value; this check keeps that
consistent across a code base.
// With "molsys::SimulationBox" = "const_ref"
void run(molsys::SimulationBox box); // Bad — passed by value.
void run(molsys::SimulationBox &box); // Bad — non-const reference.
void run(const molsys::SimulationBox &box); // Good.
Configuration
Key |
Type |
Default |
Description |
|---|---|---|---|
|
table (required) |
— |
Maps fully-qualified type names to a rule. A rule is either a mode
string or a table |
Each rule accepts:
Key |
Type |
Default |
Description |
|---|---|---|---|
|
string (required) |
— |
|
|
boolean |
|
Also check the return type of simple getters of this type
(non-static |
Non-const lvalue references, rvalue references and pointers are always flagged for a configured type.
Type names are matched like in paramNameForType:
cv-qualifiers, references and pointers are stripped, a leading :: is
ignored, and qualified names also match when wrapped in another namespace.
[cpp.ast_check_config.passByType.types]
"molsys::SimulationBox" = { mode = "const_ref", check_getter = true }
"Real" = "value"
"std::string_view" = { mode = "const_ref_or_value" }
The check is a no-op until types is configured.