3 <title>Smart Pointers - Aspell Developer's Manual</title>
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5 <meta name="description" content="Aspell spell checker developer's manual.">
6 <meta name="generator" content="makeinfo 4.8">
7 <link title="Top" rel="start" href="index.html#Top">
8 <link rel="prev" href="Strings.html#Strings" title="Strings">
9 <link rel="next" href="I_002fO.html#I_002fO" title="I/O">
10 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12 This is the developer's manual for Aspell.
14 Copyright (C) 2002, 2003, 2004, 2006 Kevin Atkinson.
16 Permission is granted to copy, distribute and/or modify this
17 document under the terms of the GNU Free Documentation License,
18 Version 1.1 or any later version published by the Free Software
19 Foundation; with no Invariant Sections, no Front-Cover Texts and
20 no Back-Cover Texts. A copy of the license is included in the
21 section entitled "GNU Free Documentation License".
23 <meta http-equiv="Content-Style-Type" content="text/css">
24 <style type="text/css"><!--
25 pre.display { font-family:inherit }
26 pre.format { font-family:inherit }
27 pre.smalldisplay { font-family:inherit; font-size:smaller }
28 pre.smallformat { font-family:inherit; font-size:smaller }
29 pre.smallexample { font-size:smaller }
30 pre.smalllisp { font-size:smaller }
31 span.sc { font-variant:small-caps }
32 span.roman { font-family:serif; font-weight:normal; }
33 span.sansserif { font-family:sans-serif; font-weight:normal; }
39 <a name="Smart-Pointers"></a>
40 Next: <a rel="next" accesskey="n" href="I_002fO.html#I_002fO">I/O</a>,
41 Previous: <a rel="previous" accesskey="p" href="Strings.html#Strings">Strings</a>,
42 Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
46 <h2 class="chapter">8 Smart Pointers</h2>
48 <p>Smart pointers are used extensively in Aspell to
49 simplify memory management tasks and to avoid memory leaks.
51 <h3 class="section">8.1 CopyPtr</h3>
53 <p>The <code>CopyPtr</code> class makes a deep copy of an object whenever it is
54 copied. The <code>CopyPtr</code> class is defined in <samp><span class="file">copy_ptr.hpp</span></samp>.
55 This header should be included wherever <code>CopyPtr</code> is used. The
56 complete definition of the object <code>CopyPtr</code> is pointing to does
57 not need to be defined at this point. The implementation is defined
58 in <samp><span class="file">copy_ptr-t.hpp</span></samp>. The implementation header file should be
59 included at a point in your code where the class <code>CopyPtr</code> is
60 pointing to is completely defined.
62 <h3 class="section">8.2 ClonePtr</h3>
64 <p><code>ClonePtr</code> is like copy pointer except the <code>clone()</code> method
65 is used instead of the copy constructor to make copies of an object.
66 If is defined in <samp><span class="file">clone_ptr.hpp</span></samp> and implemented in
67 <samp><span class="file">clone_ptr-t.hpp</span></samp>.
69 <h3 class="section">8.3 StackPtr</h3>
71 <p>A <code>StackPtr</code> is designed to be used whenever the only pointer to
72 a new object allocated with <samp><span class="command">new</span></samp> is on the stack. It is
73 similar to the standard C++ <code>auto_ptr</code> but the semantics are a
74 bit different. It is defined in <samp><span class="file">stack_ptr.hpp</span></samp> — unlike
75 <code>CopyPtr</code> or <code>ClonePtr</code> it is defined and implemented in
78 <h3 class="section">8.4 GenericCopyPtr</h3>
80 <p>A generalized version of <code>CopyPtr</code> and <code>ClonePtr</code> which the
81 two are based on. It is defined in <samp><span class="file">generic_copy_ptr.hpp</span></samp> and
82 implemented in <samp><span class="file">generic_copy_ptr-t.hpp</span></samp>.