FougTools  0.7.0dev-046fb6a
Handy tools for C++, Qt and OpenCascade
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
scoped_value.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** FougTools
3 ** Copyright Fougue (1 Mar. 2011)
4 ** contact@fougue.pro
5 **
6 ** This software is a computer program whose purpose is to provide utility
7 ** tools for the C++ language and the Qt toolkit.
8 **
9 ** This software is governed by the CeCILL-C license under French law and
10 ** abiding by the rules of distribution of free software. You can use,
11 ** modify and/ or redistribute the software under the terms of the CeCILL-C
12 ** license as circulated by CEA, CNRS and INRIA at the following URL
13 ** "http://www.cecill.info".
14 ****************************************************************************/
15 
16 #pragma once
17 
18 namespace cpp {
19 
26 template<typename T>
28 {
29 public:
30  ScopedValue(T& variable, T scopeValue);
31  ~ScopedValue();
32 
33 private:
34  T m_orgValue;
35  T& m_variable;
36 };
37 
39 
40 
41 // --
42 // -- Implementation
43 // --
44 
45 template<typename T>
46 ScopedValue<T>::ScopedValue(T &variable, T scopeValue)
47  : m_orgValue(variable),
48  m_variable(variable)
49 {
50  m_variable = scopeValue;
51 }
52 
53 template<typename T>
55 {
56  m_variable = m_orgValue;
57 }
58 
59 } // namespace cpp
~ScopedValue()
Definition: scoped_value.h:54
Definition: scoped_value.h:27
ScopedValue< bool > ScopedBool
Definition: scoped_value.h:38
Definition: basic_shared_pointer.h:20
ScopedValue(T &variable, T scopeValue)
Definition: scoped_value.h:46