Minor rewording.

[SVN r33367]
This commit is contained in:
Peter Dimov
2006-03-18 14:58:20 +00:00
parent 24d1e6f8dd
commit 00f744bf1e

View File

@ -1,35 +1,33 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>pointer_to_other.hpp</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1><img src="../../boost.png" alt="boost.png (6897 bytes)" align="middle" WIDTH="277" HEIGHT="86" />Header
<a href="../../boost/pointer_to_other.hpp">boost/pointer_to_other.hpp</a></h1>
<p>The pointer to other utility provides a way, from a source pointer type, to obtain a
pointer of the same type to another pointee type. The utility is defined in <cite><a href="../../boost/pointer_to_other.hpp">
boost/pointer_to_other.hpp</a>.</cite></p>
<p>There is test/example code in <cite><a href="test/pointer_to_other_test.cpp">pointer_to_other_test.cpp</a></cite>.</p>
<h2><a name="contents">Contents</a></h2>
<ul>
<li><a href="#rationale">Rationale</a></li>
<li><a href="#synopsis">Synopsis</a></li>
<li><a href="#example">Example</a></li>
</ul>
<h2><a name="rationale">Rationale</a></h2>
<p>Many times when building pointer independent classes, like memory managers,
allocators, or containers, there is a need to define pointers generically, so that if a
template parameter represents a pointer (for example, a raw or smart pointer to an int),
we can define another pointer of the same type to another pointee (a raw or smart
pointer to a float.)</p>
<pre>template &lt;class IntPtr&gt;
<head>
<title>pointer_to_other.hpp</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
<h1><img src="../../boost.png" alt="boost.png (6897 bytes)" align="middle" WIDTH="277" HEIGHT="86">Header
<a href="../../boost/pointer_to_other.hpp">boost/pointer_to_other.hpp</a></h1>
<p>
The pointer to other utility provides a way, given a source pointer type,
to obtain a pointer of the same type to another pointee type. The utility is
defined in <cite><a href="../../boost/pointer_to_other.hpp">boost/pointer_to_other.hpp</a>.</cite></p>
<p>There is test/example code in <cite><a href="test/pointer_to_other_test.cpp">pointer_to_other_test.cpp</a></cite>.</p>
<h2><a name="contents">Contents</a></h2>
<ul>
<li>
<a href="#rationale">Rationale</a>
<li>
<a href="#synopsis">Synopsis</a>
<li>
<a href="#example">Example</a></li>
</ul>
<h2><a name="rationale">Rationale</a></h2>
<p>When building pointer independent classes, like memory managers, allocators, or
containers, there is often a need to define pointers generically, so that if a
template parameter represents a pointer (for example, a raw or smart pointer to
an int), we can define another pointer of the same type to another pointee (a
raw or smart pointer to a float.)</p>
<pre>template &lt;class IntPtr&gt;
class FloatPointerHolder
{
<em>// Let's define a pointer to a float</em>
@ -37,10 +35,8 @@ class FloatPointerHolder
&lt;IntPtr, float&gt;::type float_ptr_t;
float_ptr_t float_ptr;
};</pre>
<h2><a name="synopsis">Synopsis</a></h2>
<pre>
<h2><a name="synopsis">Synopsis</a></h2>
<pre>
namespace boost {
template&lt;class T, class U&gt;
@ -73,13 +69,10 @@ struct pointer_to_other&lt; T*, U &gt;
};
} <em>// namespace boost</em></pre>
<p>If this definitions are not correct for an specific smart pointer, we can define an
specialization of pointer_to_other.</p>
<h2><a name="example">Example</a></h2>
<pre><em>// Let's define a memory allocator that can
<p>If these definitions are not correct for a specific smart pointer, we can define
a specialization of pointer_to_other.</p>
<h2><a name="example">Example</a></h2>
<pre><em>// Let's define a memory allocator that can
// work with raw and smart pointers</em>
#include &lt;boost/pointer_to_other.hpp&gt;
@ -104,15 +97,12 @@ class memory_allocator
block_ptr_t free_blocks;
};</pre>
<p>As we can see, using pointer_to_other we can create pointer independent code.</p>
<hr />
<p>Last revised: $Date$</p>
<p><small>Copyright 2005 Ion Gazta<74>aga and Peter Dimov.
Use, modification, and distribution are subject to the
Boost Software License, Version 1.0.<br />
(See accompanying file <a href="../../LICENSE_1_0.txt">
LICENSE_1_0.txt</a> or a copy at &lt;
<a href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>&gt;.)</small></p>
</body>
<p>As we can see, using pointer_to_other we can create pointer independent code.</p>
<hr>
<p>Last revised: $Date$</p>
<p><small>Copyright 2005, 2006 Ion Gazta<74>aga and Peter Dimov. Use, modification,
and distribution are subject to the Boost Software License, Version 1.0.<br>
(See accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or a
copy at &lt; <a href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>&gt;.)</small></p>
</body>
</html>