Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50848 - in trunk/libs/scope_exit/doc/html: . scope_exit
From: daniel_james_at_[hidden]
Date: 2009-01-28 10:32:47


Author: danieljames
Date: 2009-01-28 10:32:46 EST (Wed, 28 Jan 2009)
New Revision: 50848
URL: http://svn.boost.org/trac/boost/changeset/50848

Log:
Generate the scope_exit documentation.
Added:
   trunk/libs/scope_exit/doc/html/
   trunk/libs/scope_exit/doc/html/index.html (contents, props changed)
   trunk/libs/scope_exit/doc/html/scope_exit/
   trunk/libs/scope_exit/doc/html/scope_exit/acknowledge.html (contents, props changed)
   trunk/libs/scope_exit/doc/html/scope_exit/alternatives.html (contents, props changed)
   trunk/libs/scope_exit/doc/html/scope_exit/compilers.html (contents, props changed)
   trunk/libs/scope_exit/doc/html/scope_exit/conf.html (contents, props changed)
   trunk/libs/scope_exit/doc/html/scope_exit/ref.html (contents, props changed)
   trunk/libs/scope_exit/doc/html/scope_exit/tutorial.html (contents, props changed)

Added: trunk/libs/scope_exit/doc/html/index.html
==============================================================================
--- (empty file)
+++ trunk/libs/scope_exit/doc/html/index.html 2009-01-28 10:32:46 EST (Wed, 28 Jan 2009)
@@ -0,0 +1,77 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Chapter 1. Boost.ScopeExit</title>
+<link rel="stylesheet" href="../../../../doc/html/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
+<link rel="home" href="index.html" title="Chapter 1. Boost.ScopeExit">
+<link rel="next" href="scope_exit/tutorial.html" title="Tutorial">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav"><a accesskey="n" href="scope_exit/tutorial.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a></div>
+<div class="chapter" lang="en">
+<div class="titlepage"><div>
+<div><h2 class="title">
+<a name="scope_exit"></a>Chapter 1. Boost.ScopeExit</h2></div>
+<div><div class="author"><h3 class="author">
+<span class="firstname">Alexander</span> <span class="surname">Nasonov</span>
+</h3></div></div>
+<div><p class="copyright">Copyright © 2006 -2009 Alexander Nasonov</p></div>
+<div><div class="legalnotice">
+<a name="id1036342"></a><p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">
+ http://www.boost.org/LICENSE_1_0.txt </a>)
+ </p>
+</div></div>
+</div></div>
+<div class="toc">
+<p><b>Table of Contents</b></p>
+<dl>
+<dt><span class="section"> Introduction</span></dt>
+<dt><span class="section"> Tutorial</span></dt>
+<dt><span class="section"> Alternatives</span></dt>
+<dt><span class="section"> Supported Compilers</span></dt>
+<dt><span class="section"> Configuration</span></dt>
+<dt><span class="section"> Reference</span></dt>
+<dt><span class="section"> Acknowledge</span></dt>
+</dl>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="scope_exit.intro"></a> Introduction</h2></div></div></div>
+<p>
+ Nowadays, every C++ developer is familiar with RAII
+ technique. It binds resource acquisition and release to initialization and
+ destruction of a variable that holds the resource. But there are times when
+ writing a special class for such variable is not worth the effort.
+ </p>
+<p>
+ This is when <a class="link" href="index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a> macro comes into play.
+ You put resource acquisition directly in your code and next to it you write
+ a code that releases the resource.
+ </p>
+<p>
+ Read <a class="link" href="scope_exit/tutorial.html" title="Tutorial">Tutorial</a> to find out how to
+ write programs with <a class="link" href="index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a> or jump straight
+ to the <a class="link" href="scope_exit/ref.html" title="Reference">Reference</a> section.
+ </p>
+</div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"><p><small>Last revised: January 28, 2009 at 15:23:21 GMT</small></p></td>
+<td align="right"><div class="copyright-footer"></div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav"><a accesskey="n" href="scope_exit/tutorial.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a></div>
+</body>
+</html>

Added: trunk/libs/scope_exit/doc/html/scope_exit/acknowledge.html
==============================================================================
--- (empty file)
+++ trunk/libs/scope_exit/doc/html/scope_exit/acknowledge.html 2009-01-28 10:32:46 EST (Wed, 28 Jan 2009)
@@ -0,0 +1,66 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Acknowledge</title>
+<link rel="stylesheet" href="../../../../../doc/html/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.ScopeExit">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.ScopeExit">
+<link rel="prev" href="ref.html" title="Reference">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="ref.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="scope_exit.acknowledge"></a> Acknowledge</h2></div></div></div>
+<p>
+ (in chronological order)
+ </p>
+<p>
+ Maxim Yegorushkin for sending me a code where he used a local struct to clean
+ up resources.
+ </p>
+<p>
+ Andrei Alexandrescu for pointing me to scope(exit)
+ construct of the D
+ programming language.
+ </p>
+<p>
+ Pavel Vozenilek and Maxim Yanchenko for reviews of early drafts of the library.
+ </p>
+<p>
+ Steven Watanabe for his valuable ideas.
+ </p>
+<p>
+ Jody Hagins for good comments that helped to significantly improve the documentation.
+ </p>
+<p>
+ Richard Webb for testing the library on MSVC compiler.
+ </p>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2006 -2009 Alexander Nasonov<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">
+ http://www.boost.org/LICENSE_1_0.txt </a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="ref.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a>
+</div>
+</body>
+</html>

