| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> |
| <title>Chapter 17. Boost.Ref</title> |
| <link rel="stylesheet" href="../../doc/src/boostbook.css" type="text/css"> |
| <meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> |
| <link rel="home" href="index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> |
| <link rel="up" href="libraries.html" title="Part I. The Boost C++ Libraries (BoostBook Subset)"> |
| <link rel="prev" href="boost_random/history_and_acknowledgements.html" title="History and Acknowledgements"> |
| <link rel="next" href="ref/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"><a href="../../index.html">Home</a></td> |
| <td align="center"><a href="../../libs/libraries.htm">Libraries</a></td> |
| <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> |
| <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> |
| <td align="center"><a href="../../more/index.htm">More</a></td> |
| </tr></table> |
| <hr> |
| <div class="spirit-nav"> |
| <a accesskey="p" href="boost_random/history_and_acknowledgements.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.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="ref/reference.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="ref"></a>Chapter 17. Boost.Ref</h2></div> |
| <div><div class="author"><h3 class="author"> |
| <span class="firstname">Jaakko</span> <span class="surname">Järvi</span> |
| </h3></div></div> |
| <div><div class="author"><h3 class="author"> |
| <span class="firstname">Peter</span> <span class="surname">Dimov</span> |
| </h3></div></div> |
| <div><div class="author"><h3 class="author"> |
| <span class="firstname">Douglas</span> <span class="surname">Gregor</span> |
| </h3></div></div> |
| <div><div class="author"><h3 class="author"> |
| <span class="firstname">Dave</span> <span class="surname">Abrahams</span> |
| </h3></div></div> |
| <div><p class="copyright">Copyright © 1999, 2000 Jaakko Järvi</p></div> |
| <div><p class="copyright">Copyright © 2001, 2002 Peter Dimov</p></div> |
| <div><p class="copyright">Copyright © 2002 David Abrahams</p></div> |
| <div><div class="legalnotice"> |
| <a name="id2522575"></a><p>Subject to the Boost Software License, Version 1.0. See |
| accompanying file <code class="filename">LICENSE_1_0.txt</code> or copy at |
| <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>. |
| </p> |
| </div></div> |
| </div></div> |
| <div class="toc"> |
| <p><b>Table of Contents</b></p> |
| <dl> |
| <dt><span class="section"><a href="ref.html#ref.intro">Introduction</a></span></dt> |
| <dt><span class="section"><a href="ref/reference.html">Reference</a></span></dt> |
| <dd><dl><dt><span class="section"><a href="ref/reference.html#header.boost.ref_hpp">Header <boost/ref.hpp></a></span></dt></dl></dd> |
| <dt><span class="section"><a href="ref/ack.html">Acknowledgements</a></span></dt> |
| </dl> |
| </div> |
| <div class="section"> |
| <div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
| <a name="ref.intro"></a>Introduction</h2></div></div></div> |
| <p>The Ref library is a small library that is useful for passing |
| references to function templates (algorithms) that would usually |
| take copies of their arguments. It defines the class template |
| <code class="computeroutput"><a class="link" href="boost/reference_wrapper.html" title="Class template reference_wrapper">boost::reference_wrapper<T></a></code>, |
| two functions |
| <code class="computeroutput">boost::ref</code> and |
| <code class="computeroutput">boost::cref</code> that return |
| instances of <code class="computeroutput">boost::reference_wrapper<T></code>, |
| a function <code class="computeroutput">boost::unwrap_ref</code> |
| that unwraps a <code class="computeroutput">boost::reference_wrapper<T></code> or |
| returns a reference to any other type of object, and the |
| two traits classes |
| <code class="computeroutput"><a class="link" href="boost/is_reference_wrapper.html" title="Class template is_reference_wrapper">boost::is_reference_wrapper<T></a></code> |
| and |
| <code class="computeroutput"><a class="link" href="boost/unwrap_reference.html" title="Class template unwrap_reference">boost::unwrap_reference<T></a></code>.</p> |
| <p>The purpose of |
| <code class="computeroutput">boost::reference_wrapper<T></code> is to |
| contain a reference to an object of type T. It is primarily used to |
| "feed" references to function templates (algorithms) that take their |
| parameter by value.</p> |
| <p>To support this usage, |
| <code class="computeroutput">boost::reference_wrapper<T></code> provides an implicit |
| conversion to <code class="computeroutput">T&</code>. This usually allows the function |
| templates to work on references unmodified.</p> |
| <p><code class="computeroutput">boost::reference_wrapper<T></code> is |
| both CopyConstructible and Assignable (ordinary references are not |
| Assignable).</p> |
| <p>The expression <code class="computeroutput">boost::ref(x)</code> |
| returns a |
| <code class="computeroutput">boost::reference_wrapper<X>(x)</code> where X |
| is the type of x. Similarly, |
| <code class="computeroutput">boost::cref(x)</code> returns a |
| <code class="computeroutput">boost::reference_wrapper<X const>(x)</code>.</p> |
| <p>The expression <code class="computeroutput">boost::unwrap_ref(x)</code> |
| returns a |
| <code class="computeroutput">boost::unwrap_reference<X>::type&</code> where X |
| is the type of x.</p> |
| <p>The expression |
| <code class="computeroutput">boost::is_reference_wrapper<T>::value</code> |
| is true if T is a <code class="computeroutput">reference_wrapper</code>, and |
| false otherwise.</p> |
| <p>The type-expression |
| <code class="computeroutput">boost::unwrap_reference<T>::type</code> is T::type if T |
| is a <code class="computeroutput">reference_wrapper</code>, T otherwise.</p> |
| </div> |
| </div> |
| <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> |
| <td align="left"><p><small>Last revised: June 03, 2009 at 15:36:08 +0100</small></p></td> |
| <td align="right"><div class="copyright-footer"></div></td> |
| </tr></table> |
| <hr> |
| <div class="spirit-nav"> |
| <a accesskey="p" href="boost_random/history_and_acknowledgements.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.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="ref/reference.html"><img src="../../doc/src/images/next.png" alt="Next"></a> |
| </div> |
| </body> |
| </html> |