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}