|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r76459 - in sandbox/closure: boost/closure/detail/preprocessor libs/closure/example libs/scope_exit/doc libs/scope_exit/doc/html libs/scope_exit/doc/html/scope_exit libs/scope_exit/example libs/scope_exit/test
From: lorcaminiti_at_[hidden]
Date: 2012-01-13 11:50:32
Author: lcaminiti
Date: 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
New Revision: 76459
URL: http://svn.boost.org/trac/boost/changeset/76459
Log:
ScopeExit enhancements.
Added:
sandbox/closure/boost/closure/detail/preprocessor/line_counter.hpp (contents, props changed)
sandbox/closure/boost/closure/detail/preprocessor/void_list.hpp (contents, props changed)
sandbox/closure/libs/closure/example/function_types.cpp (contents, props changed)
sandbox/closure/libs/scope_exit/doc/Jamfile.v2 (contents, props changed)
sandbox/closure/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT.html (contents, props changed)
sandbox/closure/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ALL.html (contents, props changed)
sandbox/closure/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_CONFIG_NO_CPP11.html (contents, props changed)
sandbox/closure/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_END.html (contents, props changed)
sandbox/closure/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_TPL.html (contents, props changed)
sandbox/closure/libs/scope_exit/doc/html/index.html (contents, props changed)
sandbox/closure/libs/scope_exit/doc/html/reference.html (contents, props changed)
sandbox/closure/libs/scope_exit/doc/html/scope_exit/
sandbox/closure/libs/scope_exit/doc/html/scope_exit/Getting_Started.html (contents, props changed)
sandbox/closure/libs/scope_exit/doc/html/scope_exit/No_Variadic_Macros.html (contents, props changed)
sandbox/closure/libs/scope_exit/doc/html/scope_exit/Tutorial.html (contents, props changed)
sandbox/closure/libs/scope_exit/doc/html/scope_exit/acknowledgements.html (contents, props changed)
sandbox/closure/libs/scope_exit/doc/html/scope_exit/annex__alternatives.html (contents, props changed)
sandbox/closure/libs/scope_exit/doc/scope_exit.qbk (contents, props changed)
sandbox/closure/libs/scope_exit/example/Jamfile.v2 (contents, props changed)
sandbox/closure/libs/scope_exit/example/scope_guard.cpp (contents, props changed)
sandbox/closure/libs/scope_exit/example/scope_guard_seq.cpp (contents, props changed)
sandbox/closure/libs/scope_exit/example/try_catch.cpp (contents, props changed)
sandbox/closure/libs/scope_exit/example/try_catch_seq.cpp (contents, props changed)
sandbox/closure/libs/scope_exit/test/Jamfile.v2 (contents, props changed)
sandbox/closure/libs/scope_exit/test/world.cpp (contents, props changed)
sandbox/closure/libs/scope_exit/test/world_all.cpp (contents, props changed)
sandbox/closure/libs/scope_exit/test/world_all_seq.cpp (contents, props changed)
sandbox/closure/libs/scope_exit/test/world_commit.cpp (contents, props changed)
sandbox/closure/libs/scope_exit/test/world_commit_lambda.cpp (contents, props changed)
sandbox/closure/libs/scope_exit/test/world_commit_seq.cpp (contents, props changed)
sandbox/closure/libs/scope_exit/test/world_commit_this.cpp (contents, props changed)
sandbox/closure/libs/scope_exit/test/world_commit_this_seq.cpp (contents, props changed)
sandbox/closure/libs/scope_exit/test/world_commit_tpl.cpp (contents, props changed)
sandbox/closure/libs/scope_exit/test/world_commit_tpl_seq.cpp (contents, props changed)
sandbox/closure/libs/scope_exit/test/world_commit_void.cpp (contents, props changed)
sandbox/closure/libs/scope_exit/test/world_seq.cpp (contents, props changed)
Properties modified:
sandbox/closure/libs/scope_exit/doc/ (props changed)
sandbox/closure/libs/scope_exit/doc/html/ (props changed)
sandbox/closure/libs/scope_exit/example/ (props changed)
sandbox/closure/libs/scope_exit/test/ (props changed)
Added: sandbox/closure/boost/closure/detail/preprocessor/line_counter.hpp
==============================================================================
--- (empty file)
+++ sandbox/closure/boost/closure/detail/preprocessor/line_counter.hpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,17 @@
+
+#ifndef BOOST_CLOSURE_DETAIL_PP_LINE_COUNTER_HPP_
+#define BOOST_CLOSURE_DETAIL_PP_LINE_COUNTER_HPP_
+
+#include <boost/config.hpp>
+
+// PUBLIC //
+
+// MSVC has problems expanding __LINE__ so used (the non standard) __COUNTER__.
+#ifdef BOOST_MSVC
+# define BOOST_CLOSURE_DETAIL_PP_LINE_COUNTER __COUNTER__
+#else
+# define BOOST_CLOSURE_DETAIL_PP_LINE_COUNTER __LINE__
+#endif
+
+#endif // #include guard
+
Added: sandbox/closure/boost/closure/detail/preprocessor/void_list.hpp
==============================================================================
--- (empty file)
+++ sandbox/closure/boost/closure/detail/preprocessor/void_list.hpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,95 @@
+
+#ifndef BOOST_CLOSURE_DETAIL_PP_VOID_LIST_HPP_
+#define BOOST_CLOSURE_DETAIL_PP_VOID_LIST_HPP_
+
+#include <boost/closure/detail/preprocessor/keyword/void.hpp>
+#include <boost/config.hpp>
+#include <boost/preprocessor/control/iif.hpp>
+#include <boost/preprocessor/comparison/equal.hpp>
+#include <boost/preprocessor/tuple/to_list.hpp>
+#include <boost/preprocessor/seq/size.hpp>
+#include <boost/preprocessor/seq/to_tuple.hpp>
+#include <boost/preprocessor/variadic/size.hpp>
+
+// PRIVATE //
+
+// Argument: (token1)...
+#define BOOST_CLOSURE_DETAIL_PP_VOID_LIST_FROM_SEQ_(unused, seq) \
+ BOOST_PP_TUPLE_TO_LIST(BOOST_PP_SEQ_SIZE(seq), BOOST_PP_SEQ_TO_TUPLE(seq))
+
+// Token: void | token1
+#define BOOST_CLOSURE_DETAIL_PP_VOID_LIST_HANDLE_VOID_(is_void_macro, token) \
+ BOOST_PP_IIF(is_void_macro(token), \
+ BOOST_PP_NIL \
+ , \
+ (token, BOOST_PP_NIL) \
+ )
+
+// Token: (a)(b)... | empty | void | token
+#define BOOST_CLOSURE_DETAIL_PP_VOID_LIST_HANDLE_SEQ_(is_void_macro, token) \
+ BOOST_PP_IIF(BOOST_PP_IS_UNARY(token), /* unary paren (a)... */ \
+ BOOST_CLOSURE_DETAIL_PP_VOID_LIST_FROM_SEQ_ \
+ , \
+ BOOST_CLOSURE_DETAIL_PP_VOID_LIST_HANDLE_VOID_ \
+ )(is_void_macro, token)
+
+#ifdef BOOST_NO_VARIADIC_MACROS
+
+#define BOOST_CLOSURE_DETAIL_PP_VOID_LIST_(is_void_macro, seq) \
+ BOOST_CLOSURE_DETAIL_PP_VOId_LIST_HANDLE_SEQ_(is_void_macro, seq)
+
+#else // variadic
+
+// Argument: token1, ...
+#define BOOST_CLOSURE_DETAIL_PP_VOID_LIST_FROM_VARIADIC_(unused, ...) \
+ BOOST_PP_TUPLE_TO_LIST(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), (__VA_ARGS__))
+
+#define BOOST_CLOSURE_DETAIL_PP_VOID_LIST_(is_void_macro, ...) \
+ BOOST_PP_IIF(BOOST_PP_EQUAL(BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), 1), \
+ BOOST_CLOSURE_DETAIL_PP_VOID_LIST_HANDLE_SEQ_ \
+ , \
+ BOOST_CLOSURE_DETAIL_PP_VOID_LIST_FROM_VARIADIC_ \
+ )(is_void_macro, __VA_ARGS__)
+
+#endif // variadic
+
+#define BOOST_CLOSURE_DETAIL_PP_VOID_LIST_NEVER_(tokens) \
+ 0 /* void check always returns false */
+
+// PUBLIC //
+
+// NOTE: Empty list must always be represented is void (which is also a way to
+// specify no function parameter) and it can never be empty because (1)
+// IS_EMPTY(&var) fails (because of the leading non alphanumeric symbol) and
+// (2) some compilers (MSVC) fail to correctly pass empty macro parameters
+// even if they support variadic macros. Therefore, always using void to
+// represent is more portable.
+
+#ifdef BOOST_NO_VARIADIC_MACROS
+
+// Expand `void | (a)(b)...` to pp-list `NIL | (a, (b, NIL))`.
+#define BOOST_CLOSURE_DETAIL_PP_VOID_LIST(sign) \
+ BOOST_CLOSURE_DETAIL_PP_VOID_LIST_( \
+ BOOST_CLOSURE_DETAIL_PP_KEYWORD_IS_VOID_BACK, sign)
+
+// Expand `(a)(b)...` to pp-list `(a, (b, NIL))`.
+#define BOOST_CLOSURE_DETAIL_PP_NON_VOID_LIST(seq) \
+ BOOST_CLOSURE_DETAIL_PP_VOID_LIST_( \
+ BOOST_CLOSURE_DETAIL_PP_VOID_LIST_NEVER_, seq)
+
+#else // variadic
+
+// Expand `void | (a)(b)... | a, b, ...` to pp-list `NIL | (a, (b, NIL))`.
+#define BOOST_CLOSURE_DETAIL_PP_VOID_LIST(...) \
+ BOOST_CLOSURE_DETAIL_PP_VOID_LIST_( \
+ BOOST_CLOSURE_DETAIL_PP_KEYWORD_IS_VOID_BACK, __VA_ARGS__)
+
+// Expand `(a)(b)... | a, b, ...` to pp-list `(a, (b, NIL))`.
+#define BOOST_CLOSURE_DETAIL_PP_NON_VOID_LIST(...) \
+ BOOST_CLOSURE_DETAIL_PP_VOID_LIST_( \
+ BOOST_CLOSURE_DETAIL_PP_VOID_LIST_NEVER_, __VA_ARGS__)
+
+#endif // variadic
+
+#endif // #include guard
+
Added: sandbox/closure/libs/closure/example/function_types.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/closure/example/function_types.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,7 @@
+
+int main(void) {
+ int x
+ int BOOST_CLOSURE(
+ return 0;
+}
+
Added: sandbox/closure/libs/scope_exit/doc/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/doc/Jamfile.v2 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,34 @@
+
+# Copyright 2006 Alexander Nasonov.
+# Distributed under the Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+import quickbook ;
+using boostbook ;
+
+doxygen reference
+ :
+ ../../../boost/scope_exit.hpp
+ :
+ <doxygen:param>QUIET=YES
+ <doxygen:param>WARN_IF_UNDOCUMENTED=NO
+ <doxygen:param>HIDE_UNDOC_MEMBERS=YES
+ <doxygen:param>HIDE_UNDOC_CLASSES=YES
+ <doxygen:param>ALIASES=" Params=\"<b>Parameters:</b> <table border="0">\" Param{2}=\"<tr><td><b><tt>\\1</tt></b></td><td>\\2</td></tr>\" EndParams=\"</table>\" Returns=\"<b>Returns:</b>\" Note=\"<b>Note:</b>\" Warning=\"<b>Warning:</b>\" See=\"<b>See:</b>\" RefSect{1}=\"\\xmlonly<link linkend='scope_exit.\\1'>\\1</link>\\endxmlonly\" RefSectId{2}=\"\\xmlonly<link linkend='scope_exit.\\1'>\\2</link>\\endxmlonly\" RefClass{1}=\"\\xmlonly<computeroutput><classname alt='\\1'>\\1</classname></computeroutput>\\endxmlonly\" RefMacro{1}=\"\\xmlonly<computeroutput><macroname alt='\\1'>\\1</macroname></computeroutput>\\endxmlonly\" "
+
+ # Extract Doxygen that comments non-variant macros.
+ <doxygen:param>PREDEFINED="BOOST_LOCAL_CONFIG_COMPLIANT DOXY"
+ <reftitle>"Reference"
+ ;
+
+xml scope_exit : scope_exit.qbk :
+ <dependency>reference
+;
+
+boostbook standalone : scope_exit :
+ # Path for links to Boost:
+ <xsl:param>boost.root=../../../..
+ <xsl:param>boost.defaults=Boost
+ <format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/libs/scope_exit/doc/html
+;
+
Added: sandbox/closure/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT.html
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT.html 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,97 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Macro BOOST_SCOPE_EXIT</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="up" href="reference.html#header.boost.scope_exit_hpp" title="Header <boost/scope_exit.hpp>">
+<link rel="prev" href="reference.html" title="Reference">
+<link rel="next" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">
+</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="reference.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.scope_exit_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_SCOPE_EXIT_TPL.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="refentry">
+<a name="BOOST_SCOPE_EXIT"></a><div class="titlepage"></div>
+<div class="refnamediv">
+<h2><span class="refentrytitle">Macro BOOST_SCOPE_EXIT</span></h2>
+<p>BOOST_SCOPE_EXIT — This macro declares a scope exit. </p>
+</div>
+<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
+<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="reference.html#header.boost.scope_exit_hpp" title="Header <boost/scope_exit.hpp>">boost/scope_exit.hpp</a>>
+
+</span>BOOST_SCOPE_EXIT(capture_list)</pre></div>
+<div class="refsect1">
+<a name="id813915"></a><h2>Description</h2>
+<p>The scope exit declaration schedules the execution of the scope exit body at the exit of the enclosing scope:</p>
+<pre class="programlisting"> <span class="special">{</span> <span class="comment">// Some local scope.</span>
+ <span class="special">...</span>
+ <span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span><span class="identifier">capture_list</span><span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</span> <span class="comment">// Body code.</span>
+ <span class="special">}</span> <span class="identifier">BOOST_SCOPE_EXIT_END</span>
+ <span class="special">...</span>
+ <span class="special">}</span>
+</pre>
+<p>The enclosing scope must be local. If multiple scope exits are declared within the same enclosing scope, the scope exit bodies are executed in the reversed order of their declarations. Note how the end of the scope exit body must be marked with the <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</a></code> (or with a <code class="computeroutput">;</code> but only on C++11).</p>
+<p><span class="bold"><strong>Parameters:</strong></span> </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<tbody><tr>
+<td><span class="bold"><strong><code class="computeroutput">capture_list</code></strong></span></td>
+<td>On compilers that support variadic macros, the capture list syntax is defined by the following grammar: <pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"> <span class="identifier">capture_list</span><span class="special">:</span>
+ <span class="keyword">void</span> <span class="special">|</span> <span class="identifier">capture_tuple</span> <span class="special">|</span> <span class="identifier">capture_sequence</span>
+ <span class="identifier">capture_tuple</span><span class="special">:</span>
+ <span class="identifier">capture</span><span class="special">,</span> <span class="identifier">capture</span><span class="special">,</span> <span class="special">...</span>
+ <span class="identifier">capture_sequence</span><span class="special">:</span>
+ <span class="special">(</span><span class="identifier">capture</span><span class="special">)</span> <span class="special">(</span><span class="identifier">capture</span><span class="special">)</span> <span class="special">...</span>
+ <span class="identifier">capture</span><span class="special">:</span>
+ <span class="special">[</span><span class="special">&</span><span class="special">]</span><span class="identifier">variable</span> <span class="special">|</span> <span class="identifier">this_</span>
+</pre> On compilers that do not support variadic macros, <code class="computeroutput">capture_tuple</code> cannot be used: <pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"> <span class="identifier">capture_list</span><span class="special">:</span>
+ <span class="keyword">void</span> <span class="special">|</span> <span class="identifier">capture_sequence</span>
+</pre> Finally, on C++11 compilers <code class="computeroutput">this</code> can be used instead of <code class="computeroutput">this_</code>: <pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"> <span class="identifier">capture</span><span class="special">:</span>
+ <span class="special">[</span><span class="special">&</span><span class="special">]</span><span class="identifier">variable</span> <span class="special">|</span> <span class="identifier">this_</span> <span class="special">|</span> <span class="keyword">this</span>
+</pre> </td>
+</tr></tbody>
+</table></div>
+<p>
+</p>
+<p>Note that on compilers with variadic macro support (most of moder compliers and all C++11 compilers), the capture list can be specified as a comma-separated list of tokens. On all compilers, the same macro <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> also allows to specify the capture list as a Boost.Preprocessor sequence of tokens (for supporting compilers without variadic macros and for backward compatibility with older versions of this library).</p>
+<p>The name <code class="computeroutput">variable</code> of each captured variable must be a valid name in the enclosing scope and it must appear exactly once in the capture list. If a capture starts with the ampersand sign <code class="computeroutput">&</code>, the corresponding variable will be available by reference within the scope exit body; otherwise, a copy of the variable will be made at the point of the scope exit declaration and that copy will be available inside the scope exit body (in this case, the variable's type must be <code class="computeroutput">CopyConstructible</code>).</p>
+<p>From within a member function, the object <code class="computeroutput">this</code> can be captured using the special symbol <code class="computeroutput">this_</code> in both the capture list and the scope exit body (using <code class="computeroutput">this</code> instead of <code class="computeroutput">this_</code> in the scope exit body leads to undefined behaviour). On C++11 it is possible (but not required) to use <code class="computeroutput">this</code> instead of <code class="computeroutput">this_</code>.</p>
+<p>It is possible to capture no variable by specifying the capture list as <code class="computeroutput">void</code> (regardless of variadic macro support).</p>
+<p>Only variables listed in the capture list, static variables, <code class="computeroutput">extern</code> variables, global variables, functions, and enumerations from the enclosing scope can be used inside the scope exit body.</p>
+<p><span class="bold"><strong>Warning:</strong></span> The implementation executes the scope exit body within a destructor thus the scope exit body must never throw in order to comply with STL exception safety requirements.</p>
+<p><span class="bold"><strong>Note:</strong></span> The implementation uses Boost.Typeof to automatically deduce the types of the captured variables. In order to compile code in typeof-emulation mode, Boost.Typeof must be properly configured (see the <a class="link" href="scope_exit/Getting_Started.html" title="Getting Started"> Getting Started</a> section).</p>
+<p><span class="bold"><strong>Note:</strong></span> On various GCC versions the special macro <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code> must be used instead of <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> within templates (this is not necessary on C++11).</p>
+<p><span class="bold"><strong>Note:</strong></span> On C++11, it is possible capture all variables in scope without listing their names using the macro <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code>.</p>
+<p><span class="bold"><strong>See:</strong></span> <a class="link" href="scope_exit/Tutorial.html" title="Tutorial">Tutorial</a> section, <a class="link" href="scope_exit/Getting_Started.html" title="Getting Started"> Getting Started</a> section, <a class="link" href="scope_exit/No_Variadic_Macros.html" title="Annex: No Variadic Macros"> No Variadic Macros</a> section, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code>, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code>, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</a></code>. </p>
+</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-2012 Alexander Nasonov, Lorenzo Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="reference.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.scope_exit_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_SCOPE_EXIT_TPL.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
Added: sandbox/closure/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ALL.html
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ALL.html 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,91 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Macro BOOST_SCOPE_EXIT_ALL</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="up" href="reference.html#header.boost.scope_exit_hpp" title="Header <boost/scope_exit.hpp>">
+<link rel="prev" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">
+<link rel="next" href="BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">
+</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="BOOST_SCOPE_EXIT_TPL.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.scope_exit_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_SCOPE_EXIT_END.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="refentry">
+<a name="BOOST_SCOPE_EXIT_ALL"></a><div class="titlepage"></div>
+<div class="refnamediv">
+<h2><span class="refentrytitle">Macro BOOST_SCOPE_EXIT_ALL</span></h2>
+<p>BOOST_SCOPE_EXIT_ALL — This macro declares a scope exit that captures all variables in scope (C++11 only). </p>
+</div>
+<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
+<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="reference.html#header.boost.scope_exit_hpp" title="Header <boost/scope_exit.hpp>">boost/scope_exit.hpp</a>>
+
+</span>BOOST_SCOPE_EXIT_ALL(capture_list)</pre></div>
+<div class="refsect1">
+<a name="id816066"></a><h2>Description</h2>
+<p><span class="bold"><strong>Warning:</strong></span> This macro is only available on C++11 compilers. It is not defined on non-C++11 compilers so its use on non-C++11 compilers will generate a compiler error.</p>
+<pre class="programlisting"> <span class="special">{</span> <span class="comment">// Some local scope.</span>
+ <span class="special">...</span>
+ <span class="identifier">BOOST_SCOPE_EXIT_ALL</span><span class="special">(</span><span class="identifier">capture_list</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// C++11 only.</span>
+ <span class="special">...</span> <span class="comment">// Body code.</span>
+ <span class="special">}</span><span class="special">;</span> <span class="comment">// Use `;` instead of `BOOST_SCOPE_EXIT_END` (C++11 only).</span>
+ <span class="special">...</span>
+ <span class="special">}</span>
+</pre>
+<p>This macro accepts a capture list starting with either <code class="computeroutput">&</code> or <code class="computeroutput">=</code> to capture all variables in scope by reference or value respectively (following the same syntax of C++11 lambdas). A part from that, this macro works like <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> (see <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> for more information).</p>
+<p><span class="bold"><strong>Parameters:</strong></span> </p>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<tbody><tr>
+<td><span class="bold"><strong><code class="computeroutput">capture_list</code></strong></span></td>
+<td>
+<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">capture_list</span><span class="special">:</span>
+ <span class="identifier">capture_tuple</span> <span class="special">|</span> <span class="identifier">capture_sequence</span>
+<span class="identifier">capture_tuple</span><span class="special">:</span>
+ <span class="special">{</span><span class="special">&</span> <span class="special">|</span> <span class="special">=</span><span class="special">}</span> <span class="special">[</span><span class="special">,</span> <span class="identifier">capture</span><span class="special">,</span> <span class="identifier">capture</span><span class="special">,</span> <span class="special">...</span><span class="special">]</span>
+<span class="identifier">capture_sequence</span><span class="special">:</span>
+ <span class="special">{</span><span class="special">(</span><span class="special">&</span><span class="special">)</span> <span class="special">|</span> <span class="special">(</span><span class="special">=</span><span class="special">)</span><span class="special">}</span> <span class="special">[</span><span class="special">(</span><span class="identifier">capture</span><span class="special">)</span> <span class="special">(</span><span class="identifier">capture</span><span class="special">)</span> <span class="special">...</span><span class="special">]</span>
+<span class="identifier">capture</span><span class="special">:</span>
+ <span class="special">[</span><span class="special">&</span><span class="special">]</span><span class="identifier">variable</span> <span class="special">|</span> <span class="identifier">this_</span> <span class="special">|</span> <span class="keyword">this</span>
+</pre> </td>
+</tr></tbody>
+</table></div>
+<p>
+</p>
+<p>Note that on compilers with variadic macro support (which should be all C++11 compilers), the capture list can be specified as a comma-separated list. On all compilers, the same macro <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code> also allows to specify the capture list as a Boost.Preprocessor sequence (to allow to use a syntax consistent with the one of <code class="computeroutput">BOOST_SCOPE_EXIT</code> when used on compilers without variadic macro support).</p>
+<p>For this macro, the capture list must always contain at least the leading <code class="computeroutput">&</code> or <code class="computeroutput">=</code> so it can never be <code class="computeroutput">void</code>.</p>
+<p>The scope exit body declared by this macro can be terminated equivalently by either a semi-column <code class="computeroutput">;</code> or by the macro <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</a></code>. The <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code> macro is only available on C++11 where the terminating semi-column <code class="computeroutput">;</code> can always be used without worrying about portability with C++03 (see <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</a></code> for more information).</p>
+<p>Similarly, this macro can always use <code class="computeroutput">this</code> instead of <code class="computeroutput">this_</code> to capture the enclosing object without worrying about portability with C++03 because this macro is only available on C++11 compilers.</p>
+<p><span class="bold"><strong>Note:</strong></span> In summary, this macro can take advantage of all syntax improvements allowed by C++11 but it optionally supports the same syntax required by C++03 so programmers can always program both <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code> and <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> using the same syntax and for all compilers if they wish to do so.</p>
+<p><span class="bold"><strong>Warning:</strong></span> The implementation executes the scope exit body within a destructor thus the scope exit body must never throw in order to comply with STL exception safety requirements.</p>
+<p><span class="bold"><strong>See:</strong></span> <a class="link" href="scope_exit/Tutorial.html" title="Tutorial">Tutorial</a> section, <a class="link" href="scope_exit/No_Variadic_Macros.html" title="Annex: No Variadic Macros"> No Variadic Macros</a> section, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code>, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</a></code>. </p>
+</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-2012 Alexander Nasonov, Lorenzo Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_SCOPE_EXIT_TPL.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.scope_exit_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_SCOPE_EXIT_END.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
Added: sandbox/closure/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_CONFIG_NO_CPP11.html
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_CONFIG_NO_CPP11.html 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,55 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Macro BOOST_SCOPE_EXIT_CONFIG_NO_CPP11</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="up" href="reference.html#header.boost.scope_exit_hpp" title="Header <boost/scope_exit.hpp>">
+<link rel="prev" href="BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">
+<link rel="next" href="scope_exit/acknowledgements.html" title="Acknowledgements">
+</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="BOOST_SCOPE_EXIT_END.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.scope_exit_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="scope_exit/acknowledgements.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="refentry">
+<a name="BOOST_SCOPE_EXIT_CONFIG_NO_CPP11"></a><div class="titlepage"></div>
+<div class="refnamediv">
+<h2><span class="refentrytitle">Macro BOOST_SCOPE_EXIT_CONFIG_NO_CPP11</span></h2>
+<p>BOOST_SCOPE_EXIT_CONFIG_NO_CPP11 — Force to not use C++11 features. </p>
+</div>
+<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
+<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="reference.html#header.boost.scope_exit_hpp" title="Header <boost/scope_exit.hpp>">boost/scope_exit.hpp</a>>
+
+</span>BOOST_SCOPE_EXIT_CONFIG_NO_CPP11</pre></div>
+<div class="refsect1">
+<a name="id816805"></a><h2>Description</h2>
+<p>If programmers define this configuration macro, C++11 features will not be used even on C++11 compilers (only C++03 features will be used). By default this macro is not defined.</p>
+<p><span class="bold"><strong>Note:</strong></span> This macro does not disable comma-separated capture lists on compilers that support variadic macros (programmers can simply use Boost.Preprocessor sequences if they do not wish to use comma-separated capture lists).</p>
+<p><span class="bold"><strong>See:</strong></span> <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code>, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code>, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</a></code>. </p>
+</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-2012 Alexander Nasonov, Lorenzo Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_SCOPE_EXIT_END.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.scope_exit_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="scope_exit/acknowledgements.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
Added: sandbox/closure/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_END.html
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_END.html 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,72 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Macro BOOST_SCOPE_EXIT_END</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="up" href="reference.html#header.boost.scope_exit_hpp" title="Header <boost/scope_exit.hpp>">
+<link rel="prev" href="BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">
+<link rel="next" href="BOOST_SCOPE_EXIT_CONFIG_NO_CPP11.html" title="Macro BOOST_SCOPE_EXIT_CONFIG_NO_CPP11">
+</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="BOOST_SCOPE_EXIT_ALL.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.scope_exit_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_SCOPE_EXIT_CONFIG_NO_CPP11.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="refentry">
+<a name="BOOST_SCOPE_EXIT_END"></a><div class="titlepage"></div>
+<div class="refnamediv">
+<h2><span class="refentrytitle">Macro BOOST_SCOPE_EXIT_END</span></h2>
+<p>BOOST_SCOPE_EXIT_END — This macro marks the end of a scope exit body. </p>
+</div>
+<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
+<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="reference.html#header.boost.scope_exit_hpp" title="Header <boost/scope_exit.hpp>">boost/scope_exit.hpp</a>>
+
+</span>BOOST_SCOPE_EXIT_END</pre></div>
+<div class="refsect1">
+<a name="id816580"></a><h2>Description</h2>
+<p>This macro must follow the closing curly bracket <code class="computeroutput">}</code> that ends the scope exit body:</p>
+<pre class="programlisting"> <span class="special">{</span> <span class="comment">// Some local scope.</span>
+ <span class="special">...</span>
+ <span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span><span class="identifier">capture_list</span><span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</span> <span class="comment">// Body code.</span>
+ <span class="special">}</span> <span class="identifier">BOOST_SCOPE_EXIT_END</span>
+ <span class="special">...</span>
+ <span class="special">}</span>
+</pre>
+<p>On C++11, this macro is not necessary and it can be replaced by a semi-column <code class="computeroutput">;</code> </p>
+<pre class="programlisting"> <span class="special">{</span> <span class="comment">// Some local scope.</span>
+ <span class="special">...</span>
+ <span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span><span class="identifier">capture_list</span><span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</span> <span class="comment">// Body code.</span>
+ <span class="special">}</span><span class="special">;</span> <span class="comment">// C++11 only.</span>
+ <span class="special">...</span>
+ <span class="special">}</span>
+</pre>
+<p> However, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</a></code> is still provided on C++11 so to write code that is portable between C++03 and C++11 compilers.</p>
+<p><span class="bold"><strong>See:</strong></span> <a class="link" href="scope_exit/Tutorial.html" title="Tutorial">Tutorial</a> section, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code>, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code>, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code>. </p>
+</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-2012 Alexander Nasonov, Lorenzo Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_SCOPE_EXIT_ALL.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.scope_exit_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_SCOPE_EXIT_CONFIG_NO_CPP11.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
Added: sandbox/closure/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_TPL.html
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_TPL.html 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,80 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Macro BOOST_SCOPE_EXIT_TPL</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="up" href="reference.html#header.boost.scope_exit_hpp" title="Header <boost/scope_exit.hpp>">
+<link rel="prev" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">
+<link rel="next" href="BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">
+</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="BOOST_SCOPE_EXIT.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.scope_exit_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_SCOPE_EXIT_ALL.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="refentry">
+<a name="BOOST_SCOPE_EXIT_TPL"></a><div class="titlepage"></div>
+<div class="refnamediv">
+<h2><span class="refentrytitle">Macro BOOST_SCOPE_EXIT_TPL</span></h2>
+<p>BOOST_SCOPE_EXIT_TPL — This macro is a workaround to declare a scope exit for various versions of GCC. </p>
+</div>
+<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
+<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="reference.html#header.boost.scope_exit_hpp" title="Header <boost/scope_exit.hpp>">boost/scope_exit.hpp</a>>
+
+</span>BOOST_SCOPE_EXIT_TPL(capture_list)</pre></div>
+<div class="refsect1">
+<a name="id814451"></a><h2>Description</h2>
+<p>Various versions of the GCC compiler do not compile <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> inside function templates. As a workaround, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code> should be used instead of <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> in these cases:</p>
+<pre class="programlisting"> <span class="special">{</span> <span class="comment">// Some local scope.</span>
+ <span class="special">...</span>
+ <span class="identifier">BOOST_SCOPE_EXIT_TPL</span><span class="special">(</span><span class="identifier">capture_list</span><span class="special">)</span> <span class="special">{</span>
+ <span class="special">...</span> <span class="comment">// Body code.</span>
+ <span class="special">}</span> <span class="identifier">BOOST_SCOPE_EXIT_END</span>
+ <span class="special">...</span>
+ <span class="special">}</span>
+</pre>
+<p>The syntax of <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code> is the exact same as the one of <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> (see <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> for more information).</p>
+<p>On C++11, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code> is not needed because <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> always compiles on GCC versions that support C++11. However, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code> is still provided on C++11 so to write code that is portable between C++03 and C++11 compilers.</p>
+<p><span class="bold"><strong>Note:</strong></span> The problem boils down to the following code (see also GCC bug 37920): </p>
+<pre class="programlisting"> <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
+ <span class="keyword">void</span> <span class="identifier">f</span><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">x</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">x</span><span class="special">)</span> <span class="identifier">typeof_x</span><span class="special">;</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_x</span> <span class="identifier">x_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="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">f</span><span class="special">(</span><span class="number">0</span><span class="special">)</span><span class="special">;</span> <span class="special">}</span>
+</pre>
+<p> This can be fixed by adding <code class="computeroutput">typename</code> in front of <code class="computeroutput">local::typeof_i</code> and <code class="computeroutput">local::typeof_x</code> (which is the approach followed by the implementation of <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code>).</p>
+<p><span class="bold"><strong>Note:</strong></span> Although <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code> has the same suffix as <code class="computeroutput">BOOST_TYPEOF_TPL</code>, it does not follow the Boost.Typeof convention.</p>
+<p><span class="bold"><strong>See:</strong></span> <a class="link" href="scope_exit/Tutorial.html" title="Tutorial">Tutorial</a> section, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code>, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</a></code>. </p>
+</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-2012 Alexander Nasonov, Lorenzo Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="BOOST_SCOPE_EXIT.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="reference.html#header.boost.scope_exit_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_SCOPE_EXIT_ALL.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
Added: sandbox/closure/libs/scope_exit/doc/html/index.html
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/doc/html/index.html 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,149 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Chapter 1. Boost.ScopeExit 1.1.0</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="next" href="scope_exit/Getting_Started.html" title="Getting Started">
+</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/Getting_Started.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
+<div class="chapter">
+<div class="titlepage"><div>
+<div><h2 class="title">
+<a name="scope_exit"></a>Chapter 1. Boost.ScopeExit 1.1.0</h2></div>
+<div><div class="author"><h3 class="author">
+<span class="firstname">Alexander</span> <span class="surname">Nasonov</span>
+</h3></div></div>
+<div><div class="author"><h3 class="author">
+<span class="firstname">Lorenzo</span> <span class="surname">Caminiti</span>
+</h3></div></div>
+<div><p class="copyright">Copyright © 2006-2012 Alexander Nasonov, Lorenzo Caminiti</p></div>
+<div><div class="legalnotice">
+<a name="scope_exit.legal"></a><p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </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">Getting Started</span></dt>
+<dd><dl>
+<dt><span class="section"><a href="scope_exit/Getting_Started.html#scope_exit.Getting_Started.compilers_and_platforms">Compilers
+ and Platforms</a></span></dt>
+<dt><span class="section">Installation</span></dt>
+</dl></dd>
+<dt><span class="section">Tutorial</span></dt>
+<dd><dl>
+<dt><span class="section">Capturing Variables</span></dt>
+<dt><span class="section"><a href="scope_exit/Tutorial.html#scope_exit.Tutorial.capturing_the_object__this_">Capturing
+ The Object <code class="computeroutput"><span class="keyword">this</span></code></a></span></dt>
+<dt><span class="section"><a href="scope_exit/Tutorial.html#scope_exit.Tutorial.capturing_no_variable">Capturing
+ No Variable</a></span></dt>
+<dt><span class="section"><a href="scope_exit/Tutorial.html#scope_exit.Tutorial.capturing_all_variables__c__11_only_">Capturing
+ All Variables (C++11 Only)</a></span></dt>
+<dt><span class="section"><a href="scope_exit/Tutorial.html#scope_exit.Tutorial.gcc_template_workaround">GCC Template
+ Workaround</a></span></dt>
+</dl></dd>
+<dt><span class="section">Annex: Alternatives</span></dt>
+<dd><dl>
+<dt><span class="section">Try-Catch</span></dt>
+<dt><span class="section">RAII</span></dt>
+<dt><span class="section">Scope Guards</span></dt>
+<dt><span class="section"><a href="scope_exit/annex__alternatives.html#scope_exit.annex__alternatives.the_d_programming_language">The
+ D Programming Language</a></span></dt>
+<dt><span class="section">C++11 Lambdas</span></dt>
+</dl></dd>
+<dt><span class="section">Annex: No Variadic Macros</span></dt>
+<dd><dl>
+<dt><span class="section"><a href="scope_exit/No_Variadic_Macros.html#scope_exit.No_Variadic_Macros.sequence_syntax">Sequence
+ Syntax</a></span></dt>
+<dt><span class="section">Examples</span></dt>
+</dl></dd>
+<dt><span class="section">Reference</span></dt>
+<dd><dl><dt><span class="section">Header <boost/scope_exit.hpp></span></dt></dl></dd>
+<dt><span class="section">Acknowledgements</span></dt>
+</dl>
+</div>
+<p>
+ <span class="emphasis"><em> Alexander Nasonov is the original author. Lorenzo Caminiti added support
+ for variadic macros, capture of <code class="computeroutput"><span class="identifier">this_</span></code>,
+ no captures, and <code class="computeroutput"><span class="identifier">BOOST_SCOPE_EXIT_ALL</span></code>.
+ </em></span>
+ </p>
+<p>
+ This library allows to execute arbitrary code when the enclosing scope exits.
+ </p>
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="scope_exit.intro"></a><a class="link" href="index.html#scope_exit.intro" title="Introduction">Introduction</a>
+</h2></div></div></div>
+<p>
+ Nowadays, every C++ developer is familiar with the 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 the <a class="link" href="index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a> library comes
+ into play. Programmers can put resource acquisition directly in their code
+ and next to it, they can write code that releases the resource using this library.
+ For example: <sup>[<a name="scope_exit.intro.f0" href="#ftn.scope_exit.intro.f0" class="footnote">1</a>]</sup>
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">world</span><span class="special">::</span><span class="identifier">add_person</span><span class="special">(</span><span class="identifier">person</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a_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">persons_</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">a_person</span><span class="special">);</span> <span class="comment">// (1) direct action</span>
+ <span class="comment">// Following block is executed when the enclosing scope exits.</span>
+ <span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(&</span><span class="identifier">commit</span><span class="special">,</span> <span class="special">&</span><span class="identifier">persons_</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">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) disable rollback actions</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ Read the <a class="link" href="scope_exit/Tutorial.html" title="Tutorial">Tutorial</a> section to find
+ out how to write programs with <a class="link" href="index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a>
+ or jump to the Reference section.
+ </p>
+</div>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a id="ftn.scope_exit.intro.f0" href="#scope_exit.intro.f0" class="para">1</a>] </sup>
+ Older versions of this library used a <a href="../../../../libs/preprocessor/index.html" target="_top">Boost.Preprocessor
+ sequence</a> to specify the list of captured variable. While maintaining
+ full backward compatibility, it is now also possible to specify the captured
+ variables as a comma-separated list (which is the preferred syntax). See
+ the <a class="link" href="scope_exit/No_Variadic_Macros.html" title="Annex: No Variadic Macros">No Variadic Macros</a>
+ section for more details.
+ </p></div>
+</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 13, 2012 at 16:41:25 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/Getting_Started.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a></div>
+</body>
+</html>
Added: sandbox/closure/libs/scope_exit/doc/html/reference.html
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/doc/html/reference.html 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,55 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Reference</title>
+<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="up" href="index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="prev" href="scope_exit/No_Variadic_Macros.html" title="Annex: No Variadic Macros">
+<link rel="next" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">
+</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="scope_exit/No_Variadic_Macros.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_SCOPE_EXIT.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="reference"></a>Reference</h2></div></div></div>
+<div class="toc"><dl><dt><span class="section">Header <boost/scope_exit.hpp></span></dt></dl></div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="header.boost.scope_exit_hpp"></a>Header <boost/scope_exit.hpp></h3></div></div></div>
+<p>Scope exits allow to execute arbitrary code when the enclosing scope exits. </p>
+<pre class="synopsis">
+
+<a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a>(capture_list)
+<a class="link" href="BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a>(capture_list)
+<a class="link" href="BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a>(capture_list)
+<a class="link" href="BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</a>
+<a class="link" href="BOOST_SCOPE_EXIT_CONFIG_NO_CPP11.html" title="Macro BOOST_SCOPE_EXIT_CONFIG_NO_CPP11">BOOST_SCOPE_EXIT_CONFIG_NO_CPP11</a></pre>
+</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-2012 Alexander Nasonov, Lorenzo Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="scope_exit/No_Variadic_Macros.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="BOOST_SCOPE_EXIT.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
Added: sandbox/closure/libs/scope_exit/doc/html/scope_exit/Getting_Started.html
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/doc/html/scope_exit/Getting_Started.html 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,112 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Getting Started</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="prev" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="next" href="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="p" href="../index.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Tutorial.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="scope_exit.Getting_Started"></a><a class="link" href="Getting_Started.html" title="Getting Started">Getting Started</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="Getting_Started.html#scope_exit.Getting_Started.compilers_and_platforms">Compilers
+ and Platforms</a></span></dt>
+<dt><span class="section">Installation</span></dt>
+</dl></div>
+<p>
+ This section explains how to setup your system to use this library.
+ </p>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="scope_exit.Getting_Started.compilers_and_platforms"></a><a class="link" href="Getting_Started.html#scope_exit.Getting_Started.compilers_and_platforms" title="Compilers and Platforms">Compilers
+ and Platforms</a>
+</h3></div></div></div>
+<p>
+ The library should be usable on any compiler that supports Boost.Typeof
+ except:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ MSVC 7.1 and 8.0 fail to link if a function with <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a>
+ is included by multiple translation units.
+ </li>
+<li class="listitem">
+ GCC 3.3 cannot compile <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a> inside
+ a template (see http://lists.boost.org/Archives/boost/2007/02/116235.php
+ for more details).
+ </li>
+</ul></div>
+<p>
+ The authors tested the library on GCC 3.3, 3.4, 4.1, 4.2, 4.5.3 (with and
+ without C++11 features <code class="literal">-std=c++0x</code>), MSVC 8.0, and Intel
+ 10.1 under Linux, Cygwin, and Windows 7.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="scope_exit.Getting_Started.installation"></a><a class="link" href="Getting_Started.html#scope_exit.Getting_Started.installation" title="Installation">Installation</a>
+</h3></div></div></div>
+<p>
+ This library is composed of header files only. Therefore there is no pre-compiled
+ object file which needs to be installed. Programmers can simply instruct
+ the compiler where to find the library header files (<code class="computeroutput"><span class="special">-</span><span class="identifier">I</span></code> option on GCC, <code class="computeroutput"><span class="special">/</span><span class="identifier">I</span></code> option on MSVC, etc) and compile code
+ using the library.
+ </p>
+<p>
+ The library implementation uses Boost.Typeof
+ to automatically deduce the types of the <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a>
+ captured variables (see the <a class="link" href="Tutorial.html" title="Tutorial">Tutorial</a>
+ section). In order to compile code in <a href="../../../../../libs/typeof/index.html" target="_top">typeof
+ emulation</a> mode, all types should be properly registered with BOOST_TYPEOF_REGISTER_TYPE
+ or BOOST_TYPEOF_REGISTER_TEMPLATE
+ macros, or appropriate Boost.Typeof
+ headers should be included.
+ </p>
+<p>
+ When using comma-separated lists to specify captures (see the <a class="link" href="No_Variadic_Macros.html" title="Annex: No Variadic Macros">No
+ Variadic Macros</a> section), make sure that the <code class="computeroutput"><span class="identifier">BOOST_PP_VARIADICS</span></code>
+ macro is defined (either automatically by Boost.Preprocessor
+ or manually using your compiler options <code class="computeroutput"><span class="special">-</span><span class="identifier">D</span></code>, <code class="computeroutput"><span class="special">/</span><span class="identifier">D</span></code>, etc). <sup>[<a name="scope_exit.Getting_Started.installation.f0" href="#ftn.scope_exit.Getting_Started.installation.f0" class="footnote">2</a>]</sup>
+ </p>
+</div>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a id="ftn.scope_exit.Getting_Started.installation.f0" href="#scope_exit.Getting_Started.installation.f0" class="para">2</a>] </sup>
+ It is not sufficient for the <code class="computeroutput"><span class="identifier">BOOST_NO_VARIADIC_MACROS</span></code>
+ macro to be undefined, the <code class="computeroutput"><span class="identifier">BOOST_PP_VARIADICS</span></code>
+ macro must be defined.
+ </p></div>
+</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-2012 Alexander Nasonov, Lorenzo Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="../index.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="Tutorial.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
Added: sandbox/closure/libs/scope_exit/doc/html/scope_exit/No_Variadic_Macros.html
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/doc/html/scope_exit/No_Variadic_Macros.html 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,180 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Annex: No Variadic Macros</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="prev" href="annex__alternatives.html" title="Annex: Alternatives">
+<link rel="next" href="../reference.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="annex__alternatives.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="scope_exit.No_Variadic_Macros"></a><a class="link" href="No_Variadic_Macros.html" title="Annex: No Variadic Macros">Annex: No Variadic Macros</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="No_Variadic_Macros.html#scope_exit.No_Variadic_Macros.sequence_syntax">Sequence
+ Syntax</a></span></dt>
+<dt><span class="section">Examples</span></dt>
+</dl></div>
+<p>
+ This section presents an alternative syntax for compilers without variadic
+ macro support.
+ </p>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="scope_exit.No_Variadic_Macros.sequence_syntax"></a><a class="link" href="No_Variadic_Macros.html#scope_exit.No_Variadic_Macros.sequence_syntax" title="Sequence Syntax">Sequence
+ Syntax</a>
+</h3></div></div></div>
+<p>
+ Most modern compilers support variadic macros (notably, these include GCC,
+ MSVC, and all C++11 compilers). However, in the rare case that programmers
+ need to use <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a> on a complier that
+ does not support variaidc macros, this library also allows to specify the
+ capture list using a <a href="../../../../../libs/preprocessor/index.html" target="_top">Boost.Preprocessor
+ sequence</a>:
+ </p>
+<pre class="programlisting"><span class="special">(</span><span class="identifier">capture1</span><span class="special">)</span> <span class="special">(</span><span class="identifier">capture2</span><span class="special">)</span> <span class="special">...</span>
+</pre>
+<p>
+ Instead of a comma-separated list:
+ </p>
+<pre class="programlisting"><span class="identifier">capture1</span><span class="special">,</span> <span class="identifier">capture2</span><span class="special">,</span> <span class="special">...</span>
+</pre>
+<p>
+ For example, the following syntax is accepted on all compilers with and without
+ variadic macro support (see also "world_seq.cpp"):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">world</span><span class="special">::</span><span class="identifier">add_person</span><span class="special">(</span><span class="identifier">person</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a_person</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">persons_</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">a_person</span><span class="special">);</span>
+
+ <span class="comment">// This block must be no-throw.</span>
+ <span class="identifier">person</span><span class="special">&</span> <span class="identifier">p</span> <span class="special">=</span> <span class="identifier">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">p</span><span class="special">.</span><span class="identifier">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">)</span> <span class="special">(&</span><span class="identifier">p</span><span class="special">)</span> <span class="special">(&</span><span class="identifier">persons_</span><span class="special">)</span> <span class="special">)</span> <span class="special">{</span> <span class="comment">// Sequence, not commas.</span>
+ <span class="keyword">if</span><span class="special">(</span><span class="identifier">checkpoint</span> <span class="special">==</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">)</span> <span class="identifier">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">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">;</span>
+
+ <span class="comment">// Assign new identifier 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">p</span><span class="special">.</span><span class="identifier">id_</span><span class="special">;</span>
+ <span class="identifier">p</span><span class="special">.</span><span class="identifier">id_</span> <span class="special">=</span> <span class="identifier">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">)</span> <span class="special">(&</span><span class="identifier">p</span><span class="special">)</span> <span class="special">(&</span><span class="identifier">next_id_</span><span class="special">)</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">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">next_id_</span> <span class="special">=</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">id_</span><span class="special">;</span>
+ <span class="identifier">p</span><span class="special">.</span><span class="identifier">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">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ Furthermore, older versions of this library used to only support the Boost.Preprocessor sequence
+ syntax so the above syntax is also supported for backward compatibility.
+ However, in the current version of this library and on compilers with variadic
+ macro support, the following syntax is preferred (see also "world.cpp"):
+ <sup>[<a name="scope_exit.No_Variadic_Macros.sequence_syntax.f0" href="#ftn.scope_exit.No_Variadic_Macros.sequence_syntax.f0" class="footnote">8</a>]</sup>
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">world</span><span class="special">::</span><span class="identifier">add_person</span><span class="special">(</span><span class="identifier">person</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a_person</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">persons_</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">a_person</span><span class="special">);</span>
+
+ <span class="comment">// This block must be no-throw.</span>
+ <span class="identifier">person</span><span class="special">&</span> <span class="identifier">p</span> <span class="special">=</span> <span class="identifier">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">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">;</span>
+ <span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span><span class="identifier">checkpoint</span><span class="special">,</span> <span class="special">&</span><span class="identifier">p</span><span class="special">,</span> <span class="special">&</span><span class="identifier">persons_</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">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">)</span> <span class="identifier">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">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">;</span>
+
+ <span class="comment">// Assign new identifier 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">p</span><span class="special">.</span><span class="identifier">id_</span><span class="special">;</span>
+ <span class="identifier">p</span><span class="special">.</span><span class="identifier">id_</span> <span class="special">=</span> <span class="identifier">next_id_</span><span class="special">++;</span>
+ <span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span><span class="identifier">checkpoint</span><span class="special">,</span> <span class="special">&</span><span class="identifier">p</span><span class="special">,</span> <span class="special">&</span><span class="identifier">next_id_</span><span class="special">,</span> <span class="identifier">prev_id</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">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">next_id_</span> <span class="special">=</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">id_</span><span class="special">;</span>
+ <span class="identifier">p</span><span class="special">.</span><span class="identifier">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">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ An empty capture list is always specified using <code class="computeroutput"><span class="keyword">void</span></code>
+ on compilers with and without variaidc macro support.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="scope_exit.No_Variadic_Macros.examples"></a><a class="link" href="No_Variadic_Macros.html#scope_exit.No_Variadic_Macros.examples" title="Examples">Examples</a>
+</h3></div></div></div>
+<p>
+ The following is a list of most of the examples presented in this documentation
+ reprogrammed using the <a href="../../../../../libs/preprocessor/index.html" target="_top">Boost.Preprocessor
+ sequence</a> syntax instead of comma-separated lists: "world_commit_seq.cpp",
+ "world_commit_this_seq.cpp",
+ "world_all_seq.cpp",
+ "world_commit_tpl_seq.cpp",
+ "try_catch_seq.cpp",
+ "scope_guard_seq.cpp".
+ </p>
+</div>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a id="ftn.scope_exit.No_Variadic_Macros.sequence_syntax.f0" href="#scope_exit.No_Variadic_Macros.sequence_syntax.f0" class="para">8</a>] </sup>
+ Note that on compilers with variadic macro support, the same <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> macro accepts both
+ a comma-separated list and a <a href="../../../../../libs/preprocessor/index.html" target="_top">Boost.Preprocessor
+ sequence</a> for specifying the capture list. The same it true also
+ for the <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code>
+ and <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code>
+ macros.
+ </p></div>
+</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-2012 Alexander Nasonov, Lorenzo Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="annex__alternatives.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
Added: sandbox/closure/libs/scope_exit/doc/html/scope_exit/Tutorial.html
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/doc/html/scope_exit/Tutorial.html 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,439 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Tutorial</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="prev" href="Getting_Started.html" title="Getting Started">
+<link rel="next" href="annex__alternatives.html" title="Annex: 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="Getting_Started.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="annex__alternatives.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="scope_exit.Tutorial"></a><a class="link" href="Tutorial.html" title="Tutorial">Tutorial</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section">Capturing Variables</span></dt>
+<dt><span class="section"><a href="Tutorial.html#scope_exit.Tutorial.capturing_the_object__this_">Capturing
+ The Object <code class="computeroutput"><span class="keyword">this</span></code></a></span></dt>
+<dt><span class="section"><a href="Tutorial.html#scope_exit.Tutorial.capturing_no_variable">Capturing
+ No Variable</a></span></dt>
+<dt><span class="section"><a href="Tutorial.html#scope_exit.Tutorial.capturing_all_variables__c__11_only_">Capturing
+ All Variables (C++11 Only)</a></span></dt>
+<dt><span class="section"><a href="Tutorial.html#scope_exit.Tutorial.gcc_template_workaround">GCC Template
+ Workaround</a></span></dt>
+</dl></div>
+<p>
+ This section illustrates how to use this library.
+ </p>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="scope_exit.Tutorial.capturing_variables"></a><a class="link" href="Tutorial.html#scope_exit.Tutorial.capturing_variables" title="Capturing Variables">Capturing Variables</a>
+</h3></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">add_person</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">add_person</span><span class="special">(</span><span class="identifier">person</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a_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">persons_</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">a_person</span><span class="special">);</span> <span class="comment">// (1) direct action</span>
+ <span class="special">...</span>
+</pre>
+<p>
+ Some operations 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, the last added person must be deleted from <code class="computeroutput"><span class="identifier">persons_</span></code>
+ if the function throws. All you need is to define a delayed action (release
+ of a resource) right after the direct action (resource acquisition). For
+ example (see also "world_commit.cpp"):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">world</span><span class="special">::</span><span class="identifier">add_person</span><span class="special">(</span><span class="identifier">person</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a_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">persons_</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">a_person</span><span class="special">);</span> <span class="comment">// (1) direct action</span>
+ <span class="comment">// Following block is executed when the enclosing scope exits.</span>
+ <span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(&</span><span class="identifier">commit</span><span class="special">,</span> <span class="special">&</span><span class="identifier">persons_</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">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) disable rollback actions</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<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 1.1.0">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 1.1.0">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 1.1.0">ScopeExit</a> declaration starts with the
+ <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> macro invocation
+ which accepts a comma-separated list of captured variables (a <a href="../../../../../libs/preprocessor/index.html" target="_top">Boost.Preprocessor
+ sequence</a> is also accepted here for compilers that do not support
+ variadic macros and for backward compatibility with older versions of this
+ library, see the <a class="link" href="No_Variadic_Macros.html" title="Annex: No Variadic Macros">No Variadic
+ Macros</a> section). If a capture starts with the ampersand sign <code class="computeroutput"><span class="special">&</span></code>, a reference to the captured variable
+ will be available inside the <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a>
+ body; otherwise, a copy of the variable will be made after the <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a>
+ declaration at 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. On various versions of the GCC compiler, it is necessary to use
+ <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code> instead
+ of <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> within
+ templates (see later in this section for more details).
+ </p>
+<p>
+ In the example above, the variables <code class="computeroutput"><span class="identifier">commit</span></code>
+ and <code class="computeroutput"><span class="identifier">persons_</span></code> are captured
+ 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 actions
+ or not and the action should modify the <code class="computeroutput"><span class="identifier">persons_</span></code>
+ object, not its copy. This is the most common case but passing a variable
+ by value is sometimes useful as well.
+ </p>
+<p>
+ Finally, the end of the <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a> body
+ must be marked by the <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</a></code>
+ macro which must follow the closing curly bracket <code class="computeroutput"><span class="special">}</span></code>
+ of the <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a> body. On C++11 it is also
+ possible (but not required) to use a semi-column <code class="computeroutput"><span class="special">;</span></code>
+ instead of the <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</a></code>
+ macro. <sup>[<a name="scope_exit.Tutorial.capturing_variables.f0" href="#ftn.scope_exit.Tutorial.capturing_variables.f0" class="footnote">3</a>]</sup>
+ </p>
+<div class="warning"><table border="0" summary="Warning">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/src/images/warning.png"></td>
+<th align="left">Warning</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ In order to comply with the STL exception safety requirements, the <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a> body must never throw (because the
+ library implementation executes the body within a destructor).
+ </p></td></tr>
+</table></div>
+<p>
+ Consider a more complex example where <code class="computeroutput"><span class="identifier">world</span><span class="special">::</span><span class="identifier">add_person</span></code>
+ can save intermediate states at some point and roll back to the last saved
+ state. We use <code class="computeroutput"><span class="identifier">person</span><span class="special">::</span><span class="identifier">evolution_</span></code> to store a version of the changes
+ and increment it to cancel all rollback actions associated with those changes.
+ If we pass a current value of <code class="computeroutput"><span class="identifier">evolution_</span></code>
+ stored in the <code class="computeroutput"><span class="identifier">checkpoint</span></code>
+ variable by value, it remains unchanged within the <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a>
+ body so we can compare it with the final value of <code class="computeroutput"><span class="identifier">evolution_</span></code>.
+ If the latter was not incremented since we saved it, the rollback action
+ inside the <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a> body should be executed.
+ For example (see also "world.cpp"):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">world</span><span class="special">::</span><span class="identifier">add_person</span><span class="special">(</span><span class="identifier">person</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a_person</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">persons_</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">a_person</span><span class="special">);</span>
+
+ <span class="comment">// This block must be no-throw.</span>
+ <span class="identifier">person</span><span class="special">&</span> <span class="identifier">p</span> <span class="special">=</span> <span class="identifier">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">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">;</span>
+ <span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span><span class="identifier">checkpoint</span><span class="special">,</span> <span class="special">&</span><span class="identifier">p</span><span class="special">,</span> <span class="special">&</span><span class="identifier">persons_</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">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">)</span> <span class="identifier">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">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">;</span>
+
+ <span class="comment">// Assign new identifier 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">p</span><span class="special">.</span><span class="identifier">id_</span><span class="special">;</span>
+ <span class="identifier">p</span><span class="special">.</span><span class="identifier">id_</span> <span class="special">=</span> <span class="identifier">next_id_</span><span class="special">++;</span>
+ <span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span><span class="identifier">checkpoint</span><span class="special">,</span> <span class="special">&</span><span class="identifier">p</span><span class="special">,</span> <span class="special">&</span><span class="identifier">next_id_</span><span class="special">,</span> <span class="identifier">prev_id</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">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">next_id_</span> <span class="special">=</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">id_</span><span class="special">;</span>
+ <span class="identifier">p</span><span class="special">.</span><span class="identifier">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">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ When multiple <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a> blocks are declared
+ within the same enclosing scope, the <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a>
+ bodies are executed in the reversed order of their declarations.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="scope_exit.Tutorial.capturing_the_object__this_"></a><a class="link" href="Tutorial.html#scope_exit.Tutorial.capturing_the_object__this_" title="Capturing The Object this">Capturing
+ The Object <code class="computeroutput"><span class="keyword">this</span></code></a>
+</h3></div></div></div>
+<p>
+ Within a member function, it is also possible to capture the object <code class="computeroutput"><span class="keyword">this</span></code>. However, the special symbol <code class="computeroutput"><span class="identifier">this_</span></code> must be used instead of <code class="computeroutput"><span class="keyword">this</span></code> in the <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a>
+ declaration and body to capture and access the object. For example (see also
+ "world_commit_this.cpp"):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(&</span><span class="identifier">commit</span><span class="special">,</span> <span class="identifier">this_</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Capture object `this_`.</span>
+ <span class="keyword">if</span><span class="special">(!</span><span class="identifier">commit</span><span class="special">)</span> <span class="identifier">this_</span><span class="special">-></span><span class="identifier">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>
+</pre>
+<p>
+ </p>
+<p>
+ On C++11, it is possible (but not required) to directly use <code class="computeroutput"><span class="keyword">this</span></code> instead of the special symbol <code class="computeroutput"><span class="identifier">this_</span></code>. <sup>[<a name="scope_exit.Tutorial.capturing_the_object__this_.f0" href="#ftn.scope_exit.Tutorial.capturing_the_object__this_.f0" class="footnote">4</a>]</sup> For example (see also "world_commit_this.cpp"):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(&</span><span class="identifier">commit</span><span class="special">,</span> <span class="keyword">this</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Use `this` (C++11).</span>
+ <span class="keyword">if</span><span class="special">(!</span><span class="identifier">commit</span><span class="special">)</span> <span class="keyword">this</span><span class="special">-></span><span class="identifier">persons_</span><span class="special">.</span><span class="identifier">pop_back</span><span class="special">();</span>
+<span class="special">};</span> <span class="comment">// Use `;` instead of `BOOST_SCOPE_EXIT_END` (C++11).</span>
+</pre>
+<p>
+ </p>
+<p>
+ It is never possible to capture the object <code class="computeroutput"><span class="identifier">this_</span></code>
+ (or <code class="computeroutput"><span class="keyword">this</span></code>) by reference because
+ C++ does not allow to take a reference to <code class="computeroutput"><span class="keyword">this</span></code>.
+ If the enclosing member function is constant then the captured object will
+ also be constant, otherwise the captured object will be mutable.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="scope_exit.Tutorial.capturing_no_variable"></a><a class="link" href="Tutorial.html#scope_exit.Tutorial.capturing_no_variable" title="Capturing No Variable">Capturing
+ No Variable</a>
+</h3></div></div></div>
+<p>
+ It is possible to declare a <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a> block
+ that captures no variable. In this case, the list of captured variables is
+ replaced by the <code class="computeroutput"><span class="keyword">void</span></code> keyword
+ (similarly to the C syntax that allows to declare a function with no parameter
+ using <code class="computeroutput"><span class="identifier">result_type</span> <span class="identifier">func</span><span class="special">(</span><span class="keyword">void</span><span class="special">);</span></code>).
+ <sup>[<a name="scope_exit.Tutorial.capturing_no_variable.f0" href="#ftn.scope_exit.Tutorial.capturing_no_variable.f0" class="footnote">5</a>]</sup> For example, this can be useful when the <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a>
+ body only needs to access global variables (see also "world_commit_void.cpp"):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">world_t</span> <span class="special">{</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">person</span><span class="special">></span> <span class="identifier">persons</span><span class="special">;</span>
+ <span class="keyword">bool</span> <span class="identifier">commit</span><span class="special">;</span>
+<span class="special">}</span> <span class="identifier">world</span><span class="special">;</span> <span class="comment">// Global variable.</span>
+
+<span class="keyword">void</span> <span class="identifier">add_person</span><span class="special">(</span><span class="identifier">person</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a_person</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">world</span><span class="special">.</span><span class="identifier">commit</span> <span class="special">=</span> <span class="keyword">false</span><span class="special">;</span>
+ <span class="identifier">world</span><span class="special">.</span><span class="identifier">persons</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">a_person</span><span class="special">);</span>
+
+ <span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// No captures.</span>
+ <span class="keyword">if</span><span class="special">(!</span><span class="identifier">world</span><span class="special">.</span><span class="identifier">commit</span><span class="special">)</span> <span class="identifier">world</span><span class="special">.</span><span class="identifier">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">world</span><span class="special">.</span><span class="identifier">commit</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ This same syntax is supported for both compilers with and without variadic
+ macro support.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="scope_exit.Tutorial.capturing_all_variables__c__11_only_"></a><a class="link" href="Tutorial.html#scope_exit.Tutorial.capturing_all_variables__c__11_only_" title="Capturing All Variables (C++11 Only)">Capturing
+ All Variables (C++11 Only)</a>
+</h3></div></div></div>
+<p>
+ On C++11 compliers, it is also possible to capture all the variables in scope
+ without naming them one by one using the special macro <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code>
+ instead of <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code>.
+ <sup>[<a name="scope_exit.Tutorial.capturing_all_variables__c__11_only_.f0" href="#ftn.scope_exit.Tutorial.capturing_all_variables__c__11_only_.f0" class="footnote">6</a>]</sup>
+ </p>
+<p>
+ Following the same syntax adopted by C++11 lambdas, the <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code>
+ macro accepts a comma-separated list of captures which must start with either
+ <code class="computeroutput"><span class="special">&</span></code> or <code class="computeroutput"><span class="special">=</span></code>
+ to capture all variables in scope respectively by reference or by value (note
+ that no variable name is specified by these leading captures). Additional
+ captures of specific variables can follow the leading <code class="computeroutput"><span class="special">&</span></code>
+ or <code class="computeroutput"><span class="special">=</span></code> and they will override
+ the default reference or value captures. For example (see also "world_all.cpp"):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">world</span><span class="special">::</span><span class="identifier">add_person</span><span class="special">(</span><span class="identifier">person</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a_person</span><span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">persons_</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">a_person</span><span class="special">);</span>
+
+ <span class="comment">// This block must be no-throw.</span>
+ <span class="identifier">person</span><span class="special">&</span> <span class="identifier">p</span> <span class="special">=</span> <span class="identifier">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">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">;</span>
+ <span class="identifier">BOOST_SCOPE_EXIT_ALL</span><span class="special">(&,</span> <span class="identifier">checkpoint</span><span class="special">,</span> <span class="identifier">this_</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Capture all by ref (C++11).</span>
+ <span class="keyword">if</span><span class="special">(</span><span class="identifier">checkpoint</span> <span class="special">==</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">)</span> <span class="identifier">this_</span><span class="special">-></span><span class="identifier">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">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">;</span>
+
+ <span class="comment">// Assign new identifier 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">p</span><span class="special">.</span><span class="identifier">id_</span><span class="special">;</span>
+ <span class="identifier">p</span><span class="special">.</span><span class="identifier">id_</span> <span class="special">=</span> <span class="identifier">next_id_</span><span class="special">++;</span>
+ <span class="identifier">BOOST_SCOPE_EXIT_ALL</span><span class="special">(=,</span> <span class="special">&</span><span class="identifier">p</span><span class="special">,</span> <span class="keyword">this</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Capture all by value, `this` (C++11).</span>
+ <span class="keyword">if</span><span class="special">(</span><span class="identifier">checkpoint</span> <span class="special">==</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">this</span><span class="special">-></span><span class="identifier">next_id_</span> <span class="special">=</span> <span class="identifier">p</span><span class="special">.</span><span class="identifier">id_</span><span class="special">;</span>
+ <span class="identifier">p</span><span class="special">.</span><span class="identifier">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="comment">// Use `;` instead of `SCOPE_EXIT_END` (C++11).</span>
+
+ <span class="comment">// ...</span>
+
+ <span class="identifier">checkpoint</span> <span class="special">=</span> <span class="special">++</span><span class="identifier">p</span><span class="special">.</span><span class="identifier">evolution_</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ The first <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a> declaration captures
+ all variables in scope by reference but <code class="computeroutput"><span class="identifier">checkpoint</span></code>
+ and <code class="computeroutput"><span class="identifier">this_</span></code> which are explicitly
+ captured by value (in particular, <code class="computeroutput"><span class="identifier">p</span></code>
+ and <code class="computeroutput"><span class="identifier">persons_</span></code> are captured
+ by reference). The second <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a> declaration
+ instead captures all variables in scope by value but <code class="computeroutput"><span class="identifier">p</span></code>
+ which is captured by reference (in particular, <code class="computeroutput"><span class="identifier">checkpoint</span></code>,
+ <code class="computeroutput"><span class="identifier">prev_id</span></code>, and <code class="computeroutput"><span class="keyword">this</span></code> are captured by value).
+ </p>
+<div class="warning"><table border="0" summary="Warning">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/src/images/warning.png"></td>
+<th align="left">Warning</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ Again, in order to comply with the STL exception safety requirements, the
+ <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a> body must never throw.
+ </p></td></tr>
+</table></div>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="scope_exit.Tutorial.gcc_template_workaround"></a><a class="link" href="Tutorial.html#scope_exit.Tutorial.gcc_template_workaround" title="GCC Template Workaround">GCC Template
+ Workaround</a>
+</h3></div></div></div>
+<p>
+ Various versions of the GCC compiler do not compile <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code>
+ inside templates (see the Reference section
+ for more information). <sup>[<a name="scope_exit.Tutorial.gcc_template_workaround.f0" href="#ftn.scope_exit.Tutorial.gcc_template_workaround.f0" class="footnote">7</a>]</sup> As a workaround, <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code>
+ should be used instead of <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code>
+ in these cases:
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">Person</span><span class="special">></span>
+<span class="keyword">void</span> <span class="identifier">world</span><span class="special"><</span><span class="identifier">Person</span><span class="special">>::</span><span class="identifier">add_person</span><span class="special">(</span><span class="identifier">Person</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a_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">persons_</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">a_person</span><span class="special">);</span>
+
+ <span class="identifier">BOOST_SCOPE_EXIT_TPL</span><span class="special">(&</span><span class="identifier">commit</span><span class="special">,</span> <span class="identifier">this_</span><span class="special">)</span> <span class="special">{</span> <span class="comment">// Use `_TPL` postfix.</span>
+ <span class="keyword">if</span><span class="special">(!</span><span class="identifier">commit</span><span class="special">)</span> <span class="identifier">this_</span><span class="special">-></span><span class="identifier">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">commit</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ The <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT_TPL.html" title="Macro BOOST_SCOPE_EXIT_TPL">BOOST_SCOPE_EXIT_TPL</a></code>
+ macro has the exact same syntax of <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code>.
+ </p>
+<div class="warning"><table border="0" summary="Warning">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/src/images/warning.png"></td>
+<th align="left">Warning</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ Again, in order to comply with the STL exception safety requirements, the
+ <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a> body must never throw.
+ </p></td></tr>
+</table></div>
+</div>
+<div class="footnotes">
+<br><hr width="100" align="left">
+<div class="footnote"><p><sup>[<a id="ftn.scope_exit.Tutorial.capturing_variables.f0" href="#scope_exit.Tutorial.capturing_variables.f0" class="para">3</a>] </sup>
+ The macro <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</a></code>
+ can still be used on C++11 to write portable code that can be used on both
+ C++03 and C++11 compilers. Using <code class="computeroutput"><span class="special">;</span></code>
+ instead of <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT_END.html" title="Macro BOOST_SCOPE_EXIT_END">BOOST_SCOPE_EXIT_END</a></code>
+ on C++03 compilers will generate a (possibly cryptic) compiler error.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.scope_exit.Tutorial.capturing_the_object__this_.f0" href="#scope_exit.Tutorial.capturing_the_object__this_.f0" class="para">4</a>] </sup>
+ The special symbol <code class="computeroutput"><span class="identifier">this_</span></code>
+ can still be used on C++11 to write portable code that can be used on both
+ C++03 and C++11 compilers. Unfortunately, using <code class="computeroutput"><span class="keyword">this</span></code>
+ instead of <code class="computeroutput"><span class="identifier">this_</span></code> on C++03
+ compilers leads to undefined behaviour (it will likely generate a compiler
+ error but that is not guaranteed).
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.scope_exit.Tutorial.capturing_no_variable.f0" href="#scope_exit.Tutorial.capturing_no_variable.f0" class="para">5</a>] </sup>
+ Unfortunately, it is not possible to simply invoke the <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a>
+ macro with no parameters <code class="computeroutput"><span class="identifier">BOOST_SCOPE_EXIT</span><span class="special">()</span></code> because the preprocessor cannot detect
+ emptiness of a macro parameter when the parameter can start with a non-alphanumeric
+ symbol (which is the case when capturing a variable by reference <code class="computeroutput"><span class="special">&</span><span class="identifier">variable</span></code>).
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.scope_exit.Tutorial.capturing_all_variables__c__11_only_.f0" href="#scope_exit.Tutorial.capturing_all_variables__c__11_only_.f0" class="para">6</a>] </sup>
+ The <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code>
+ macro is only defined on C++11 compilers. Using <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code>
+ on C++03 compilers will generate a (possibly cryptic) compiler error.
+ </p></div>
+<div class="footnote"><p><sup>[<a id="ftn.scope_exit.Tutorial.gcc_template_workaround.f0" href="#scope_exit.Tutorial.gcc_template_workaround.f0" class="para">7</a>] </sup>
+ GCC versions compliant with C++11 do not present this issue and given that
+ <code class="computeroutput"><a class="link" href="../BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code>
+ is only available on C++11 compilers, there is no need for a <code class="computeroutput"><span class="identifier">BOOST_SCOPE_EXIT_ALL_TPL</span></code> macro.
+ </p></div>
+</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-2012 Alexander Nasonov, Lorenzo Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="Getting_Started.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="annex__alternatives.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
Added: sandbox/closure/libs/scope_exit/doc/html/scope_exit/acknowledgements.html
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/doc/html/scope_exit/acknowledgements.html 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,69 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Acknowledgements</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="prev" href="../BOOST_SCOPE_EXIT_CONFIG_NO_CPP11.html" title="Macro BOOST_SCOPE_EXIT_CONFIG_NO_CPP11">
+</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="../BOOST_SCOPE_EXIT_CONFIG_NO_CPP11.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="scope_exit.acknowledgements"></a><a class="link" href="acknowledgements.html" title="Acknowledgements">Acknowledgements</a>
+</h2></div></div></div>
+<p>
+ <span class="emphasis"><em>In chronological order.</em></span>
+ </p>
+<p>
+ Maxim Yegorushkin for sharing code where he used a local struct to clean up
+ resources.
+ </p>
+<p>
+ Andrei Alexandrescu for pointing out the 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>
+<p>
+ Adam Butcher for a workaround to error C2355 when deducing the type of <code class="computeroutput"><span class="keyword">this</span></code> on some MSVC versions.
+ </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-2012 Alexander Nasonov, Lorenzo Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="../BOOST_SCOPE_EXIT_CONFIG_NO_CPP11.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a>
+</div>
+</body>
+</html>
Added: sandbox/closure/libs/scope_exit/doc/html/scope_exit/annex__alternatives.html
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/doc/html/scope_exit/annex__alternatives.html 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,334 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<title>Annex: Alternatives</title>
+<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
+<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
+<link rel="home" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="up" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">
+<link rel="prev" href="Tutorial.html" title="Tutorial">
+<link rel="next" href="No_Variadic_Macros.html" title="Annex: No Variadic Macros">
+</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/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="No_Variadic_Macros.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h2 class="title" style="clear: both">
+<a name="scope_exit.annex__alternatives"></a><a class="link" href="annex__alternatives.html" title="Annex: Alternatives">Annex: Alternatives</a>
+</h2></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section">Try-Catch</span></dt>
+<dt><span class="section">RAII</span></dt>
+<dt><span class="section">Scope Guards</span></dt>
+<dt><span class="section"><a href="annex__alternatives.html#scope_exit.annex__alternatives.the_d_programming_language">The
+ D Programming Language</a></span></dt>
+<dt><span class="section">C++11 Lambdas</span></dt>
+</dl></div>
+<p>
+ This section presents some alternatives and work related to <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a>.
+ </p>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="scope_exit.annex__alternatives.try_catch"></a><a class="link" href="annex__alternatives.html#scope_exit.annex__alternatives.try_catch" title="Try-Catch">Try-Catch</a>
+</h3></div></div></div>
+<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>
+ does not close the file in its destructor, a programmer is expected to call
+ the <code class="computeroutput"><span class="identifier">close</span></code> member function
+ explicitly. For example (see also "try_catch.cpp"):
+ </p>
+<p>
+</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">std</span><span class="special">::</span><span class="identifier">clog</span> <span class="special"><<</span> <span class="string">"could not get user info"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</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>
+ </p>
+<p>
+ Note the following issues with this approach:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ 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 class="listitem">
+ 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.
+ </li>
+<li class="listitem">
+ 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>
+ The <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a> approach does not have any
+ of these issues. For example (see also "try_catch.cpp"):
+ </p>
+<p>
+</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="identifier">passwd</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="special">}</span> <span class="keyword">catch</span><span class="special">(...)</span> <span class="special">{</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">clog</span> <span class="special"><<</span> <span class="string">"could not get user info"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+ <span class="keyword">throw</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="scope_exit.annex__alternatives.raii"></a><a class="link" href="annex__alternatives.html#scope_exit.annex__alternatives.raii" title="RAII">RAII</a>
+</h3></div></div></div>
+<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">std</span><span class="special">::</span><span class="identifier">clog</span> <span class="special"><<</span> <span class="string">"could not get user info"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</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">persons_</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">a_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">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">commit_</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">person</span><span class="special">>&</span> <span class="identifier">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">commit_</span><span class="special">)</span> <span class="identifier">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"><</span><span class="identifier">Person</span><span class="special">></span> <span class="identifier">superman_ptr</span><span class="special">(</span><span class="keyword">new</span> <span class="identifier">superman</span><span class="special">());</span>
+<span class="identifier">persons_</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">superman_ptr</span><span class="special">.</span><span class="identifier">get</span><span class="special">());</span>
+<span class="identifier">superman_ptr</span><span class="special">.</span><span class="identifier">release</span><span class="special">();</span> <span class="comment">// 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>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="scope_exit.annex__alternatives.scope_guards"></a><a class="link" href="annex__alternatives.html#scope_exit.annex__alternatives.scope_guards" title="Scope Guards">Scope Guards</a>
+</h3></div></div></div>
+<p>
+ Imagine that a new currency rate is introduced before performing a transaction:
+ </p>
+<p>
+</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"><</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">></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>
+<span class="comment">// Transaction...</span>
+</pre>
+<p>
+ </p>
+<p>
+ If the transaction does not complete, the currency must be erased from <code class="computeroutput"><span class="identifier">rates</span></code>. This can be done with ScopeGuard
+ and Boost.Lambda
+ (or Boost.Phoenix):
+ </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">&&</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"><</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</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">>::</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"><</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">>::*)(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&)</span>
+ <span class="special">>(&</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special"><</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">>::</span><span class="identifier">erase</span><span class="special">)</span>
+ <span class="special">,</span> <span class="special">&</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 the following issues with this approach:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ Boost.Lambda
+ expressions are hard to write correctly (e.g., overloaded functions must
+ be explicitly casted, as demonstrated in the example above).
+ </li>
+<li class="listitem">
+ The condition in the <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 reducing readability.
+ </li>
+<li class="listitem">
+ Setting a breakpoint inside <code class="computeroutput"><span class="identifier">if_</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 C++11 lambdas:
+ </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">&</span><span class="identifier">commit</span><span class="special">,</span> <span class="special">&</span><span class="identifier">rates</span><span class="special">,</span> <span class="special">&</span><span class="identifier">currency</span><span class="special">]()</span> <span class="special">-></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">&&</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>
+
+<span class="comment">// ...</span>
+
+<span class="identifier">commit</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span>
+</pre>
+<p>
+ With <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a> we can simply do the following
+ (see also "scope_guard.cpp"):
+ </p>
+<p>
+</p>
+<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">&</span><span class="identifier">commit</span><span class="special">,</span> <span class="special">&</span><span class="identifier">rates</span><span class="special">,</span> <span class="special">&</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">&&</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>
+<p>
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="scope_exit.annex__alternatives.the_d_programming_language"></a><a class="link" href="annex__alternatives.html#scope_exit.annex__alternatives.the_d_programming_language" title="The D Programming Language">The
+ D Programming Language</a>
+</h3></div></div></div>
+<p>
+ <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a> is similar to scope(exit)
+ feature built into the D
+ programming language.
+ </p>
+<p>
+ A curious reader may notice that the library does not 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, these are not possible in C++ because failure or success conditions
+ cannot be determined by calling <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">uncaught_exception</span></code>
+ (see 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). However, this is not a big problem because
+ these two D's
+ 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 the <a class="link" href="Tutorial.html" title="Tutorial">Tutorial</a>
+ section.
+ </p>
+</div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="scope_exit.annex__alternatives.c__11_lambdas"></a><a class="link" href="annex__alternatives.html#scope_exit.annex__alternatives.c__11_lambdas" title="C++11 Lambdas">C++11 Lambdas</a>
+</h3></div></div></div>
+<p>
+ Using C++11 lambdas, it is relatively easy to implement the <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a>
+ construct. For example (see also "world_commit_lambda.cpp"):
+ </p>
+<p>
+</p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">functional</span><span class="special">></span>
+
+<span class="keyword">struct</span> <span class="identifier">scope_exit</span> <span class="special">{</span>
+ <span class="identifier">scope_exit</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">function</span><span class="special"><</span><span class="keyword">void</span> <span class="special">(</span><span class="keyword">void</span><span class="special">)></span> <span class="identifier">f</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">f_</span><span class="special">(</span><span class="identifier">f</span><span class="special">)</span> <span class="special">{}</span>
+ <span class="special">~</span><span class="identifier">scope_exit</span><span class="special">(</span><span class="keyword">void</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">f_</span><span class="special">();</span> <span class="special">}</span>
+<span class="keyword">private</span><span class="special">:</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">function</span><span class="special"><</span><span class="keyword">void</span> <span class="special">(</span><span class="keyword">void</span><span class="special">)></span> <span class="identifier">f_</span><span class="special">;</span>
+<span class="special">};</span>
+
+<span class="keyword">void</span> <span class="identifier">world</span><span class="special">::</span><span class="identifier">add_person</span><span class="special">(</span><span class="identifier">person</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a_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">persons_</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">a_person</span><span class="special">);</span>
+ <span class="identifier">scope_exit</span> <span class="identifier">on_exit1</span><span class="special">([&</span><span class="identifier">commit</span><span class="special">,</span> <span class="special">&</span><span class="identifier">persons_</span><span class="special">]()</span> <span class="special">{</span> <span class="comment">// Use C++11 lambda.</span>
+ <span class="keyword">if</span><span class="special">(!</span><span class="identifier">commit</span><span class="special">)</span> <span class="identifier">persons_</span><span class="special">.</span><span class="identifier">pop_back</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>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+<p>
+ However, this library allows to program the <a class="link" href="../index.html" title="Chapter 1. Boost.ScopeExit 1.1.0">ScopeExit</a>
+ construct in a way that is portable between C++03 and C++11 compilers.
+ </p>
+</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-2012 Alexander Nasonov, Lorenzo Caminiti<p>
+ Distributed under the Boost Software License, Version 1.0 (see accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ </p>
+</div></td>
+</tr></table>
+<hr>
+<div class="spirit-nav">
+<a accesskey="p" href="Tutorial.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="No_Variadic_Macros.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
+</div>
+</body>
+</html>
Added: sandbox/closure/libs/scope_exit/doc/scope_exit.qbk
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/doc/scope_exit.qbk 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,457 @@
+
+[library Boost.ScopeExit
+ [quickbook 1.5]
+ [version 1.1.0]
+ [copyright 2006-2012 Alexander Nasonov, Lorenzo Caminiti]
+ [purpose execute arbitrary code at scope exit]
+ [license
+ Distributed under the Boost Software License, Version 1.0
+ (see accompanying file LICENSE_1_0.txt or copy at
+ [@http://www.boost.org/LICENSE_1_0.txt])
+ ]
+ [authors [Nasonov, Alexander] [Caminiti, Lorenzo]]
+ [category utility]
+ [id scope_exit]
+ [dirname scope_exit]
+]
+
+[def __scope_exit__ [link scope_exit ScopeExit]]
+[def __Tutorial__ [link scope_exit.Tutorial Tutorial]]
+[def __No_Variadic_Macros__ [link scope_exit.No_Variadic_Macros No Variadic Macros]]
+[def __Reference__ [@reference.html Reference]]
+[def __lambda__ [@../../../../libs/lambda/index.html Boost.Lambda]]
+[def __phoenix__ [@../../../../libs/phoenix/index.html Boost.Phoenix]]
+[def __typeof__ [@../../../../libs/typeof/index.html Boost.Typeof]]
+[def __typeof_emulation__ [@../../../../libs/typeof/index.html typeof emulation]]
+[def __typeof_REGISTER_TYPE__ [@../../../../doc/html/typeof/refe.html#typeof.regtype BOOST_TYPEOF_REGISTER_TYPE]]
+[def __typeof_REGISTER_TEMPLATE__ [@../../../../doc/html/typeof/refe.html#typeof.regtemp BOOST_TYPEOF_REGISTER_TEMPLATE]]
+[def __pp__ [@../../../../libs/preprocessor/index.html Boost.Preprocessor]]
+[def __pp_seq__ [@../../../../libs/preprocessor/index.html Boost.Preprocessor sequence]]
+[def __ptr_container__ [@../../../../libs/ptr_container/doc/ptr_container.html Boost Pointer Container Library]]
+[def __multi_index__ [@../../../../libs/multi_index/doc/index.html Boost Multi-Index Containers Library]]
+[def __scope_guard__ [@http://www.ddj.com/dept/cpp/184403758 ScopeGuard]]
+[def __D__ [@http://www.digitalmars.com/d/index.html D]]
+[def __D_scope_exit__ [@http://www.digitalmars.com/d/2.0/statement.html#ScopeGuardStatement scope(exit)]]
+[def __RAII__ [@http://www.research.att.com/~bs/glossary.html#Gresource-acquisition-is-initialization RAII]]
+[def __strong_guarantee__ [@http://www.research.att.com/~bs/glossary.html#Gstrong-guarantee strong guarantee]]
+
+[import ../test/world.cpp]
+[import ../test/world_seq.cpp]
+[import ../test/world_commit.cpp]
+[import ../test/world_commit_this.cpp]
+[import ../test/world_commit_void.cpp]
+[import ../test/world_all.cpp]
+[import ../test/world_commit_tpl.cpp]
+[import ../test/world_commit_lambda.cpp]
+[import ../example/try_catch.cpp]
+[import ../example/scope_guard.cpp]
+
+['
+Alexander Nasonov is the original author.
+Lorenzo Caminiti added support for variadic macros, capture of `this_`, no captures, and `BOOST_SCOPE_EXIT_ALL`.
+]
+
+This library allows to execute arbitrary code when the enclosing scope exits.
+
+[section:intro Introduction]
+
+Nowadays, every C++ developer is familiar with the __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.
+
+This is when the __scope_exit__ library comes into play.
+Programmers can put resource acquisition directly in their code and next to it, they can write code that releases the resource using this library.
+For example:
+[footnote
+Older versions of this library used a __pp_seq__ to specify the list of captured variable.
+While maintaining full backward compatibility, it is now also possible to specify the captured variables as a comma-separated list (which is the preferred syntax).
+See the __No_Variadic_Macros__ section for more details.
+]
+
+[test_world_commit]
+
+Read the __Tutorial__ section to find out how to write programs with __scope_exit__ or jump to the __Reference__ section.
+
+[endsect]
+
+[section:Getting_Started Getting Started]
+
+This section explains how to setup your system to use this library.
+
+[section Compilers and Platforms]
+
+The library should be usable on any compiler that supports __typeof__ except:
+
+* MSVC 7.1 and 8.0 fail to link if a function with __scope_exit__ is included by multiple translation units.
+* GCC 3.3 cannot compile __scope_exit__ inside a template (see [@http://lists.boost.org/Archives/boost/2007/02/116235.php] for more details).
+
+The authors tested the library on GCC 3.3, 3.4, 4.1, 4.2, 4.5.3 (with and without C++11 features [^-std=c++0x]), MSVC 8.0, and Intel 10.1 under Linux, Cygwin, and Windows 7.
+
+[endsect]
+
+[section Installation]
+
+This library is composed of header files only.
+Therefore there is no pre-compiled object file which needs to be installed.
+Programmers can simply instruct the compiler where to find the library header files (`-I` option on GCC, `/I` option on MSVC, etc) and compile code using the library.
+
+The library implementation uses __typeof__ to automatically deduce the types of the __scope_exit__ captured variables (see the __Tutorial__ section).
+In order to compile code in __typeof_emulation__ mode, all types should be properly registered with __typeof_REGISTER_TYPE__ or __typeof_REGISTER_TEMPLATE__ macros, or appropriate __typeof__ headers should be included.
+
+When using comma-separated lists to specify captures (see the __No_Variadic_Macros__ section), make sure that the `BOOST_PP_VARIADICS` macro is defined (either automatically by __pp__ or manually using your compiler options `-D`, `/D`, etc).
+[footnote
+It is not sufficient for the `BOOST_NO_VARIADIC_MACROS` macro to be undefined, the `BOOST_PP_VARIADICS` macro must be defined.
+]
+
+[endsect]
+
+[endsect]
+
+[section:Tutorial Tutorial]
+
+This section illustrates how to use this library.
+
+[section Capturing Variables]
+
+Imagine that you want to make many modifications to data members of the `world` class in the `world::add_person` function.
+You start with adding a new `person` object to a vector of persons:
+
+ void world::add_person(person const& a_person) {
+ bool commit = false;
+
+ persons_.push_back(a_person); // (1) direct action
+ ...
+
+Some operations 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 __strong_guarantee__.
+
+In particular, the last added person must be deleted from `persons_` if the function throws.
+All you need is to define a delayed action (release of a resource) right after the direct action (resource acquisition).
+For example (see also [@../../test/world_commit.cpp "world_commit.cpp"]):
+
+[test_world_commit]
+
+The block below point `(1)` is a __scope_exit__ declaration.
+Unlike point `(1)`, an execution of the __scope_exit__ body will be delayed until the end of the current scope. In this case it will be executed either after point `(4)` or on any exception.
+
+The __scope_exit__ declaration starts with the [macroref BOOST_SCOPE_EXIT] macro invocation which accepts a comma-separated list of captured variables (a __pp_seq__ is also accepted here for compilers that do not support variadic macros and for backward compatibility with older versions of this library, see the __No_Variadic_Macros__ section).
+If a capture starts with the ampersand sign `&`, a reference to the captured variable will be available inside the __scope_exit__ body; otherwise, a copy of the variable will be made after the __scope_exit__ declaration at point `(1)` and only the copy will be available inside the body.
+On various versions of the GCC compiler, it is necessary to use [macroref BOOST_SCOPE_EXIT_TPL] instead of [macroref BOOST_SCOPE_EXIT] within templates (see later in this section for more details).
+
+In the example above, the variables `commit` and `persons_` are captured by reference because the final value of the `commit` variable should be used to determine whether to execute rollback actions or not and the action should modify the `persons_` object, not its copy.
+This is the most common case but passing a variable by value is sometimes useful as well.
+
+Finally, the end of the __scope_exit__ body must be marked by the [macroref BOOST_SCOPE_EXIT_END] macro which must follow the closing curly bracket `}` of the __scope_exit__ body.
+On C++11 it is also possible (but not required) to use a semi-column `;` instead of the [macroref BOOST_SCOPE_EXIT_END] macro.
+[footnote
+The macro [macroref BOOST_SCOPE_EXIT_END] can still be used on C++11 to write portable code that can be used on both C++03 and C++11 compilers.
+Using `;` instead of [macroref BOOST_SCOPE_EXIT_END] on C++03 compilers will generate a (possibly cryptic) compiler error.
+]
+
+[warning
+In order to comply with the STL exception safety requirements, the __scope_exit__ body must never throw (because the library implementation executes the body within a destructor).
+]
+
+Consider a more complex example where `world::add_person` can save intermediate states at some point and roll back to the last saved state.
+We use `person::evolution_` to store a version of the changes and increment it to cancel all rollback actions associated with those changes.
+If we pass a current value of `evolution_` stored in the `checkpoint` variable by value, it remains unchanged within the __scope_exit__ body so we can compare it with the final value of `evolution_`.
+If the latter was not incremented since we saved it, the rollback action inside the __scope_exit__ body should be executed.
+For example (see also [@../../test/world.cpp "world.cpp"]):
+
+[test_world]
+
+When multiple __scope_exit__ blocks are declared within the same enclosing scope, the __scope_exit__ bodies are executed in the reversed order of their declarations.
+
+[endsect]
+
+[section Capturing The Object `this`]
+
+Within a member function, it is also possible to capture the object `this`.
+However, the special symbol `this_` must be used instead of `this` in the __scope_exit__ declaration and body to capture and access the object.
+For example (see also [@../../test/world_commit_this.cpp "world_commit_this.cpp"]):
+
+[test_world_commit_this_]
+
+On C++11, it is possible (but not required) to directly use `this` instead of the special symbol `this_`.
+[footnote
+The special symbol `this_` can still be used on C++11 to write portable code that can be used on both C++03 and C++11 compilers.
+Unfortunately, using `this` instead of `this_` on C++03 compilers leads to undefined behaviour (it will likely generate a compiler error but that is not guaranteed).
+]
+For example (see also [@../../test/world_commit_this.cpp "world_commit_this.cpp"]):
+
+[test_world_commit_this]
+
+It is never possible to capture the object `this_` (or `this`) by reference because C++ does not allow to take a reference to `this`.
+If the enclosing member function is constant then the captured object will also be constant, otherwise the captured object will be mutable.
+
+[endsect]
+
+[section Capturing No Variable]
+
+It is possible to declare a __scope_exit__ block that captures no variable.
+In this case, the list of captured variables is replaced by the `void` keyword (similarly to the C syntax that allows to declare a function with no parameter using `result_type func(void);`).
+[footnote
+Unfortunately, it is not possible to simply invoke the __scope_exit__ macro with no parameters `BOOST_SCOPE_EXIT()` because the preprocessor cannot detect emptiness of a macro parameter when the parameter can start with a non-alphanumeric symbol (which is the case when capturing a variable by reference `&variable`).
+]
+For example, this can be useful when the __scope_exit__ body only needs to access global variables (see also [@../../test_world_commit_void.cpp "world_commit_void.cpp"]):
+
+[test_world_commit_void]
+
+This same syntax is supported for both compilers with and without variadic macro support.
+
+[endsect]
+
+[section Capturing All Variables (C++11 Only)]
+
+On C++11 compliers, it is also possible to capture all the variables in scope without naming them one by one using the special macro [macroref BOOST_SCOPE_EXIT_ALL] instead of [macroref BOOST_SCOPE_EXIT].
+[footnote
+The [macroref BOOST_SCOPE_EXIT_ALL] macro is only defined on C++11 compilers.
+Using [macroref BOOST_SCOPE_EXIT_ALL] on C++03 compilers will generate a (possibly cryptic) compiler error.
+]
+
+Following the same syntax adopted by C++11 lambdas, the [macroref BOOST_SCOPE_EXIT_ALL] macro accepts a comma-separated list of captures which must start with either `&` or `=` to capture all variables in scope respectively by reference or by value (note that no variable name is specified by these leading captures).
+Additional captures of specific variables can follow the leading `&` or `=` and they will override the default reference or value captures.
+For example (see also [@../../test_world_all.cpp "world_all.cpp"]):
+
+[test_world_all]
+
+The first __scope_exit__ declaration captures all variables in scope by reference but `checkpoint` and `this_` which are explicitly captured by value (in particular, `p` and `persons_` are captured by reference).
+The second __scope_exit__ declaration instead captures all variables in scope by value but `p` which is captured by reference (in particular, `checkpoint`, `prev_id`, and `this` are captured by value).
+
+[warning
+Again, in order to comply with the STL exception safety requirements, the __scope_exit__ body must never throw.
+]
+
+[endsect]
+
+[section GCC Template Workaround]
+
+Various versions of the GCC compiler do not compile [macroref BOOST_SCOPE_EXIT] inside templates (see the __Reference__ section for more information).
+[footnote
+GCC versions compliant with C++11 do not present this issue and given that [macroref BOOST_SCOPE_EXIT_ALL] is only available on C++11 compilers, there is no need for a `BOOST_SCOPE_EXIT_ALL_TPL` macro.
+]
+As a workaround, [macroref BOOST_SCOPE_EXIT_TPL] should be used instead of [macroref BOOST_SCOPE_EXIT] in these cases:
+
+[test_world_commit_tpl]
+
+The [macroref BOOST_SCOPE_EXIT_TPL] macro has the exact same syntax of [macroref BOOST_SCOPE_EXIT].
+
+[warning
+Again, in order to comply with the STL exception safety requirements, the __scope_exit__ body must never throw.
+]
+
+[endsect]
+
+[endsect]
+
+[section Annex: Alternatives]
+
+This section presents some alternatives and work related to __scope_exit__.
+
+[section Try-Catch]
+
+This is an example of using a badly designed `file` class.
+An instance of `file` does not close the file in its destructor, a programmer is expected to call the `close` member function explicitly.
+For example (see also [@../../example/try_catch.cpp "try_catch.cpp"]):
+
+[example_try_catch_bad]
+
+Note the following issues with this approach:
+
+* The `passwd` object is defined outside of the `try` block because this object is required inside the `catch` block to close the file.
+* The `passwd` object is not fully constructed until after the `open`
+member function returns.
+* If opening throws, the `passwd.close()` should not be called, hence the call to `passwd.is_open()`.
+
+The __scope_exit__ approach does not have any of these issues.
+For example (see also [@../../example/try_catch.cpp "try_catch.cpp"]):
+
+[example_try_catch_good]
+
+[endsect]
+
+[section RAII]
+
+__RAII__ is absolutely perfect for the `file` class introduced above.
+Use of a properly designed `file` class would look like:
+
+ try {
+ file passwd("/etc/passwd");
+ // ...
+ } catch(...) {
+ std::clog << "could not get user info" << std::endl;
+ throw;
+ }
+
+However, using __RAII__ to build up a __strong_guarantee__ could introduce a lot of non-reusable __RAII__ types.
+For example:
+
+ persons_.push_back(a_person);
+ pop_back_if_not_commit pop_back_if_not_commit_guard(commit, persons_);
+
+The `pop_back_if_not_commit` class is either defined out of the scope or as a local class:
+
+ class pop_back_if_not_commit {
+ bool commit_;
+ std::vector<person>& vec_;
+ // ...
+ ~pop_back_if_not_commit() {
+ if(!commit_) vec_.pop_back();
+ }
+ };
+
+In some cases __strong_guarantee__ can be accomplished with standard utilities:
+
+ std::auto_ptr<Person> superman_ptr(new superman());
+ persons_.push_back(superman_ptr.get());
+ superman_ptr.release(); // persons_ successfully took ownership
+
+Or with specialized containers such as __ptr_container__ or __multi_index__.
+
+[endsect]
+
+[section Scope Guards]
+
+Imagine that a new currency rate is introduced before performing a transaction:
+
+[example_scope_guard_decl]
+
+If the transaction does not complete, the currency must be erased from `rates`.
+This can be done with __scope_guard__ and __lambda__ (or __phoenix__):
+
+ using namespace boost::lambda;
+
+ ON_BLOCK_EXIT(
+ if_(currency_rate_inserted && !_1) [
+ bind(
+ static_cast<
+ std::map<std::string, double>::size_type
+ (std::map<std::string, double>::*)(std::string const&)
+ >(&std::map<std::string, double>::erase)
+ , &rates
+ , currency
+ )
+ ]
+ , boost::cref(commit)
+ );
+
+ // ...
+
+ commit = true;
+
+Note the following issues with this approach:
+
+* __lambda__ expressions are hard to write correctly (e.g., overloaded functions must be explicitly casted, as demonstrated in the example above).
+* The condition in the `if_` expression refers to `commit` variable indirectly through the `_1` placeholder reducing readability.
+* Setting a breakpoint inside `if_[...]` requires in-depth knowledge of __lambda__ and debugging techniques.
+
+This code will look much better with C++11 lambdas:
+
+ ON_BLOCK_EXIT(
+ [currency_rate_inserted, &commit, &rates, ¤cy]() -> void
+ {
+ if(currency_rate_inserted && !commit) rates.erase(currency);
+ }
+ );
+
+ // ...
+
+ commit = true;
+
+With __scope_exit__ we can simply do the following (see also [@../../example/scope_guard.cpp "scope_guard.cpp"]):
+
+[example_scope_guard_exit]
+
+[endsect]
+
+[section The D Programming Language]
+
+__scope_exit__ is similar to __D_scope_exit__ feature built into the __D__ programming language.
+
+A curious reader may notice that the library does not implement `scope(success)` and `scope(failure)` of the __D__ language.
+Unfortunately, these are not possible in C++ because failure or success conditions cannot be determined by calling `std::uncaught_exception` (see [@http://www.gotw.ca/gotw/047.htm Guru of the Week #47] for more details about `std::uncaught_exception` and if it has any good use at all).
+However, this is not a big problem because these two __D__'s constructs can be expressed in terms of __D_scope_exit__ and a `bool commit` variable as explained in the __Tutorial__ section.
+
+[endsect]
+
+[section C++11 Lambdas]
+
+Using C++11 lambdas, it is relatively easy to implement the __scope_exit__ construct.
+For example (see also [@../../test/world_commit_lambda.cpp "world_commit_lambda.cpp"]):
+
+[test_world_commit_lambda]
+
+However, this library allows to program the __scope_exit__ construct in a way that is portable between C++03 and C++11 compilers.
+
+[endsect]
+
+[endsect]
+
+[section:No_Variadic_Macros Annex: No Variadic Macros]
+
+This section presents an alternative syntax for compilers without variadic macro support.
+
+[section Sequence Syntax]
+
+Most modern compilers support variadic macros (notably, these include GCC, MSVC, and all C++11 compilers).
+However, in the rare case that programmers need to use __scope_exit__ on a complier that does not support variaidc macros, this library also allows to specify the capture list using a __pp_seq__:
+
+ (capture1) (capture2) ...
+
+Instead of a comma-separated list:
+
+ capture1, capture2, ...
+
+For example, the following syntax is accepted on all compilers with and without variadic macro support (see also [@../../test/world_seq.cpp "world_seq.cpp"]):
+
+[test_world_seq]
+
+Furthermore, older versions of this library used to only support the __pp_seq__ syntax so the above syntax is also supported for backward compatibility.
+However, in the current version of this library and on compilers with variadic macro support, the following syntax is preferred (see also [@../../test/world.cpp "world.cpp"]):
+[footnote
+Note that on compilers with variadic macro support, the same [macroref BOOST_SCOPE_EXIT] macro accepts both a comma-separated list and a __pp_seq__ for specifying the capture list.
+The same it true also for the [macroref BOOST_SCOPE_EXIT_TPL] and [macroref BOOST_SCOPE_EXIT_ALL] macros.
+]
+
+[test_world]
+
+An empty capture list is always specified using `void` on compilers with and without variaidc macro support.
+
+[endsect]
+
+[section Examples]
+
+The following is a list of most of the examples presented in this documentation reprogrammed using the __pp_seq__ syntax instead of comma-separated lists:
+[@../../test/world_commit_seq.cpp "world_commit_seq.cpp"],
+[@../../test/world_commit_this_seq.cpp "world_commit_this_seq.cpp"],
+[@../../test/world_all_seq.cpp "world_all_seq.cpp"],
+[@../../test/world_commit_tpl_seq.cpp "world_commit_tpl_seq.cpp"],
+[@../../example/try_catch_seq.cpp "try_catch_seq.cpp"],
+[@../../example/scope_guard_seq.cpp "scope_guard_seq.cpp"].
+
+[endsect]
+
+[endsect]
+
+
+[xinclude reference.xml]
+
+[section Acknowledgements]
+
+['In chronological order.]
+
+Maxim Yegorushkin for sharing code where he used a local struct to clean up resources.
+
+Andrei Alexandrescu for pointing out the __D_scope_exit__ construct of the __D__ programming language.
+
+Pavel Vozenilek and Maxim Yanchenko for reviews of early drafts of the library.
+
+Steven Watanabe for his valuable ideas.
+
+Jody Hagins for good comments that helped to significantly improve the documentation.
+
+Richard Webb for testing the library on MSVC compiler.
+
+Adam Butcher for a workaround to error C2355 when deducing the type of `this` on some MSVC versions.
+
+[endsect]
Added: sandbox/closure/libs/scope_exit/example/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/example/Jamfile.v2 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,11 @@
+
+import testing ;
+
+test-suite boost_scope_exit_examples :
+ [ run try_catch.cpp ]
+ [ run try_catch_seq.cpp ]
+
+ [ run scope_guard.cpp ]
+ [ run scope_guard_seq.cpp ]
+;
+
Added: sandbox/closure/libs/scope_exit/example/scope_guard.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/example/scope_guard.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,30 @@
+
+#include <boost/scope_exit.hpp>
+#include <map>
+#include <string>
+#include <utility>
+
+int main(void) {
+ //[example_scope_guard_decl
+ bool commit = false;
+ std::string currency("EUR");
+ double rate = 1.3326;
+ std::map<std::string, double> rates;
+ bool currency_rate_inserted =
+ rates.insert(std::make_pair(currency, rate)).second;
+ // Transaction...
+ //]
+
+ //[example_scope_guard_exit
+ BOOST_SCOPE_EXIT(currency_rate_inserted, &commit, &rates, ¤cy) {
+ if(currency_rate_inserted && !commit) rates.erase(currency);
+ } BOOST_SCOPE_EXIT_END
+
+ // ...
+
+ commit = true;
+ //]
+
+ return 0;
+}
+
Added: sandbox/closure/libs/scope_exit/example/scope_guard_seq.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/example/scope_guard_seq.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,27 @@
+
+#include <boost/scope_exit.hpp>
+#include <map>
+#include <string>
+#include <utility>
+
+int main(void) {
+ bool commit = false;
+ std::string currency("EUR");
+ double rate = 1.3326;
+ std::map<std::string, double> rates;
+ bool currency_rate_inserted =
+ rates.insert(std::make_pair(currency, rate)).second;
+
+ BOOST_SCOPE_EXIT( (currency_rate_inserted) (&commit) (&rates)
+ (¤cy) ) {
+ if(currency_rate_inserted && !commit)
+ rates.erase(currency);
+ } BOOST_SCOPE_EXIT_END
+
+ // ...
+
+ commit = true;
+
+ return 0;
+}
+
Added: sandbox/closure/libs/scope_exit/example/try_catch.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/example/try_catch.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,51 @@
+
+#include <boost/scope_exit.hpp>
+#include <iostream>
+
+struct file {
+ file() : open_(false) {}
+ file(char const* path) : open_(false) { open(path); }
+
+ void open(char const* path) { open_ = true; }
+ void close(void) { open_ = false; }
+
+ bool is_open(void) const { return open_; }
+private:
+ bool open_;
+};
+
+void bad(void) {
+ //[example_try_catch_bad
+ file passwd;
+ try {
+ passwd.open("/etc/passwd");
+ // ...
+ passwd.close();
+ } catch(...) {
+ std::clog << "could not get user info" << std::endl;
+ if(passwd.is_open()) passwd.close();
+ throw;
+ }
+ //]
+}
+
+void good(void) {
+ //[example_try_catch_good
+ try {
+ file passwd("/etc/passwd");
+ BOOST_SCOPE_EXIT(&passwd) {
+ passwd.close();
+ } BOOST_SCOPE_EXIT_END
+ } catch(...) {
+ std::clog << "could not get user info" << std::endl;
+ throw;
+ }
+ //]
+}
+
+int main(void) {
+ bad();
+ good();
+ return 0;
+}
+
Added: sandbox/closure/libs/scope_exit/example/try_catch_seq.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/example/try_catch_seq.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,51 @@
+
+#include <boost/scope_exit.hpp>
+#include <iostream>
+
+struct file {
+ file() : open_(false) {}
+ file(char const* path) : open_(false) { open(path); }
+
+ void open(char const* path) { open_ = true; }
+ void close(void) { open_ = false; }
+
+ bool is_open(void) const { return open_; }
+private:
+ bool open_;
+};
+
+void bad(void) {
+ //[example_try_catch_bad_seq
+ file passwd;
+ try {
+ passwd.open("/etc/passwd");
+ // ...
+ passwd.close();
+ } catch(...) {
+ std::clog << "could not get user info" << std::endl;
+ if(passwd.is_open()) passwd.close();
+ throw;
+ }
+ //]
+}
+
+void good(void) {
+ //[example_try_catch_good_seq
+ try {
+ file passwd("/etc/passwd");
+ BOOST_SCOPE_EXIT( (&passwd) ) {
+ passwd.close();
+ } BOOST_SCOPE_EXIT_END
+ } catch(...) {
+ std::clog << "could not get user info" << std::endl;
+ throw;
+ }
+ //]
+}
+
+int main(void) {
+ bad();
+ good();
+ return 0;
+}
+
Added: sandbox/closure/libs/scope_exit/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/test/Jamfile.v2 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,24 @@
+
+import testing ;
+
+test-suite boost_scope_exit_tests :
+ [ run world.cpp /boost//unit_test_framework ]
+ [ run world_seq.cpp /boost//unit_test_framework ]
+
+ [ run world_commit.cpp /boost//unit_test_framework ]
+ [ run world_commit_seq.cpp /boost//unit_test_framework ]
+
+ [ run world_commit_this.cpp /boost//unit_test_framework ]
+ [ run world_commit_this_seq.cpp /boost//unit_test_framework ]
+
+ [ run world_commit_void.cpp /boost//unit_test_framework ]
+
+ [ run world_all.cpp /boost//unit_test_framework ]
+ [ run world_all_seq.cpp /boost//unit_test_framework ]
+
+ [ run world_commit_tpl.cpp /boost//unit_test_framework ]
+ [ run world_commit_tpl_seq.cpp /boost//unit_test_framework ]
+
+ [ run world_commit_lambda.cpp /boost//unit_test_framework ]
+;
+
Added: sandbox/closure/libs/scope_exit/test/world.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/test/world.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,104 @@
+
+#include <boost/scope_exit.hpp>
+#include <boost/foreach.hpp>
+#include <boost/typeof/typeof.hpp>
+#include <boost/typeof/std/vector.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#define BOOST_TEST_MODULE TestWorld
+#include <boost/test/unit_test.hpp>
+#include <vector>
+#include <iostream>
+#include <sstream>
+
+class person {
+ friend class world;
+public:
+ typedef unsigned int id_t;
+ typedef unsigned int evolution_t;
+
+ person(void) : id_(0), evolution_(0) {}
+
+ friend std::ostream& operator<<(std::ostream& o, person const& p) {
+ return o << "person(" << p.id_ << ", " << p.evolution_ << ")";
+ }
+private:
+ id_t id_;
+ evolution_t evolution_;
+};
+
+BOOST_TYPEOF_REGISTER_TYPE(person)
+
+class world {
+public:
+ typedef unsigned int id_t;
+
+ world(void) : next_id_(1) {}
+
+ void add_person(person const& a_person);
+
+ friend std::ostream& operator<<(std::ostream& o, world const& w) {
+ o << "world(" << w.next_id_ << ", {";
+ BOOST_FOREACH(person const& p, w.persons_) {
+ o << " " << p << ", ";
+ }
+ return o << "})";
+ }
+private:
+ id_t next_id_;
+ std::vector<person> persons_;
+};
+
+BOOST_TYPEOF_REGISTER_TYPE(world)
+
+//[test_world
+void world::add_person(person const& a_person) {
+ persons_.push_back(a_person);
+
+ // This block must be no-throw.
+ person& p = persons_.back();
+ person::evolution_t checkpoint = p.evolution_;
+ BOOST_SCOPE_EXIT(checkpoint, &p, &persons_) {
+ if(checkpoint == p.evolution_) persons_.pop_back();
+ } BOOST_SCOPE_EXIT_END
+
+ // ...
+
+ checkpoint = ++p.evolution_;
+
+ // Assign new identifier to the person.
+ world::id_t const prev_id = p.id_;
+ p.id_ = next_id_++;
+ BOOST_SCOPE_EXIT(checkpoint, &p, &next_id_, prev_id) {
+ if(checkpoint == p.evolution_) {
+ next_id_ = p.id_;
+ p.id_ = prev_id;
+ }
+ } BOOST_SCOPE_EXIT_END
+
+ // ...
+
+ checkpoint = ++p.evolution_;
+}
+//]
+
+BOOST_AUTO_TEST_CASE( test_world ) {
+ person adam, eva;
+ std::ostringstream oss;
+ oss << adam;
+ std::cout << oss.str() << std::endl;
+ BOOST_CHECK( oss.str() == "person(0, 0)" );
+
+ oss.str("");
+ oss << eva;
+ std::cout << oss.str() << std::endl;
+ BOOST_CHECK( oss.str() == "person(0, 0)" );
+
+ world w;
+ w.add_person(adam);
+ w.add_person(eva);
+ oss.str("");
+ oss << w;
+ std::cout << oss.str() << std::endl;
+ BOOST_CHECK( oss.str() == "world(3, { person(1, 2), person(2, 2), })" );
+}
+
Added: sandbox/closure/libs/scope_exit/test/world_all.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/test/world_all.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,114 @@
+
+#include <boost/config.hpp>
+
+#ifndef BOOST_NO_LAMBDAS
+
+#include <boost/scope_exit.hpp>
+#include <boost/foreach.hpp>
+#include <boost/typeof/typeof.hpp>
+#include <boost/typeof/std/vector.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#define BOOST_TEST_MODULE TestWorldAll
+#include <boost/test/unit_test.hpp>
+#include <vector>
+#include <iostream>
+#include <sstream>
+
+class person {
+ friend class world;
+public:
+ typedef unsigned int id_t;
+ typedef unsigned int evolution_t;
+
+ person(void) : id_(0), evolution_(0) {}
+
+ friend std::ostream& operator<<(std::ostream& o, person const& p) {
+ return o << "person(" << p.id_ << ", " << p.evolution_ << ")";
+ }
+private:
+ id_t id_;
+ evolution_t evolution_;
+};
+
+BOOST_TYPEOF_REGISTER_TYPE(person)
+
+class world {
+public:
+ typedef unsigned int id_t;
+
+ world(void) : next_id_(1) {}
+
+ void add_person(person const& a_person);
+
+ friend std::ostream& operator<<(std::ostream& o, world const& w) {
+ o << "world(" << w.next_id_ << ", {";
+ BOOST_FOREACH(person const& p, w.persons_) {
+ o << " " << p << ", ";
+ }
+ return o << "})";
+ }
+private:
+ id_t next_id_;
+ std::vector<person> persons_;
+};
+
+BOOST_TYPEOF_REGISTER_TYPE(world)
+
+//[test_world_all
+void world::add_person(person const& a_person) {
+ persons_.push_back(a_person);
+
+ // This block must be no-throw.
+ person& p = persons_.back();
+ person::evolution_t checkpoint = p.evolution_;
+ BOOST_SCOPE_EXIT_ALL(&, checkpoint, this_) { // Capture all by ref (C++11).
+ if(checkpoint == p.evolution_) this_->persons_.pop_back();
+ } BOOST_SCOPE_EXIT_END
+
+ // ...
+
+ checkpoint = ++p.evolution_;
+
+ // Assign new identifier to the person.
+ world::id_t const prev_id = p.id_;
+ p.id_ = next_id_++;
+ BOOST_SCOPE_EXIT_ALL(=, &p, this) { // Capture all by value, `this` (C++11).
+ if(checkpoint == p.evolution_) {
+ this->next_id_ = p.id_;
+ p.id_ = prev_id;
+ }
+ }; // Use `;` instead of `SCOPE_EXIT_END` (C++11).
+
+ // ...
+
+ checkpoint = ++p.evolution_;
+}
+//]
+
+BOOST_AUTO_TEST_CASE( test_world_all ) {
+ person adam, eva;
+ std::ostringstream oss;
+ oss << adam;
+ std::cout << oss.str() << std::endl;
+ BOOST_CHECK( oss.str() == "person(0, 0)" );
+
+ oss.str("");
+ oss << eva;
+ std::cout << oss.str() << std::endl;
+ BOOST_CHECK( oss.str() == "person(0, 0)" );
+
+ world w;
+ w.add_person(adam);
+ w.add_person(eva);
+ oss.str("");
+ oss << w;
+ std::cout << oss.str() << std::endl;
+ BOOST_CHECK( oss.str() == "world(3, { person(1, 2), person(2, 2), })" );
+}
+
+#else // No lambdas (trivial test).
+
+int main(void) { return 0; }
+
+#endif
+
Added: sandbox/closure/libs/scope_exit/test/world_all_seq.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/test/world_all_seq.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,114 @@
+
+#include <boost/config.hpp>
+
+#ifndef BOOST_NO_LAMBDAS
+
+#include <boost/scope_exit.hpp>
+#include <boost/foreach.hpp>
+#include <boost/typeof/typeof.hpp>
+#include <boost/typeof/std/vector.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#define BOOST_TEST_MODULE TestWorldAllSeq
+#include <boost/test/unit_test.hpp>
+#include <vector>
+#include <iostream>
+#include <sstream>
+
+class person {
+ friend class world;
+public:
+ typedef unsigned int id_t;
+ typedef unsigned int evolution_t;
+
+ person(void) : id_(0), evolution_(0) {}
+
+ friend std::ostream& operator<<(std::ostream& o, person const& p) {
+ return o << "person(" << p.id_ << ", " << p.evolution_ << ")";
+ }
+private:
+ id_t id_;
+ evolution_t evolution_;
+};
+
+BOOST_TYPEOF_REGISTER_TYPE(person)
+
+class world {
+public:
+ typedef unsigned int id_t;
+
+ world(void) : next_id_(1) {}
+
+ void add_person(person const& a_person);
+
+ friend std::ostream& operator<<(std::ostream& o, world const& w) {
+ o << "world(" << w.next_id_ << ", {";
+ BOOST_FOREACH(person const& p, w.persons_) {
+ o << " " << p << ", ";
+ }
+ return o << "})";
+ }
+private:
+ id_t next_id_;
+ std::vector<person> persons_;
+};
+
+BOOST_TYPEOF_REGISTER_TYPE(world)
+
+//[test_world_all_seq
+void world::add_person(person const& a_person) {
+ persons_.push_back(a_person);
+
+ // This block must be no-throw.
+ person& p = persons_.back();
+ person::evolution_t checkpoint = p.evolution_;
+ BOOST_SCOPE_EXIT_ALL( (&) (checkpoint) (this_) ) {
+ if(checkpoint == p.evolution_) this_->persons_.pop_back();
+ } BOOST_SCOPE_EXIT_END
+
+ // ...
+
+ checkpoint = ++p.evolution_;
+
+ // Assign new identifier to the person.
+ world::id_t const prev_id = p.id_;
+ p.id_ = next_id_++;
+ BOOST_SCOPE_EXIT_ALL( (=) (&p) (this) ) {
+ if(checkpoint == p.evolution_) {
+ this->next_id_ = p.id_;
+ p.id_ = prev_id;
+ }
+ };
+
+ // ...
+
+ checkpoint = ++p.evolution_;
+}
+//]
+
+BOOST_AUTO_TEST_CASE( test_world_all_seq ) {
+ person adam, eva;
+ std::ostringstream oss;
+ oss << adam;
+ std::cout << oss.str() << std::endl;
+ BOOST_CHECK( oss.str() == "person(0, 0)" );
+
+ oss.str("");
+ oss << eva;
+ std::cout << oss.str() << std::endl;
+ BOOST_CHECK( oss.str() == "person(0, 0)" );
+
+ world w;
+ w.add_person(adam);
+ w.add_person(eva);
+ oss.str("");
+ oss << w;
+ std::cout << oss.str() << std::endl;
+ BOOST_CHECK( oss.str() == "world(3, { person(1, 2), person(2, 2), })" );
+}
+
+#else // No lambdas (trivial test).
+
+int main(void) { return 0; }
+
+#endif
+
Added: sandbox/closure/libs/scope_exit/test/world_commit.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/test/world_commit.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,38 @@
+
+#include <boost/scope_exit.hpp>
+//#define BOOST_TEST_MODULE TestWorldCommit
+//#include <boost/test/unit_test.hpp>
+#include <vector>
+
+struct person {};
+
+struct world {
+ void add_person(person const& a_person);
+ std::vector<person> persons_;
+};
+
+//[test_world_commit
+void world::add_person(person const& a_person) {
+ bool commit = false;
+
+ persons_.push_back(a_person); // (1) direct action
+ // Following block is executed when the enclosing scope exits.
+ BOOST_SCOPE_EXIT(&commit, &persons_) {
+ if(!commit) persons_.pop_back(); // (2) rollback action
+ } BOOST_SCOPE_EXIT_END
+
+ // ... // (3) other operations
+
+ commit = true; // (4) disable rollback actions
+}
+//]
+
+//BOOST_AUTO_TEST_CASE( test_world_commit ) {
+int main() {
+ world w;
+ person p;
+ w.add_person(p);
+// BOOST_CHECK( w.persons_.size() == 1 );
+ return 0;
+}
+
Added: sandbox/closure/libs/scope_exit/test/world_commit_lambda.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/test/world_commit_lambda.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,53 @@
+
+#include <boost/config.hpp>
+
+#ifndef BOOST_NO_LAMBDAS
+
+#define BOOST_TEST_MODULE TestWorldCommitLambda
+#include <boost/test/unit_test.hpp>
+#include <vector>
+
+struct person {};
+
+struct world {
+ void add_person(person const& a_person);
+ std::vector<person> persons_;
+};
+
+//[test_world_commit_lambda
+#include <functional>
+
+struct scope_exit {
+ scope_exit(std::function<void (void)> f) : f_(f) {}
+ ~scope_exit(void) { f_(); }
+private:
+ std::function<void (void)> f_;
+};
+
+void world::add_person(person const& a_person) {
+ bool commit = false;
+
+ persons_.push_back(a_person);
+ scope_exit on_exit1([&commit, &persons_]() { // Use C++11 lambda.
+ if(!commit) persons_.pop_back();
+ });
+
+ // ...
+
+ commit = true;
+}
+//]
+
+BOOST_AUTO_TEST_CASE( test_world_commit_lambda ) {
+ world w;
+ person p;
+ w.add_person(p);
+ BOOST_CHECK( w.persons_.size() == 1 );
+}
+
+#else // No lambdas (trivial test).
+
+int main(void) { return 0; }
+
+#endif
+
Added: sandbox/closure/libs/scope_exit/test/world_commit_seq.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/test/world_commit_seq.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,37 @@
+
+#include <boost/scope_exit.hpp>
+//#define BOOST_TEST_MODULE TestWorldCommitSeq
+//#include <boost/test/unit_test.hpp>
+#include <vector>
+
+struct person {};
+
+struct world {
+ void add_person(person const& a_person);
+ std::vector<person> persons_;
+};
+
+//[test_world_commit_seq
+void world::add_person(person const& a_person) {
+ bool commit = false;
+
+ persons_.push_back(a_person);
+ BOOST_SCOPE_EXIT( (&commit) (&persons_) ) {
+ if(!commit) persons_.pop_back();
+ } BOOST_SCOPE_EXIT_END
+
+ // ...
+
+ commit = true;
+}
+//]
+
+//BOOST_AUTO_TEST_CASE( test_world_commit_seq ) {
+int main() {
+ world w;
+ person p;
+ w.add_person(p);
+// BOOST_CHECK( w.persons_.size() == 1 );
+ return 0;
+}
+
Added: sandbox/closure/libs/scope_exit/test/world_commit_this.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/test/world_commit_this.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,44 @@
+
+#include <boost/scope_exit.hpp>
+#include <boost/config.hpp>
+#define BOOST_TEST_MODULE TestWorldCommitThis
+#include <boost/test/unit_test.hpp>
+#include <vector>
+
+struct person {};
+
+struct world {
+ void add_person(person const& a_person);
+ std::vector<person> persons_;
+};
+
+void world::add_person(person const& a_person) {
+ bool commit = false;
+
+ persons_.push_back(a_person);
+#ifdef BOOST_NO_LAMBDAS
+ //[test_world_commit_this_
+ BOOST_SCOPE_EXIT(&commit, this_) { // Capture object `this_`.
+ if(!commit) this_->persons_.pop_back();
+ } BOOST_SCOPE_EXIT_END
+ //]
+#else
+ //[test_world_commit_this
+ BOOST_SCOPE_EXIT(&commit, this) { // Use `this` (C++11).
+ if(!commit) this->persons_.pop_back();
+ }; // Use `;` instead of `BOOST_SCOPE_EXIT_END` (C++11).
+ //]
+#endif
+
+ // ...
+
+ commit = true;
+}
+
+BOOST_AUTO_TEST_CASE( test_world_commit_this ) {
+ world w;
+ person p;
+ w.add_person(p);
+ BOOST_CHECK( w.persons_.size() == 1 );
+}
+
Added: sandbox/closure/libs/scope_exit/test/world_commit_this_seq.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/test/world_commit_this_seq.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,44 @@
+
+#include <boost/scope_exit.hpp>
+#include <boost/config.hpp>
+#define BOOST_TEST_MODULE TestWorldCommitThis
+#include <boost/test/unit_test.hpp>
+#include <vector>
+
+struct person {};
+
+struct world {
+ void add_person(person const& a_person);
+ std::vector<person> persons_;
+};
+
+void world::add_person(person const& a_person) {
+ bool commit = false;
+
+ persons_.push_back(a_person);
+#ifdef BOOST_NO_LAMBDAS
+ //[test_world_commit_this_
+ BOOST_SCOPE_EXIT( (&commit) (this_) ) { // Capture object `this_`.
+ if(!commit) this_->persons_.pop_back();
+ } BOOST_SCOPE_EXIT_END
+ //]
+#else
+ //[test_world_commit_this
+ BOOST_SCOPE_EXIT( (&commit) (this) ) { // Use `this` (C++11).
+ if(!commit) this->persons_.pop_back();
+ }; // Use `;` instead of `BOOST_SCOPE_EXIT_END` (C++11).
+ //]
+#endif
+
+ // ...
+
+ commit = true;
+}
+
+BOOST_AUTO_TEST_CASE( test_world_commit_this ) {
+ world w;
+ person p;
+ w.add_person(p);
+ BOOST_CHECK( w.persons_.size() == 1 );
+}
+
Added: sandbox/closure/libs/scope_exit/test/world_commit_tpl.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/test/world_commit_tpl.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,36 @@
+
+#include <boost/scope_exit.hpp>
+#define BOOST_TEST_MODULE TestWorldCommitTpl
+#include <boost/test/unit_test.hpp>
+
+struct person {};
+
+template<typename Person>
+struct world {
+ void add_person(Person const& a_person);
+ std::vector<Person> persons_;
+};
+
+//[test_world_commit_tpl
+template<typename Person>
+void world<Person>::add_person(Person const& a_person) {
+ bool commit = false;
+ persons_.push_back(a_person);
+
+ BOOST_SCOPE_EXIT_TPL(&commit, this_) { // Use `_TPL` postfix.
+ if(!commit) this_->persons_.pop_back();
+ } BOOST_SCOPE_EXIT_END
+
+ // ...
+
+ commit = true;
+}
+//]
+
+BOOST_AUTO_TEST_CASE( test_world_commit_tpl ) {
+ world<person> w;
+ person p;
+ w.add_person(p);
+ BOOST_CHECK( w.persons_.size() == 1 );
+}
+
Added: sandbox/closure/libs/scope_exit/test/world_commit_tpl_seq.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/test/world_commit_tpl_seq.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,36 @@
+
+#include <boost/scope_exit.hpp>
+#define BOOST_TEST_MODULE TestWorldCommitTplSeq
+#include <boost/test/unit_test.hpp>
+
+struct person {};
+
+template<typename Person>
+struct world {
+ void add_person(Person const& a_person);
+ std::vector<Person> persons_;
+};
+
+//[test_world_commit_tpl_seq
+template<typename Person>
+void world<Person>::add_person(Person const& a_person) {
+ bool commit = false;
+ persons_.push_back(a_person);
+
+ BOOST_SCOPE_EXIT_TPL( (&commit) (this_) ) {
+ if(!commit) this_->persons_.pop_back();
+ } BOOST_SCOPE_EXIT_END
+
+ // ...
+
+ commit = true;
+}
+//]
+
+BOOST_AUTO_TEST_CASE( test_world_commit_tpl_seq ) {
+ world<person> w;
+ person p;
+ w.add_person(p);
+ BOOST_CHECK( w.persons_.size() == 1 );
+}
+
Added: sandbox/closure/libs/scope_exit/test/world_commit_void.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/test/world_commit_void.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,36 @@
+
+#include <boost/scope_exit.hpp>
+//#define BOOST_TEST_MODULE TestWorldCommitVoid
+//#include <boost/test/unit_test.hpp>
+#include <vector>
+
+struct person {};
+
+//[test_world_commit_void
+struct world_t {
+ std::vector<person> persons;
+ bool commit;
+} world; // Global variable.
+
+void add_person(person const& a_person) {
+ world.commit = false;
+ world.persons.push_back(a_person);
+
+ BOOST_SCOPE_EXIT(void) { // No captures.
+ if(!world.commit) world.persons.pop_back();
+ } BOOST_SCOPE_EXIT_END
+
+ // ...
+
+ world.commit = true;
+}
+//]
+
+//BOOST_AUTO_TEST_CASE( test_world_commit_void ) {
+int main() {
+ person p;
+ add_person(p);
+// BOOST_CHECK( world.persons.size() == 1 );
+ return 0;
+}
+
Added: sandbox/closure/libs/scope_exit/test/world_seq.cpp
==============================================================================
--- (empty file)
+++ sandbox/closure/libs/scope_exit/test/world_seq.cpp 2012-01-13 11:50:28 EST (Fri, 13 Jan 2012)
@@ -0,0 +1,104 @@
+
+#include <boost/scope_exit.hpp>
+#include <boost/foreach.hpp>
+#include <boost/typeof/typeof.hpp>
+#include <boost/typeof/std/vector.hpp>
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+#define BOOST_TEST_MODULE TestWorldSeq
+#include <boost/test/unit_test.hpp>
+#include <vector>
+#include <iostream>
+#include <sstream>
+
+class person {
+ friend class world;
+public:
+ typedef unsigned int id_t;
+ typedef unsigned int evolution_t;
+
+ person(void) : id_(0), evolution_(0) {}
+
+ friend std::ostream& operator<<(std::ostream& o, person const& p) {
+ return o << "person(" << p.id_ << ", " << p.evolution_ << ")";
+ }
+private:
+ id_t id_;
+ evolution_t evolution_;
+};
+
+BOOST_TYPEOF_REGISTER_TYPE(person)
+
+class world {
+public:
+ typedef unsigned int id_t;
+
+ world(void) : next_id_(1) {}
+
+ void add_person(person const& a_person);
+
+ friend std::ostream& operator<<(std::ostream& o, world const& w) {
+ o << "world(" << w.next_id_ << ", {";
+ BOOST_FOREACH(person const& p, w.persons_) {
+ o << " " << p << ", ";
+ }
+ return o << "})";
+ }
+private:
+ id_t next_id_;
+ std::vector<person> persons_;
+};
+
+BOOST_TYPEOF_REGISTER_TYPE(world)
+
+//[test_world_seq
+void world::add_person(person const& a_person) {
+ persons_.push_back(a_person);
+
+ // This block must be no-throw.
+ person& p = persons_.back();
+ person::evolution_t checkpoint = p.evolution_;
+ BOOST_SCOPE_EXIT( (checkpoint) (&p) (&persons_) ) { // Sequence, not commas.
+ if(checkpoint == p.evolution_) persons_.pop_back();
+ } BOOST_SCOPE_EXIT_END
+
+ // ...
+
+ checkpoint = ++p.evolution_;
+
+ // Assign new identifier to the person.
+ world::id_t const prev_id = p.id_;
+ p.id_ = next_id_++;
+ BOOST_SCOPE_EXIT( (checkpoint) (&p) (&next_id_) (prev_id) ) {
+ if(checkpoint == p.evolution_) {
+ next_id_ = p.id_;
+ p.id_ = prev_id;
+ }
+ } BOOST_SCOPE_EXIT_END
+
+ // ...
+
+ checkpoint = ++p.evolution_;
+}
+//]
+
+BOOST_AUTO_TEST_CASE( test_world_seq ) {
+ person adam, eva;
+ std::ostringstream oss;
+ oss << adam;
+ std::cout << oss.str() << std::endl;
+ BOOST_CHECK( oss.str() == "person(0, 0)" );
+
+ oss.str("");
+ oss << eva;
+ std::cout << oss.str() << std::endl;
+ BOOST_CHECK( oss.str() == "person(0, 0)" );
+
+ world w;
+ w.add_person(adam);
+ w.add_person(eva);
+ oss.str("");
+ oss << w;
+ std::cout << oss.str() << std::endl;
+ BOOST_CHECK( oss.str() == "world(3, { person(1, 2), person(2, 2), })" );
+}
+
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