@@ -106,9 +106,9 @@ union Placeholder
106106 return pHolder;
107107 }
108108
109- // MSVC71 doesn 't extend friendship to nested class (Any::Holder)
110- #if !defined(POCO_MSVC_VERSION) || (defined(POCO_MSVC_VERSION) && (POCO_MSVC_VERSION > 71 ))
111- private:
109+ // MSVC71,80 won 't extend friendship to nested class (Any::Holder)
110+ #if !defined(POCO_MSVC_VERSION) || (defined(POCO_MSVC_VERSION) && (POCO_MSVC_VERSION > 80 ))
111+ // private:
112112#endif
113113
114114 PlaceholderT* pHolder;
@@ -165,7 +165,7 @@ class Any
165165 if (!empty ())
166166 {
167167 if (_valueHolder.isLocal ())
168- content ()-> ~ValueHolder ();
168+ destruct ();
169169 else
170170 delete content ();
171171 }
@@ -174,9 +174,9 @@ class Any
174174 Any& swap (Any& other)
175175 // / Swaps the content of the two Anys.
176176 // /
177- // / When small object optimizaton is enabled,
178- // / swap is only exception-safe when both (*this and
179- // / other) objects are allocated on the heap.
177+ // / When small object optimizaton is enabled, swap only
178+ // / has no-throw guarantee when both (*this and other)
179+ // / objects are allocated on the heap.
180180 {
181181 if (this == &other) return *this ;
182182
@@ -187,16 +187,24 @@ class Any
187187 else
188188 {
189189 Any tmp (*this );
190- if (_valueHolder.isLocal ()) this ->~Any ();
191- construct (other);
192- other = tmp;
190+ try
191+ {
192+ if (_valueHolder.isLocal ()) destruct ();
193+ construct (other);
194+ other = tmp;
195+ }
196+ catch (...)
197+ {
198+ construct (tmp);
199+ throw ;
200+ }
193201 }
194202
195203 return *this ;
196204 }
197205
198206 template <typename ValueType>
199- Any & operator = (const ValueType& rhs)
207+ Any& operator = (const ValueType& rhs)
200208 // / Assignment operator for all types != Any.
201209 // /
202210 // / Example:
@@ -309,6 +317,11 @@ class Any
309317 _valueHolder.erase ();
310318 }
311319
320+ void destruct ()
321+ {
322+ content ()->~ValueHolder ();
323+ }
324+
312325 Placeholder<ValueHolder> _valueHolder;
313326
314327
0 commit comments