ValueTree& vs. ValueTree* vs. ValueTree (ValueTree&)


When maintaining references to a ValueTree node (e.g in a Component / ComponentAttachment to keep track of the node to read/write from/to), is there ever any (e.g. performance) advantage in using ValueTree& or ValueTree* ?

Or should I always be using

//Creates a reference to another ValueTree.
ValueTree::ValueTree (const ValueTree&) noexcept

and storing the references as ValueTree objects?


From the docs:

Create ValueTree objects on the stack, and don’t be afraid to copy them around, as they’re simply a lightweight reference to a shared data container.
Creating a copy of another ValueTree simply creates a new reference to the same underlying object - to make a separate, deep copy of a tree you should explicitly call createCopy().

So ValueTree* makes no sense.

Here you find the difference between the copy constructor and the assignment operator:



Thank you @daniel :thumbsup: