From cbf3807ad4e93441d4a4324d1c21099ca644fac7 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Wed, 15 Apr 2015 23:22:31 -0700 Subject: Implement copy ctor/assignment for xpath_variable_set xpath_variable_set is essentially an associative container; it's about time it became copyable. Implementation is slightly tricky due to out of memory handling. Both copy ctor and assignment operator have strong exception guarantee (even if exceptions are disabled! which translates to "roll back on allocation errors"). --- src/pugixml.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/pugixml.hpp') diff --git a/src/pugixml.hpp b/src/pugixml.hpp index a7154f1..b8b8946 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -1075,17 +1075,22 @@ namespace pugi private: xpath_variable* _data[64]; - // Non-copyable semantics - xpath_variable_set(const xpath_variable_set&); - xpath_variable_set& operator=(const xpath_variable_set&); + void _assign(const xpath_variable_set& rhs); + void _swap(xpath_variable_set& rhs); + + xpath_variable* _find(const char_t* name) const; - xpath_variable* find(const char_t* name) const; + static bool _clone(xpath_variable* var, xpath_variable** out_result); public: // Default constructor/destructor xpath_variable_set(); ~xpath_variable_set(); + // Copy constructor/assignment operator + xpath_variable_set(const xpath_variable_set& rhs); + xpath_variable_set& operator=(const xpath_variable_set& rhs); + // Add a new variable or get the existing one, if the types match xpath_variable* add(const char_t* name, xpath_value_type type); -- cgit v1.2.3