From e196e5232a510ad2c78edd21bc9df762a144c38a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 19 Nov 2008 12:06:17 +0000 Subject: [PATCH] store the value to be set inside wxON_BLOCK_EXIT_SET(), this allows to use temporaries with it and also fixes the test failure when built with icc and optimizations on (not sure if it is a compiler bug or not but in any case it seems better to fix it) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56848 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/scopeguard.h | 6 +++--- interface/wx/scopeguard.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/wx/scopeguard.h b/include/wx/scopeguard.h index baa33fb799..da056e08db 100644 --- a/include/wx/scopeguard.h +++ b/include/wx/scopeguard.h @@ -411,7 +411,7 @@ template class VariableSetterImpl : public VariableSetterBase { public: - VariableSetterImpl(T& var, const U& value) + VariableSetterImpl(T& var, U value) : m_var(var), m_value(value) { @@ -424,7 +424,7 @@ public: private: T& m_var; - const U& m_value; + const U m_value; // suppress the warning about assignment operator not being generated VariableSetterImpl& operator=(const VariableSetterImpl&); @@ -454,7 +454,7 @@ private: template inline -wxPrivate::VariableSetterImpl wxMakeVarSetter(T& var, const U& value) +wxPrivate::VariableSetterImpl wxMakeVarSetter(T& var, U value) { return wxPrivate::VariableSetterImpl(var, value); } diff --git a/interface/wx/scopeguard.h b/interface/wx/scopeguard.h index 55ea677e22..01887eb603 100644 --- a/interface/wx/scopeguard.h +++ b/interface/wx/scopeguard.h @@ -131,6 +131,9 @@ wxScopeGuard wxMakeGuard(F func, P1 p1, ..., PN pN); } @endcode + Notice that @a value is copied, i.e. stored by value, so it can be a + temporary object returned by a function call, for example. + @see wxON_BLOCK_EXIT_OBJ0(), wxON_BLOCK_EXIT_NULL() @header{wx/scopeguard.h} -- 2.45.2