PageRenderTime 19ms CodeModel.GetById 11ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/src/contrib/boost-1.52.0/boost/xpressive/detail/utility/save_restore.hpp

https://gitlab.com/tylerluo/pythonocc
C++ Header | 55 lines | 37 code | 11 blank | 7 comment | 1 complexity | 2331eed37990f26b78ab4a95e1ace99c MD5 | raw file
 1///////////////////////////////////////////////////////////////////////////////
 2// save_restore.hpp
 3//
 4//  Copyright 2008 Eric Niebler. Distributed under the Boost
 5//  Software License, Version 1.0. (See accompanying file
 6//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 7
 8#ifndef BOOST_XPRESSIVE_DETAIL_UTILITY_SAVE_RESTORE_HPP_EAN_10_04_2005
 9#define BOOST_XPRESSIVE_DETAIL_UTILITY_SAVE_RESTORE_HPP_EAN_10_04_2005
10
11// MS compatible compilers support #pragma once
12#if defined(_MSC_VER) && (_MSC_VER >= 1020)
13# pragma once
14#endif
15
16#include <boost/noncopyable.hpp>
17
18namespace boost { namespace xpressive { namespace detail
19{
20
21    template<typename T>
22    struct save_restore
23      : private noncopyable
24    {
25        explicit save_restore(T &t)
26          : ref(t)
27          , val(t)
28        {
29        }
30
31        save_restore(T &t, T const &n)
32          : ref(t)
33          , val(t)
34        {
35            this->ref = n;
36        }
37
38        ~save_restore()
39        {
40            this->ref = this->val;
41        }
42
43        void restore()
44        {
45            this->ref = this->val;
46        }
47
48    private:
49        T &ref;
50        T const val;
51    };
52
53}}}
54
55#endif