Added: trunk/libs/scope_exit/doc/html/scope_exit/alternatives.html
==============================================================================
--- (empty file)
+++ trunk/libs/scope_exit/doc/html/scope_exit/alternatives.html 2009-01-28 10:32:46 EST (Wed, 28 Jan 2009)
@@ -0,0 +1,303 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Alternatives</title>
+<link rel="stylesheet" href="../../../../../doc/html/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.ScopeExit">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.ScopeExit">
+<link rel="prev" href="tutorial.html" title="Tutorial">
+<link rel="next" href="compilers.html" title="Supported Compilers">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="tutorial.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="compilers.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="scope_exit.alternatives"></a> Alternatives</h2></div></div></div>
+<a name="alternatives.try_catch"></a><h4>
+<a name="id1037675"></a>
+ try-catch
+ </h4>
+<p>
+ This is an example of using a badly designed <code class="computeroutput"><span class="identifier">File</span></code>
+ class. An instance of <code class="computeroutput"><span class="identifier">File</span></code>
+ doesn't close a file in a destructor, a programmer is expected to call the
+ <code class="computeroutput"><span class="identifier">close</span></code> member function explicitly.
+ </p>
+<pre class="programlisting"><span class="identifier">File</span> <span class="identifier">passwd</span><span class="special">;</span>
+<span class="keyword">try</span> <span class="special">{</span>
+ <span class="identifier">passwd</span><span class="special">.</span><span class="identifier">open</span><span class="special">(</span><span class="string">"/etc/passwd"</span><span class="special">);</span>
+ <span class="comment">// ...
+</span> <span class="identifier">passwd</span><span class="special">.</span><span class="identifier">close</span><span class="special">();</span>
+<span class="special">}</span>
+<span class="keyword">catch</span><span class="special">(...)</span> <span class="special">{</span>
+ <span class="identifier">log</span><span class="special">(</span><span class="string">"could not get user info"</span><span class="special">);</span>
+ <span class="keyword">if</span><span class="special">(</span><span class="identifier">passwd</span><span class="special">.</span><span class="identifier">is_open</span><span class="special">())</span>
+ <span class="identifier">passwd</span><span class="special">.</span><span class="identifier">close</span><span class="special">();</span>
+ <span class="keyword">throw</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ Note the following:
+ </p>
+<div class="itemizedlist"><ul type="disc">
+<li>
+ the <code class="computeroutput"><span class="identifier">passwd</span></code> object is defined
+ outside of the <code class="computeroutput"><span class="keyword">try</span></code> block because
+ this object is required inside the <code class="computeroutput"><span class="keyword">catch</span></code>
+ block to close the file,
+ </li>
+<li>
+ the <code class="computeroutput"><span class="identifier">passwd</span></code> object is not
+ fully constructed until after the <code class="computeroutput"><span class="identifier">open</span></code>
+ member function returns, and
+ </li>
+<li>
+ if opening throws, the <code class="computeroutput"><span class="identifier">passwd</span><span class="special">.</span><span class="identifier">close</span><span class="special">()</span></code> should not be called, hence the call to
+ <code class="computeroutput"><span class="identifier">passwd</span><span class="special">.</span><span class="identifier">is_open</span><span class="special">()</span></code>.
+ </li>
+</ul></div>
+<p>
+ <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a> doesn't have any of these problems:
+ </p>
+<pre class="programlisting"><span class="keyword">try</span> <span class="special">{</span>
+ <span class="identifier">File</span> <span class="identifier">passwd</span><span class="special">(</span><span class="string">"/etc/passwd"</span><span class="special">);</span>
+ <span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span> <span class="special">(&amp;</span><span class="identifier">passwd</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">passwd</span><span class="special">.</span><span class="identifier">close</span><span class="special">();</span>
+ <span class="special">}</span> <span class="identifier">BOOST_SCOPE_EXIT_END</span>
+ <span class="comment">// ...
+</span><span class="special">}</span>
+<span class="keyword">catch</span><span class="special">(...)</span> <span class="special">{</span>
+ <span class="identifier">log</span><span class="special">(</span><span class="string">"could not get user info"</span><span class="special">);</span>
+ <span class="keyword">throw</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<a name="alternatives.raii"></a><h4>
+<a name="id1038144"></a>
+ RAII
+ </h4>
+<p>
+ RAII
+ is absolutely perfect for the <code class="computeroutput"><span class="identifier">File</span></code>
+ class introduced above. Use of a properly designed <code class="computeroutput"><span class="identifier">File</span></code>
+ class would look like:
+ </p>
+<pre class="programlisting"><span class="keyword">try</span> <span class="special">{</span>
+ <span class="identifier">File</span> <span class="identifier">passwd</span><span class="special">(</span><span class="string">"/etc/passwd"</span><span class="special">);</span>
+ <span class="comment">// ...
+</span><span class="special">}</span>
+<span class="keyword">catch</span><span class="special">(...)</span> <span class="special">{</span>
+ <span class="identifier">log</span><span class="special">(</span><span class="string">"could not get user info"</span><span class="special">);</span>
+ <span class="keyword">throw</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ However, using RAII
+ to build up a <a href="http://www.research.att.com/~bs/glossary.html#Gstrong-guarantee" target="_top">strong
+ guarantee</a> could introduce a lot of non-reusable RAII
+ types. For example:
+ </p>
+<pre class="programlisting"><span class="identifier">m_persons</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">person</span><span class="special">);</span>
+<span class="identifier">pop_back_if_not_commit</span> <span class="identifier">pop_back_if_not_commit_guard</span><span class="special">(</span><span class="identifier">commit</span><span class="special">,</span> <span class="identifier">m_persons</span><span class="special">);</span>
+</pre>
+<p>
+ The <code class="computeroutput"><span class="identifier">pop_back_if_not_commit</span></code>
+ class is either defined out of the scope or as a local class:
+ </p>
+<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">pop_back_if_not_commit</span> <span class="special">{</span>
+ <span class="keyword">bool</span> <span class="identifier">m_commit</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">Person</span><span class="special">&gt;&amp;</span> <span class="identifier">m_vec</span><span class="special">;</span>
+ <span class="comment">// ...
+</span> <span class="special">~</span><span class="identifier">pop_back_if_not_commit</span><span class="special">()</span> <span class="special">{</span>
+ <span class="keyword">if</span><span class="special">(!</span><span class="identifier">m_commit</span><span class="special">)</span>
+ <span class="identifier">m_vec</span><span class="special">.</span><span class="identifier">pop_back</span><span class="special">();</span>
+ <span class="special">}</span>
+<span class="special">};</span>
+</pre>
+<p>
+ In some cases <a href="http://www.research.att.com/~bs/glossary.html#Gstrong-guarantee" target="_top">strong
+ guarantee</a> can be accomplished with standard utilities:
+ </p>
+<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">auto_ptr</span><span class="special">&lt;</span><span class="identifier">Person</span><span class="special">&gt;</span> <span class="identifier">spSuperMan</span><span class="special">(</span><span class="keyword">new</span> <span class="identifier">Superman</span><span class="special">);</span>
+<span class="identifier">m_persons</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">spSuperMan</span><span class="special">.</span><span class="identifier">get</span><span class="special">());</span>
+<span class="identifier">spSuperMan</span><span class="special">.</span><span class="identifier">release</span><span class="special">();</span> <span class="comment">// m_persons successfully took ownership.
+</span></pre>
+<p>
+ or with specialized containers such as <a href="../../../../../libs/ptr_container/doc/ptr_container.html" target="_top">Boost
+ Pointer Container Library</a> or <a href="../../../../../libs/multi_index/doc/index.html" target="_top">Boost
+ Multi-Index Containers Library</a>.
+ </p>
+<a name="alternatives._ulink_url__http___www_ddj_com_dept_cpp_184403758__scopeguard__ulink_"></a><h4>
+<a name="id1038643"></a>
+ ScopeGuard
+ </h4>
+<p>
+ Imagine that you add a new currency rate:
+ </p>
+<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">commit</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">;</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">currency</span><span class="special">(</span><span class="string">"EUR"</span><span class="special">);</span>
+<span class="keyword">double</span> <span class="identifier">rate</span> <span class="special">=</span> <span class="number">1.3326</span><span class="special">;</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span> <span class="keyword">double</span><span class="special">&gt;</span> <span class="identifier">rates</span><span class="special">;</span>
+<span class="keyword">bool</span> <span class="identifier">currency_rate_inserted</span> <span class="special">=</span>
+ <span class="identifier">rates</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">make_pair</span><span class="special">(</span><span class="identifier">currency</span><span class="special">,</span> <span class="identifier">rate</span><span class="special">)).</span><span class="identifier">second</span><span class="special">;</span>
+</pre>
+<p>
+ and then continue a transaction. If it cannot be completed, you erase the currency
+ from <code class="computeroutput"><span class="identifier">rates</span></code>. This is how you
+ can do this with ScopeGuard
+ and Boost.Lambda:
+ </p>
+<pre class="programlisting"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">lambda</span><span class="special">;</span>
+
+<span class="identifier">ON_BLOCK_EXIT</span><span class="special">(</span>
+ <span class="identifier">if_</span><span class="special">(</span><span class="identifier">currency_rate_inserted</span> <span class="special">&amp;&amp;</span> <span class="special">!</span><span class="identifier">_1</span><span class="special">)</span> <span class="special">[</span>
+ <span class="identifier">bind</span><span class="special">(</span>
+ <span class="keyword">static_cast</span><span class="special">&lt;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span><span class="keyword">double</span><span class="special">&gt;::</span><span class="identifier">size_type</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span><span class="keyword">double</span><span class="special">&gt;::*)(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;)</span>
+ <span class="special">&gt;(&amp;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">,</span><span class="keyword">double</span><span class="special">&gt;::</span><span class="identifier">erase</span><span class="special">)</span>
+ <span class="special">,</span> <span class="special">&amp;</span><span class="identifier">rates</span>
+ <span class="special">,</span> <span class="identifier">currency</span>
+ <span class="special">)</span>
+ <span class="special">]</span>
+ <span class="special">,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">cref</span><span class="special">(</span><span class="identifier">commit</span><span class="special">)</span>
+ <span class="special">);</span>
+
+<span class="comment">// ...
+</span>
+<span class="identifier">commit</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span>
+</pre>
+<p>
+ Note that
+ </p>
+<div class="itemizedlist"><ul type="disc">
+<li>
+ Boost.lambda expressions are hard to write correctly, for example, overloaded
+ function must be explicitly casted, as demonstrated in this example,
+ </li>
+<li>
+ condition in <code class="computeroutput"><span class="identifier">if_</span></code> expression
+ refers to <code class="computeroutput"><span class="identifier">commit</span></code> variable
+ indirectly through the <code class="computeroutput"><span class="identifier">_1</span></code>
+ placeholder,
+ </li>
+<li>
+ setting a breakpoint inside <code class="computeroutput"><span class="identifier">if_</span><span class="special">[</span> <span class="special">...</span> <span class="special">]</span></code>
+ requires in-depth knowledge of Boost.Lambda
+ and debugging techniques.
+ </li>
+</ul></div>
+<p>
+ This code will look much better with native lambda expressions proposed for
+ C++0x:
+ </p>
+<pre class="programlisting"><span class="identifier">ON_BLOCK_EXIT</span><span class="special">(</span>
+ <span class="special">[</span><span class="identifier">currency_rate_inserted</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">commit</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">rates</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">currency</span><span class="special">]()</span> <span class="special">-&gt;</span> <span class="keyword">void</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span><span class="special">(</span><span class="identifier">currency_rate_inserted</span> <span class="special">&amp;&amp;</span> <span class="special">!</span><span class="identifier">commit</span><span class="special">)</span>
+ <span class="identifier">rates</span><span class="special">.</span><span class="identifier">erase</span><span class="special">(</span><span class="identifier">currency</span><span class="special">);</span>
+ <span class="special">}</span>
+<span class="special">);</span>
+</pre>
+<p>
+ With <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a> you can simply do
+ </p>
+<pre class="programlisting"><span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span> <span class="special">(</span><span class="identifier">currency_rate_inserted</span><span class="special">)(&amp;</span><span class="identifier">commit</span><span class="special">)(&amp;</span><span class="identifier">rates</span><span class="special">)(&amp;</span><span class="identifier">currency</span><span class="special">)</span> <span class="special">)</span>
+<span class="special">{</span>
+ <span class="keyword">if</span><span class="special">(</span><span class="identifier">currency_rate_inserted</span> <span class="special">&amp;&amp;</span> <span class="special">!</span><span class="identifier">commit</span><span class="special">)</span>
+ <span class="identifier">rates</span><span class="special">.</span><span class="identifier">erase</span><span class="special">(</span><span class="identifier">currency</span><span class="special">);</span>
+<span class="special">}</span> <span class="identifier">BOOST_SCOPE_EXIT_END</span>
+
+<span class="comment">// ...
+</span>
+<span class="identifier">commit</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span>
+</pre>
+<a name="alternatives.c__0x"></a><h4>
+<a name="id1039632"></a>
+ C++0x
+ </h4>
+<p>
+ In future releases <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a> will take advantages
+ of C++0x features.
+ </p>
+<div class="itemizedlist"><ul type="disc"><li>
+ Passing capture list as <a href="../../../../../libs/preprocessor/index.html" target="_top">Boost.Preprocessor
+ sequence</a> will be replaced with a traditional macro invocation style:
+ </li></ul></div>
+<pre class="programlisting"><span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span><span class="identifier">currency_rate_inserted</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">commit</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">rates</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">currency</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="keyword">if</span><span class="special">(</span><span class="identifier">currency_rate_inserted</span> <span class="special">&amp;&amp;</span> <span class="special">!</span><span class="identifier">commit</span><span class="special">)</span>
+ <span class="identifier">rates</span><span class="special">.</span><span class="identifier">erase</span><span class="special">(</span><span class="identifier">currency</span><span class="special">);</span>
+<span class="special">}</span> <span class="identifier">BOOST_SCOPE_EXIT_END</span>
+</pre>
+<div class="itemizedlist"><ul type="disc"><li>
+<code class="computeroutput"><span class="identifier">BOOST_SCOPE_EXIT_END</span></code> will
+ be replaced with a semicolon:
+ </li></ul></div>
+<pre class="programlisting"><span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span><span class="identifier">currency_rate_inserted</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">commit</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">rates</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">currency</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="keyword">if</span><span class="special">(</span><span class="identifier">currency_rate_inserted</span> <span class="special">&amp;&amp;</span> <span class="special">!</span><span class="identifier">commit</span><span class="special">)</span>
+ <span class="identifier">rates</span><span class="special">.</span><span class="identifier">erase</span><span class="special">(</span><span class="identifier">currency</span><span class="special">);</span>
+<span class="special">};</span>
+</pre>
+<div class="itemizedlist"><ul type="disc"><li>
+ Users will be able to capture local variables implicitly with lambda capture
+ defaults <code class="computeroutput"><span class="special">&amp;</span></code> and <code class="computeroutput"><span class="special">=</span></code>:
+ </li></ul></div>
+<pre class="programlisting"><span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(&amp;,</span> <span class="identifier">currency_rate_inserted</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="keyword">if</span><span class="special">(</span><span class="identifier">currency_rate_inserted</span> <span class="special">&amp;&amp;</span> <span class="special">!</span><span class="identifier">commit</span><span class="special">)</span>
+ <span class="identifier">rates</span><span class="special">.</span><span class="identifier">erase</span><span class="special">(</span><span class="identifier">currency</span><span class="special">);</span>
+<span class="special">};</span>
+</pre>
+<div class="itemizedlist"><ul type="disc"><li>
+ It will be possible to capture <code class="computeroutput"><span class="keyword">this</span></code>
+ pointer.
+ </li></ul></div>
+<a name="alternatives.the_d_programming_language"></a><h4>
+<a name="id1040070"></a>
+ The D Programming Language
+ </h4>
+<p>
+ <span class="underline">ScopeExit</span> is similar to scope(exit)
+ feature built into the D
+ programming language.
+ </p>
+<p>
+ A curious reader may notice that the library doesn't implement <code class="computeroutput"><span class="identifier">scope</span><span class="special">(</span><span class="identifier">success</span><span class="special">)</span></code> and <code class="computeroutput"><span class="identifier">scope</span><span class="special">(</span><span class="identifier">failure</span><span class="special">)</span></code> of the D
+ language. Unfortunately, it's not possible in C++ because failure or success
+ condition cannot be determined by calling <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">uncaught_exception</span></code>.
+ It's not a big problem, though. These two constructs can be expressed in terms
+ of scope(exit)
+ and a <code class="computeroutput"><span class="keyword">bool</span> <span class="identifier">commit</span></code>
+ variable as explained in <a class="link" href="tutorial.html" title="Tutorial">Tutorial</a>.
+ Refer to Guru of the Week #47
+ for more details about <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">uncaught_exception</span></code>
+ and if it has any good use at all.
+ </p>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2006 -2009 Alexander Nasonov<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">
+ http://www.boost.org/LICENSE_1_0.txt </a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="tutorial.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="compilers.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: trunk/libs/scope_exit/doc/html/scope_exit/compilers.html
==============================================================================
--- (empty file)
+++ trunk/libs/scope_exit/doc/html/scope_exit/compilers.html 2009-01-28 10:32:46 EST (Wed, 28 Jan 2009)
@@ -0,0 +1,61 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Supported Compilers</title>
+<link rel="stylesheet" href="../../../../../doc/html/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.ScopeExit">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.ScopeExit">
+<link rel="prev" href="alternatives.html" title="Alternatives">
+<link rel="next" href="conf.html" title="Configuration">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="alternatives.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="conf.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="scope_exit.compilers"></a> Supported Compilers</h2></div></div></div>
+<p>
+ The library should be usable on any compiler that supports Boost.Typeof
+ except
+ </p>
+<div class="itemizedlist"><ul type="disc">
+<li>
+ MSVC 7.1 and 8.0 fail to link if a function with <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a>
+ is included by multiple translation units.
+ </li>
+<li>
+ GCC 3.3 can't compile <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a> inside
+ a template. See <a href="http://lists.boost.org/Archives/boost/2007/02/116235.php" target="_top">this
+ thread</a> for more details.
+ </li>
+</ul></div>
+<p>
+ The author tested the library on GCC 3.3, 3.4, 4.1, 4.2 and Intel 10.1.
+ </p>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2006 -2009 Alexander Nasonov<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">
+ http://www.boost.org/LICENSE_1_0.txt </a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="alternatives.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="conf.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: trunk/libs/scope_exit/doc/html/scope_exit/conf.html
==============================================================================
--- (empty file)
+++ trunk/libs/scope_exit/doc/html/scope_exit/conf.html 2009-01-28 10:32:46 EST (Wed, 28 Jan 2009)
@@ -0,0 +1,49 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Configuration</title>
+<link rel="stylesheet" href="../../../../../doc/html/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.ScopeExit">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.ScopeExit">
+<link rel="prev" href="compilers.html" title="Supported Compilers">
+<link rel="next" href="ref.html" title="Reference">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="compilers.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="ref.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="scope_exit.conf"></a> Configuration</h2></div></div></div>
+<p>
+ Normally, no configuration is required for the library but note that the library
+ depends on Boost.Typeof
+ and you may want to configure or enforce <a href="../../../../../libs/typeof/index.html" target="_top">typeof
+ emulation</a>.
+ </p>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2006 -2009 Alexander Nasonov<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">
+ http://www.boost.org/LICENSE_1_0.txt </a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="compilers.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="ref.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: trunk/libs/scope_exit/doc/html/scope_exit/ref.html
==============================================================================
--- (empty file)
+++ trunk/libs/scope_exit/doc/html/scope_exit/ref.html 2009-01-28 10:32:46 EST (Wed, 28 Jan 2009)
@@ -0,0 +1,153 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Reference</title>
+<link rel="stylesheet" href="../../../../../doc/html/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.ScopeExit">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.ScopeExit">
+<link rel="prev" href="conf.html" title="Configuration">
+<link rel="next" href="acknowledge.html" title="Acknowledge">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="conf.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="acknowledge.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="scope_exit.ref"></a> Reference</h2></div></div></div>
+<a name="ref.boost_scope_exit"></a><h4>
+<a name="id1040305"></a>
+ BOOST_SCOPE_EXIT
+ </h4>
+<p>
+ A <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a> declaration has the following
+ synopsis:
+ </p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">scope_exit</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
+
+<span class="identifier">BOOST_SCOPE_EXIT</span> <span class="special">(</span> <span class="identifier">scope</span><span class="special">-</span><span class="identifier">exit</span><span class="special">-</span><span class="identifier">capture</span><span class="special">-</span><span class="identifier">list</span> <span class="special">)</span>
+ <span class="identifier">function</span><span class="special">-</span><span class="identifier">body</span>
+<span class="identifier">BOOST_SCOPE_EXIT_END</span>
+</pre>
+<p>
+ where
+ </p>
+<pre class="programlisting"><span class="identifier">scope</span><span class="special">-</span><span class="identifier">exit</span><span class="special">-</span><span class="identifier">capture</span><span class="special">-</span><span class="identifier">list</span><span class="special">:</span>
+ <span class="special">(</span> <span class="identifier">scope</span><span class="special">-</span><span class="identifier">exit</span><span class="special">-</span><span class="identifier">capture</span> <span class="special">)</span>
+ <span class="identifier">scope</span><span class="special">-</span><span class="identifier">exit</span><span class="special">-</span><span class="identifier">capture</span><span class="special">-</span><span class="identifier">list</span> <span class="special">(</span> <span class="identifier">scope</span><span class="special">-</span><span class="identifier">exit</span><span class="special">-</span><span class="identifier">capture</span> <span class="special">)</span>
+
+<span class="identifier">scope</span><span class="special">-</span><span class="identifier">exit</span><span class="special">-</span><span class="identifier">capture</span><span class="special">:</span>
+ <span class="identifier">identifier</span>
+ <span class="special">&amp;</span><span class="identifier">identifier</span>
+</pre>
+<p>
+ The <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a> declaration schedules an execution
+ of <code class="computeroutput"><span class="identifier">scope</span><span class="special">-</span><span class="identifier">exit</span><span class="special">-</span><span class="identifier">body</span></code>
+ at the end of the current scope. The <code class="computeroutput"><span class="identifier">scope</span><span class="special">-</span><span class="identifier">exit</span><span class="special">-</span><span class="identifier">body</span></code> statements are executed in the reverse
+ order of <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a> declarations in the given
+ scope. The scope must be local.
+ </p>
+<p>
+ Each <code class="computeroutput"><span class="identifier">identifier</span></code> in <code class="computeroutput"><span class="identifier">scope</span><span class="special">-</span><span class="identifier">exit</span><span class="special">-</span><span class="identifier">capture</span><span class="special">-</span><span class="identifier">list</span></code> must
+ be a valid name in enclosing scope and it must appear exactly once in the list.
+ If a <code class="computeroutput"><span class="identifier">scope</span><span class="special">-</span><span class="identifier">exit</span><span class="special">-</span><span class="identifier">capture</span></code>
+ starts with the ampersand sign <code class="computeroutput"><span class="special">&amp;</span></code>,
+ the corresponding <code class="computeroutput"><span class="identifier">identifier</span></code>
+ will be available inside <code class="computeroutput"><span class="identifier">scope</span><span class="special">-</span><span class="identifier">exit</span><span class="special">-</span><span class="identifier">body</span></code>; otherwise, a copy of it will be made
+ at the point of <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a> declaration and
+ that copy will be available inside <code class="computeroutput"><span class="identifier">scope</span><span class="special">-</span><span class="identifier">exit</span><span class="special">-</span><span class="identifier">body</span></code>. In the latter case, the <code class="computeroutput"><span class="identifier">idenitifer</span></code> must be <code class="computeroutput"><span class="identifier">CopyConstructible</span></code>.
+ </p>
+<p>
+ Only identifiers listed in <code class="computeroutput"><span class="identifier">scope</span><span class="special">-</span><span class="identifier">exit</span><span class="special">-</span><span class="identifier">capture</span><span class="special">-</span><span class="identifier">list</span></code>, static variables, <code class="computeroutput"><span class="keyword">extern</span></code>
+ variables and functions, and enumerations from the enclosing scope can be used
+ inside the <code class="computeroutput"><span class="identifier">scope</span><span class="special">-</span><span class="identifier">exit</span><span class="special">-</span><span class="identifier">body</span></code>.
+ </p>
+<div class="note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/html/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ <code class="computeroutput"><span class="keyword">this</span></code> pointer is not an identifier
+ and cannot be passed to <code class="computeroutput"> <span class="identifier">scope</span><span class="special">-</span><span class="identifier">exit</span><span class="special">-</span><span class="identifier">capture</span><span class="special">-</span><span class="identifier">list</span></code>.
+ </p></td></tr>
+</table></div>
+<p>
+ The <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a> uses Boost.Typeof
+ to determine types of <code class="computeroutput"><span class="identifier">scope</span><span class="special">-</span><span class="identifier">exit</span><span class="special">-</span><span class="identifier">capture</span><span class="special">-</span><span class="identifier">list</span></code> elements. In order to compile code in
+ typeof emulation mode,
+ all types should be registered with BOOST_TYPEOF_REGISTER_TYPE
+ or BOOST_TYPEOF_REGISTER_TEMPLATE
+ macros, or appropriate Boost.Typeof
+ headers should be included.
+ </p>
+<a name="ref.boost_scope_exit_tpl"></a><h4>
+<a name="id1041009"></a>
+ BOOST_SCOPE_EXIT_TPL
+ </h4>
+<p>
+ This macro is a workaround for various versions of gcc. These compilers don't
+ compile <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a> declaration inside function
+ templates. As a workaround, the <code class="computeroutput"><span class="identifier">_TPL</span></code>
+ suffix should be appended to <code class="computeroutput"><span class="identifier">BOOST_SCOPE_EXIT</span></code>.
+ </p>
+<p>
+ The problem boils down to the following code:
+ </p>
+<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">void</span> <span class="identifier">foo</span><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">t</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">struct</span> <span class="identifier">Local</span> <span class="special">{</span>
+ <span class="keyword">typedef</span> <span class="identifier">__typeof__</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">typeof_i</span><span class="special">;</span>
+ <span class="keyword">typedef</span> <span class="identifier">__typeof__</span><span class="special">(</span><span class="identifier">t</span><span class="special">)</span> <span class="identifier">typeof_t</span><span class="special">;</span>
+ <span class="special">};</span>
+ <span class="keyword">typedef</span> <span class="identifier">Local</span><span class="special">::</span><span class="identifier">typeof_i</span> <span class="identifier">i_type</span><span class="special">;</span>
+ <span class="keyword">typedef</span> <span class="identifier">Local</span><span class="special">::</span><span class="identifier">typeof_t</span> <span class="identifier">t_type</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> <span class="special">{</span> <span class="identifier">foo</span><span class="special">(</span><span class="number">0</span><span class="special">);</span> <span class="special">}</span>
+</pre>
+<p>
+ This can be fixed by adding <code class="computeroutput"><span class="keyword">typename</span></code>
+ in front of <code class="computeroutput"><span class="identifier">Local</span><span class="special">::</span><span class="identifier">typeof_i</span></code> and <code class="computeroutput"><span class="identifier">Local</span><span class="special">::</span><span class="identifier">typeof_t</span></code>.
+ </p>
+<p>
+ See also <a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37920" target="_top">GCC
+ bug 37920</a>.
+ </p>
+<div class="note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/html/images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ Although <code class="computeroutput"><span class="identifier">BOOST_SCOPE_EXIT_TPL</span></code>
+ has the same suffix as the <code class="computeroutput"><span class="identifier">BOOST_TYPEOF_TPL</span></code>,
+ it doesn't follow a convention of the Boost.Typeof.
+ </p></td></tr>
+</table></div>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2006 -2009 Alexander Nasonov<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">
+ http://www.boost.org/LICENSE_1_0.txt </a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="conf.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="acknowledge.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>

