|
FEAT 3
Finite Element Analysis Toolbox
|
This page discusses the differences, assumptions and implications when using references or pointers as arguments for class member functions, operators and constructors.
A pointer or reference parameter of a (class member) function is called transient, if the object referenced by the pointer or reference is only accessed within the function body (and possibly other functions taking this reference/pointer as a transient one), but no reference or pointer to the object is kept in the class object after the function call returns.
In other words: transient pointers/references are only used within the called function, but they are not stored for later use, so in consequence it is perfectly safe if the pointed/referenced object is modified, moved or destroyed after the function call returns.
A pointer or reference parameter of a (class member) function is called resident, if a reference or pointer to the referenced object is stored inside a class object for later use after the function call returns.
In consequence, the pointed/referenced object has to remain valid after the called function returns until the lifetime of the resident object (usually the class object of the member function, unless stated otherwise in the function documentation) reaches its end. It is the responsibility of the caller to ensure that the pointed/referenced object is not destroyed, moved or otherwise modified.