A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.ultimatepp.org/srcdoc$Core$ValueReference$en-us.html below:

Rules for references to Value internal maps elements :: U++

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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4