]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/scope_exit/doc/html/BOOST_SCOPE_EXIT_ALL.html
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / scope_exit / doc / html / BOOST_SCOPE_EXIT_ALL.html
CommitLineData
7c673cae
FG
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4<title>Macro BOOST_SCOPE_EXIT_ALL</title>
5<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
7<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Boost.ScopeExit 1.1.0">
8<link rel="up" href="reference.html#header.boost.scope_exit_hpp" title="Header &lt;boost/scope_exit.hpp&gt;">
9<link rel="prev" href="BOOST_SCOPE_EXIT_ID_TPL.html" title="Macro BOOST_SCOPE_EXIT_ID_TPL">
10<link rel="next" href="BOOST_SCOPE_EXIT_ALL_ID.html" title="Macro BOOST_SCOPE_EXIT_ALL_ID">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
15<td align="center"><a href="../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="BOOST_SCOPE_EXIT_ID_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_ALL_ID.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="refentry">
26<a name="BOOST_SCOPE_EXIT_ALL"></a><div class="titlepage"></div>
27<div class="refnamediv">
28<h2><span class="refentrytitle">Macro BOOST_SCOPE_EXIT_ALL</span></h2>
29<p>BOOST_SCOPE_EXIT_ALL &#8212; This macro declares a scope exit that captures all variables in scope (C++11 only). </p>
30</div>
31<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
32<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="reference.html#header.boost.scope_exit_hpp" title="Header &lt;boost/scope_exit.hpp&gt;">boost/scope_exit.hpp</a>&gt;
33
34</span>BOOST_SCOPE_EXIT_ALL(capture_list)</pre></div>
35<div class="refsect1">
36<a name="id877356"></a><h2>Description</h2>
37<p>This macro accepts a capture list starting with either <code class="computeroutput">&amp;</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>
38<pre class="programlisting"><span class="special">{</span> <span class="comment">// Some local scope.</span>
39 <span class="special">...</span>
40 <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>
41 <span class="special">...</span> <span class="comment">// Body code.</span>
42 <span class="special">}</span><span class="special">;</span> <span class="comment">// Use `;` instead of `BOOST_SCOPE_EXIT_END` (C++11 only).</span>
43 <span class="special">...</span>
44<span class="special">}</span>
45</pre>
46<p>Note how the end of the scope exit body declared by this macro must be marked by a semi-column <code class="computeroutput">;</code> (and not by <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>
47<p><span class="bold"><strong>Warning:</strong></span> This macro is only available on C++11 compilers (specifically, on C++11 compilers that do not define the Boost.Config <code class="computeroutput">BOOST_NO_CXX11_LAMBDAS</code> macro). It is not defined on non-C++11 compilers so its use on non-C++11 compilers will generate a compiler error.</p>
48<p><span class="bold"><strong>Parameters:</strong></span> </p>
49<div class="informaltable"><table class="table">
50<colgroup>
51<col>
52<col>
53</colgroup>
54<tbody><tr>
55<td><span class="bold"><strong><code class="computeroutput">capture_list</code></strong></span></td>
56<td>On compilers that support variadic macros (see also Boost.Config <code class="computeroutput">BOOST_NO_CXX11_VARIADIC_MACROS</code>), 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>
57 <span class="identifier">capture_tuple</span> <span class="special">|</span> <span class="identifier">capture_sequence</span>
58<span class="identifier">capture_tuple</span><span class="special">:</span>
59 <span class="special">{</span><span class="special">&amp;</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>
60<span class="identifier">capture_sequence</span><span class="special">:</span>
61 <span class="special">{</span><span class="special">(</span><span class="special">&amp;</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>
62<span class="identifier">capture</span><span class="special">:</span>
63 <span class="special">[</span><span class="special">&amp;</span><span class="special">]</span><span class="identifier">variable</span> <span class="special">|</span> <span class="identifier">this_</span>
64</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>
65 <span class="keyword">void</span> <span class="special">|</span> <span class="identifier">capture_sequence</span>
66</pre> Furthermore, on C++11 compilers that support the use of <code class="computeroutput">typename</code> outside templates, also <code class="computeroutput">this</code> can be used to capture the object at member function scope: <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>
67 <span class="special">[</span><span class="special">&amp;</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>
68</pre>(Lexical conventions: <code class="computeroutput">token1 | token2</code> means either <code class="computeroutput">token1</code> or <code class="computeroutput">token2</code>; <code class="computeroutput">[token]</code> means either <code class="computeroutput">token</code> or nothing; <code class="computeroutput">{expression}</code> means the token resulting from the expression.) </td>
69</tr></tbody>
70</table></div>
71<p>
72</p>
73<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.</p>
74<p>The capture list must always contain at least the leading <code class="computeroutput">&amp;</code> or <code class="computeroutput">=</code> so it can never be <code class="computeroutput">void</code> (<code class="computeroutput">BOOST_SCOPE_EXIT(void)</code> should be used to program scope exits with an empty capture list).</p>
75<p>In general, the special macro <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_ALL_ID.html" title="Macro BOOST_SCOPE_EXIT_ALL_ID">BOOST_SCOPE_EXIT_ALL_ID</a></code> must be used instead of <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code> when it is necessary to expand multiple scope exit declarations on the same line.</p>
76<p><span class="bold"><strong>Warning:</strong></span> This macro capture list follows the exact same syntax of C++11 lambda captures which is unfortunately different from the syntax of <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> captures (unless programmers define the <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_CONFIG_USE_LAMBDAS.html" title="Macro BOOST_SCOPE_EXIT_CONFIG_USE_LAMBDAS">BOOST_SCOPE_EXIT_CONFIG_USE_LAMBDAS</a></code> macro). For example, like C++11 lambda functions, <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT_ALL.html" title="Macro BOOST_SCOPE_EXIT_ALL">BOOST_SCOPE_EXIT_ALL</a></code> requires to capture data members by capturing the object <code class="computeroutput">this</code> while <code class="computeroutput"><a class="link" href="BOOST_SCOPE_EXIT.html" title="Macro BOOST_SCOPE_EXIT">BOOST_SCOPE_EXIT</a></code> allows to capture data members directly and without capturing the object.</p>
77<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>
78<p><span class="bold"><strong>Note:</strong></span> This macro can always be used also within templates (so there is no need for a <code class="computeroutput">BOOST_SCOPE_EXIT_ALL_TPL</code> macro).</p>
79<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_ALL_ID.html" title="Macro BOOST_SCOPE_EXIT_ALL_ID">BOOST_SCOPE_EXIT_ALL_ID</a></code>. </p>
80</div>
81</div>
82<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
83<td align="left"></td>
84<td align="right"><div class="copyright-footer">Copyright &#169; 2006-2012 Alexander Nasonov, Lorenzo Caminiti<p>
85 Distributed under the Boost Software License, Version 1.0 (see accompanying
86 file LICENSE_1_0.txt or a copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
87 </p>
88</div></td>
89</tr></table>
90<hr>
91<div class="spirit-nav">
92<a accesskey="p" href="BOOST_SCOPE_EXIT_ID_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_ALL_ID.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
93</div>
94</body>
95</html>