]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/serialization/doc/state_saver.html
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / serialization / doc / state_saver.html
CommitLineData
7c673cae
FG
1<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!--
4(C) Copyright 2002-4 Robert Ramey - http://www.rrsd.com .
5Use, modification and distribution is subject to the Boost Software
6License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7http://www.boost.org/LICENSE_1_0.txt)
8-->
9<head>
10<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
11<link rel="stylesheet" type="text/css" href="../../../boost.css">
12<link rel="stylesheet" type="text/css" href="style.css">
13<title>Serialization - <code style="white-space: normal">state_saver</code></title>
14</head>
15<body link="#0000ff" vlink="#800080">
16<table border="0" cellpadding="7" cellspacing="0" width="100%" summary="header">
17 <tr>
18 <td valign="top" width="300">
19 <h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../boost.png" border="0"></a></h3>
20 </td>
21 <td valign="top">
22 <h1 align="center">Serialization</h1>
23 <h2 align="center"><code style="white-space: normal">state_saver</code</h2>
24 </td>
25 </tr>
26</table>
27<hr>
28<p>
29Sometimes a certain value has to change only for a limited scope.
30This class wrapper saves a copy of the current state of some object,
31and resets the object's state at destruction time, undoing any change the object
32may have gone through. Here is the interface:
33
34<pre><code>
35template<class T>
36// T requirements:
37// - POD or object semantic (cannot be reference, function, ...)
38// - copy constructor
39// - operator = (no-throw one preferred)
40class state_saver : private boost::noncopyable
41{
42private:
43 ... // implementation
44
45public:
46 state_saver(T & object);
47 ~state_saver();
48};
49</code></pre>
50
51The complete implementation can be found
52<a target="state_saver" href="../../../boost/serialization/state_saver.hpp">here</a>
53
54The following illustrates how this is expected to be used.
55
56<pre><code>
57#include &lt;boost/state_saver.hpp&gt;
58
59void func(A & a)
60 boost::state_saver&lt;A&gt; s(a);
61 ... // alter state of a by calling non-const functions
62 ... // call other functions
63 // original state of a automatically restored on exit
64}
65</pre></code>
66
67<h3>History</h3>
68This is a generalization of Daryle Walker's
69<a href="../../../libs/io/doc/ios_state.html">io_state_saver</a> library.
70<p>
71Robert Ramey made an initial version for the serialization library.
72<p>
73Pavel Vozenilek made several non-obvious refinements to make it more
74secure and boost friendly
75
76<hr>
77<p><i>&copy; Copyright <a href="http://www.rrsd.com">Robert Ramey</a> 2002-2004.
78Distributed under the Boost Software License, Version 1.0. (See
79accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
80</i></p>
81</body>
82</html>