Added: trunk/libs/scope_exit/doc/html/scope_exit/tutorial.html
==============================================================================
--- (empty file)
+++ trunk/libs/scope_exit/doc/html/scope_exit/tutorial.html 2009-01-28 10:32:46 EST (Wed, 28 Jan 2009)
@@ -0,0 +1,151 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>Tutorial</title>
+<link rel="stylesheet" href="../../../../../doc/html/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.ScopeExit">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.ScopeExit">
+<link rel="prev" href="../index.html" title="Chapter 1. Boost.ScopeExit">
+<link rel="next" href="alternatives.html" title="Alternatives">
+</head>
+<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
+<table cellpadding="2" width="100%"><tr>
+<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
+<td align="center">Home</td>
+<td align="center">Libraries</td>
+<td align="center">People</td>
+<td align="center">FAQ</td>
+<td align="center">More</td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="../index.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="alternatives.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="scope_exit.tutorial"></a> Tutorial</h2></div></div></div>
+<p>
+ Imagine that you want to make many modifications to data members of the <code class="computeroutput"><span class="identifier">World</span></code> class in the <code class="computeroutput"><span class="identifier">World</span><span class="special">::</span><span class="identifier">addPerson</span></code>
+ function. You start with adding a new <code class="computeroutput"><span class="identifier">Person</span></code>
+ object to a vector of persons:
+ </p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">World</span><span class="special">::</span><span class="identifier">addPerson</span><span class="special">(</span><span class="identifier">Person</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">person</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">bool</span> <span class="identifier">commit</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">;</span>
+ <span class="identifier">m_persons</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">person</span><span class="special">);</span> <span class="comment">// (1) direct action
+</span></pre>
+<p>
+ Some operation down the road may throw an exception and all changes to involved
+ objects should be rolled back. This all-or-nothing semantic is also known as
+ <a href="http://www.research.att.com/~bs/glossary.html#Gstrong-guarantee" target="_top">strong
+ guarantee</a>.
+ </p>
+<p>
+ In particular, last added person must be deleted from <code class="computeroutput"><span class="identifier">m_persons</span></code>
+ when the function throws. All you need is to define a delayed action (release
+ of a resource) right after the direct action (resource acquisition):
+ </p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">World</span><span class="special">::</span><span class="identifier">addPerson</span><span class="special">(</span><span class="identifier">Person</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">aPerson</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">bool</span> <span class="identifier">commit</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">;</span>
+ <span class="identifier">m_persons</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">aPerson</span><span class="special">);</span> <span class="comment">// (1) direct action
+</span> <span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span> <span class="special">(&amp;</span><span class="identifier">commit</span><span class="special">)(&amp;</span><span class="identifier">m_persons</span><span class="special">)</span> <span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span><span class="special">(!</span><span class="identifier">commit</span><span class="special">)</span>
+ <span class="identifier">m_persons</span><span class="special">.</span><span class="identifier">pop_back</span><span class="special">();</span> <span class="comment">// (2) rollback action
+</span> <span class="special">}</span> <span class="identifier">BOOST_SCOPE_EXIT_END</span>
+
+ <span class="comment">// ... // (3) other operations
+</span>
+ <span class="identifier">commit</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span> <span class="comment">// (4) turn all rollback actions into no-op
+</span><span class="special">}</span>
+</pre>
+<p>
+ The block below point <code class="computeroutput"><span class="special">(</span><span class="number">1</span><span class="special">)</span></code> is a <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a>
+ declaration. Unlike point <code class="computeroutput"><span class="special">(</span><span class="number">1</span><span class="special">)</span></code>, an execution of the <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a>
+ body will be delayed until the end of the current scope. In this case it will
+ be executed either after point <code class="computeroutput"><span class="special">(</span><span class="number">4</span><span class="special">)</span></code> or on any
+ exception.
+ </p>
+<p>
+ The <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a> declaration starts with <code class="computeroutput"><span class="identifier">BOOST_SCOPE_EXIT</span></code> macro invocation which accepts
+ Boost.Preprocessor sequence
+ of captured variables. If a capture starts with the ampersand sign <code class="computeroutput"><span class="special">&amp;</span></code>, a reference to the captured variable
+ will be available inside the <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit">ScopeExit</a> body;
+ otherwise, a copy of the variable will be made after the point <code class="computeroutput"><span class="special">(</span><span class="number">1</span><span class="special">)</span></code>
+ and only the copy will be available inside the body.
+ </p>
+<p>
+ In the example above, variables <code class="computeroutput"><span class="identifier">commit</span></code>
+ and <code class="computeroutput"><span class="identifier">m_persons</span></code> are passed by
+ reference because the final value of the <code class="computeroutput"><span class="identifier">commit</span></code>
+ variable should be used to determine whether to execute rollback action or
+ not and the action should modify the <code class="computeroutput"><span class="identifier">m_persons</span></code>
+ object, not its copy. This is a most common case but passing a variable by
+ value is sometimes useful as well.
+ </p>
+<p>
+ Consider a more complex case where <code class="computeroutput"><span class="identifier">World</span><span class="special">::</span><span class="identifier">addPerson</span></code>
+ can save intermediate states at some points and roll back to the last saved
+ state. You can use <code class="computeroutput"><span class="identifier">Person</span><span class="special">::</span><span class="identifier">m_evolution</span></code> to store a version of changes
+ and increment it to cancel all rollback actions associated with those changes.
+ </p>
+<p>
+ If you pass a current value of <code class="computeroutput"><span class="identifier">m_evolution</span></code>
+ stored in the <code class="computeroutput"><span class="identifier">checkpoint</span></code> variable
+ by value, it will remain unchanged until the end of aa scope and you can compare
+ it with the final value of the <code class="computeroutput"><span class="identifier">m_evolution</span></code>.
+ If the latter wasn't incremented since you saved it, the rollback action inside
+ the block should be executed:
+ </p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">World</span><span class="special">::</span><span class="identifier">addPerson</span><span class="special">(</span><span class="identifier">Person</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">aPerson</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">m_persons</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">aPerson</span><span class="special">);</span>
+
+ <span class="comment">// This block must be no-throw
+</span> <span class="identifier">Person</span><span class="special">&amp;</span> <span class="identifier">person</span> <span class="special">=</span> <span class="identifier">m_persons</span><span class="special">.</span><span class="identifier">back</span><span class="special">();</span>
+ <span class="identifier">Person</span><span class="special">::</span><span class="identifier">evolution_t</span> <span class="identifier">checkpoint</span> <span class="special">=</span> <span class="identifier">person</span><span class="special">.</span><span class="identifier">m_evolution</span><span class="special">;</span>
+
+ <span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span> <span class="special">(</span><span class="identifier">checkpoint</span><span class="special">)(&amp;</span><span class="identifier">person</span><span class="special">)(&amp;</span><span class="identifier">m_persons</span><span class="special">)</span> <span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span><span class="special">(</span><span class="identifier">checkpoint</span> <span class="special">==</span> <span class="identifier">person</span><span class="special">.</span><span class="identifier">m_evolution</span><span class="special">)</span>
+ <span class="identifier">m_persons</span><span class="special">.</span><span class="identifier">pop_back</span><span class="special">();</span>
+ <span class="special">}</span> <span class="identifier">BOOST_SCOPE_EXIT_END</span>
+
+ <span class="comment">// ...
+</span>
+ <span class="identifier">checkpoint</span> <span class="special">=</span> <span class="special">++</span><span class="identifier">person</span><span class="special">.</span><span class="identifier">m_evolution</span><span class="special">;</span>
+
+ <span class="comment">// Assign new id to the person
+</span> <span class="identifier">World</span><span class="special">::</span><span class="identifier">id_t</span> <span class="keyword">const</span> <span class="identifier">prev_id</span> <span class="special">=</span> <span class="identifier">person</span><span class="special">.</span><span class="identifier">m_id</span><span class="special">;</span>
+ <span class="identifier">person</span><span class="special">.</span><span class="identifier">m_id</span> <span class="special">=</span> <span class="identifier">m_next_id</span><span class="special">++;</span>
+ <span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span> <span class="special">(</span><span class="identifier">checkpoint</span><span class="special">)(&amp;</span><span class="identifier">person</span><span class="special">)(&amp;</span><span class="identifier">m_next_id</span><span class="special">)(</span><span class="identifier">prev_id</span><span class="special">)</span> <span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">if</span><span class="special">(</span><span class="identifier">checkpoint</span> <span class="special">==</span> <span class="identifier">person</span><span class="special">.</span><span class="identifier">m_evolution</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">m_next_id</span> <span class="special">=</span> <span class="identifier">person</span><span class="special">.</span><span class="identifier">m_id</span><span class="special">;</span>
+ <span class="identifier">person</span><span class="special">.</span><span class="identifier">m_id</span> <span class="special">=</span> <span class="identifier">prev_id</span><span class="special">;</span>
+ <span class="special">}</span>
+ <span class="special">}</span> <span class="identifier">BOOST_SCOPE_EXIT_END</span>
+
+ <span class="comment">// ...
+</span>
+ <span class="identifier">checkpoint</span> <span class="special">=</span> <span class="special">++</span><span class="identifier">person</span><span class="special">.</span><span class="identifier">m_evolution</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ Full code listing can be found in world.cpp.
+ </p>
+</div>
+<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
+<td align="left"></td>
+<td align="right"><div class="copyright-footer">Copyright © 2006 -2009 Alexander Nasonov<p>
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">
+ http://www.boost.org/LICENSE_1_0.txt </a>)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="../index.html"><img src="../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="alternatives.html"><img src="../../../../../doc/html/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk