Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site











SourceForge.net Logo

Rules for references to ValueArray, ValueMap and Value elements

Value is originally designed as non-mutable concrete Value of different concrete types.

 

However, as Value is commonly used to store complex hierarchies (using ValueArray/ValueMap), it is in the end very useful to be able to reference ValueArray/ValueMap elements directly. Validity of such references is restricted by following rule:

 

Reference obtained from Value/ValueArray/ValueMap (by Value::At, Value::GetAdd, ValueArray::At, ValueMap::GetAdd and derivative methods) are only valid until the next operation on originating Value - including just reading it.

 

Examples of invalid code:

 

 

Value m;

Value& x = m("key");

x = m; // using m as source invalidates x

....

Value m;

Value& x = m("key");

Value& y = m("key2"); // Invalidates x

x = 123; // undefined

....

Value m;

Value& x = m.At(1);

Value m2 = m; // Invalidates x

x = "fail"; // undefined

 

Last edit by cxl on 12/13/2016. Do you want to contribute?. T++