]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/phoenix/doc/html/phoenix/modules/bind/binding_member_variables.html
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / phoenix / doc / html / phoenix / modules / bind / binding_member_variables.html
CommitLineData
7c673cae
FG
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4<title>Binding Member Variables</title>
5<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
7<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Phoenix 3.2.0">
8<link rel="up" href="../bind.html" title="Bind">
9<link rel="prev" href="binding_member_functions.html" title="Binding Member Functions">
10<link rel="next" href="compatibility_with_boost_bind.html" title="Compatibility with Boost.Bind">
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="binding_member_functions.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bind.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="compatibility_with_boost_bind.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h4 class="title">
27<a name="phoenix.modules.bind.binding_member_variables"></a><a class="link" href="binding_member_variables.html" title="Binding Member Variables">Binding
28 Member Variables</a>
29</h4></div></div></div>
30<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">bind</span><span class="special">/</span><span class="identifier">bind_member_variable</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
31</pre>
32<p>
33 Member variables can also be bound much like member functions. Member variables
34 are not functions. Yet, like the <a class="link" href="../core/references.html" title="References"><code class="computeroutput"><span class="identifier">ref</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code></a>
35 that acts like a nullary function returning a reference to the data, member
36 variables, when bound, act like a unary function, taking in a pointer or
37 reference to an object as its argument and returning a reference to the
38 bound member variable. For instance, given:
39 </p>
40<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">xyz</span>
41<span class="special">{</span>
42 <span class="keyword">int</span> <span class="identifier">v</span><span class="special">;</span>
43<span class="special">};</span>
44</pre>
45<p>
46 <code class="computeroutput"><span class="identifier">xyz</span><span class="special">::</span><span class="identifier">v</span></code> can be bound as:
47 </p>
48<pre class="programlisting"><span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">xyz</span><span class="special">::</span><span class="identifier">v</span><span class="special">,</span> <span class="identifier">obj</span><span class="special">)</span> <span class="comment">// obj is an xyz object</span>
49</pre>
50<p>
51 As noted, just like the bound member function, a bound member variable
52 also expects the first (and only) argument to be a pointer or reference
53 to an object. The object (reference or pointer) can be lazily bound. Examples:
54 </p>
55<pre class="programlisting"><span class="identifier">xyz</span> <span class="identifier">obj</span><span class="special">;</span>
56<span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">xyz</span><span class="special">::</span><span class="identifier">v</span><span class="special">,</span> <span class="identifier">arg1</span><span class="special">)</span> <span class="comment">// arg1.v</span>
57<span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">xyz</span><span class="special">::</span><span class="identifier">v</span><span class="special">,</span> <span class="identifier">obj</span><span class="special">)</span> <span class="comment">// obj.v</span>
58<span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">xyz</span><span class="special">::</span><span class="identifier">v</span><span class="special">,</span> <span class="identifier">arg1</span><span class="special">)(</span><span class="identifier">obj</span><span class="special">)</span> <span class="special">=</span> <span class="number">4</span> <span class="comment">// obj.v = 4</span>
59</pre>
60</div>
61<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
62<td align="left"></td>
63<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2010, 2014, 2015 Joel de Guzman, Dan Marsden, Thomas
64 Heller, John Fletcher<p>
65 Distributed under the Boost Software License, Version 1.0. (See accompanying
66 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
67 </p>
68</div></td>
69</tr></table>
70<hr>
71<div class="spirit-nav">
72<a accesskey="p" href="binding_member_functions.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../bind.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="compatibility_with_boost_bind.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
73</div>
74</body>
75</html>