Say you’re working on a large code base, and you came across several instances where some type of non-negligible size was passed as argument by value – where it was more efficient to pass by const reference. Fixing a few occurrences is easy, but how can you efficiently list all places throughout the code where this happens?
Here’s a trick: define the type as aligned, and rebuild. The compiler would now shout exactly where the type is passed by value, since aligned types cannot be passed as such.
Double clicking every such error would get you immediately to where a fix is probably in order.
That’s a nice trick! Useful if you have colleagues that were trained in c# or Java. Those guys will forever pass stuff by value without giving it any thought.
Indeed.