Skip to content
Snippets Groups Projects
Commit ddb5ae3b authored by ilor's avatar ilor
Browse files

clarify that copies of Variables objects can share accesors

parent 7dc9c634
No related branches found
No related tags found
No related merge requests found
......@@ -108,9 +108,10 @@ protected:
* @todo the above is not the case yet.
*
* Objects of the accesor class can only be created by the Variables object,
* are valid only for that Variables object and might stop working if the
* Variables object is touched in the wrong way in between the creation and use
* of a VariableAccesor. UB is meant by "stop working".
* are valid only for that Variables object and its copies, and might stop
* working if the Variables object is touched in the wrong way in between the
* creation and use of a VariableAccesor. UB is meant by "stop working".
* Bad touch is not yet fully defined, removing a variable certainly is one.
*/
template<typename T>
class VariableAccesor : public BaseAccesor
......@@ -212,8 +213,8 @@ public:
/** Get a variable using a "fast" accesor.
*
* The accesor is required to have been created by this particular object,
* and the Variables object must have not had variables removed, however
* adding new variables should not invalidate VariableAccesor objects.
* or a copy (either way), and the Variables object must have not had
* variables removed (adding new variables should not invalidate accesors).
*
* If the VariableAccesor comes form a different Variables object or there
* have been invalidating changes to this Variables object, behavior is not
......
......@@ -14,12 +14,14 @@ struct VAfx
{
Variables v;
VAfx() {
v.put("a", new Bool(true));
v.put("b", new Bool(true));
v.put("c", new Bool(true));
v.put("bb", new Bool(true));
v.put("aa", new Position(1));
v.put("aaa", new Position(2));
Variables v2;
v2.put("a", new Bool(true));
v2.put("b", new Bool(true));
v2.put("c", new Bool(true));
v2.put("bb", new Bool(true));
v2.put("aa", new Position(1));
v2.put("aaa", new Position(2));
v = v2;
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment