About structs and performant handling

Namespace rswhite4 at googlemail.com
Tue Mar 12 14:02:05 PDT 2013


One option, that I could think of why one should mark such 
parameters, would be that the compiler can then point out what is 
missing so that it would be potentially possible.

Example:
void foo (A a) {

Because 'a' is not const and not scope, the compiler could not 
change the behavior from passing by value to passing by reference.

But when the parameter is marked accordingly:
void foo (A& a) {

You get an error / warning:
"Parameters with '&' require const scope."
Whether 'A' ultimately is really big enough to make it worthwhile 
to have it passed by ref is irrelevant for that.


More information about the Digitalmars-d mailing list