From ddb5ae3b8dab610b183b1404c26871aedcab85dc Mon Sep 17 00:00:00 2001 From: ilor <kailoran@gmail.com> Date: Mon, 8 Nov 2010 13:10:42 +0100 Subject: [PATCH] clarify that copies of Variables objects can share accesors --- libwccl/variables.h | 11 ++++++----- tests/varaccess.cpp | 14 ++++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/libwccl/variables.h b/libwccl/variables.h index 107d36b..c489974 100644 --- a/libwccl/variables.h +++ b/libwccl/variables.h @@ -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 diff --git a/tests/varaccess.cpp b/tests/varaccess.cpp index 663c60d..b10e781 100644 --- a/tests/varaccess.cpp +++ b/tests/varaccess.cpp @@ -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; } }; -- GitLab