Many of Blenders class constructor and methods do not use the const
qualifier for input parameters. This is especially cumbersome if you want to pass a const
pointer (eitherway: a constant pointer, or a pointer to constant data) to a method that will only accept a non-const pointer. In such a case, you have to cast away the const
, knowing or assuming that the method will not change the pointer or data.
Example:
GHOST_EventDragnDrop
takes amongst others GHOST_TEventDataPtr data
. I doubt that the user provided data has to be modified at some point in the pipeline. If it does indeed, this is not documented.
There are many more cases where input arguments are non-const. Functions should always use const
for pure input references or pointers to 1) allow passing read-only memory, 2) signalling that passed data is not changed.
Is there a particular reason, why input parameters rarely use the const
qualifier?