From 885925a83becc8323eb6a8fd842ea88a6260397b Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 26 Nov 2012 11:44:04 -0800 Subject: [PATCH] Add a 'CAUTION' notice to warn about creating vectors (or other containers that use copy assignment) of types derived from SerializedType. You generally don't want to do this anyway due to slicing, but make clear the other risks. (Field names get mangled.) --- src/cpp/ripple/SerializedTypes.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cpp/ripple/SerializedTypes.h b/src/cpp/ripple/SerializedTypes.h index d60393e0db..7b97970033 100644 --- a/src/cpp/ripple/SerializedTypes.h +++ b/src/cpp/ripple/SerializedTypes.h @@ -12,6 +12,14 @@ #include "InstanceCounter.h" #include "Log.h" +// CAUTION: Do not create a vector (or similar container) of any object derived from +// SerializedType. Use Boost ptr_* containers. The copy assignment operator of +// SerializedType has semantics that will cause contained types to change their names +// when an object is deleted because copy assignment is used to "slide down" the +// remaining types and this will not copy the field name. Changing the copy assignment +// operator to copy the field name breaks the use of copy assignment just to copy values, +// which is used in the transaction engine code. + enum PathFlags { PF_END = 0x00, // End of current path & path list.