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