~ubuntu-branches/ubuntu/dapper/boost/dapper

« back to all changes in this revision

Viewing changes to libs/ptr_container/doc/faq.html

  • Committer: Bazaar Package Importer
  • Author(s): Domenico Andreoli, Christophe Prud'homme, Domenico Andreoli
  • Date: 2006-01-11 11:11:42 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060111111142-xy6z1i5himlgu8iw
Tags: 1.33.1-2
[ Christophe Prud'homme ]
* Bug fix: "libboost-wave-dev: Dependency on libboost-filesystem-dev
  missing", thanks to Martin v . Löwis (Closes: #346367).

[ Domenico Andreoli ]
* boost/graph/topological_sort.hpp: removed name of unused parameter
  to prevent long compiler warning.  Closes: #347519.
* Applied patch from upstream CVS to fix parsing of valid options
  with a common root.  Closes: #345714.
* libboost-python-dev now correctly depends on python2.4-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
4
<head>
5
5
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
 
<meta name="generator" content="Docutils 0.3.7: http://docutils.sourceforge.net/" />
 
6
<meta name="generator" content="Docutils 0.3.9: http://docutils.sourceforge.net/" />
7
7
<title>Boost Pointer Container Library</title>
8
8
<link rel="stylesheet" href="default.css" type="text/css" />
9
9
</head>
10
10
<body>
11
11
<div class="document" id="boost-pointer-container-library">
12
 
<h1 class="title"><img alt="Boost" src="cboost.gif" /> Pointer Container Library</h1>
 
12
<h1 class="title"><img alt="Boost" src="boost.png" /> Pointer Container Library</h1>
13
13
<h2 class="subtitle" id="faq">FAQ</h2>
14
14
<div class="contents topic" id="contents">
15
15
<ul class="simple">
26
26
</div>
27
27
<div class="section" id="since-a-pointer-container-is-not-copy-constructible-and-assignable-i-cannot-put-them-into-standard-containers-what-do-i-do">
28
28
<h1><a class="toc-backref" href="#id4" name="since-a-pointer-container-is-not-copy-constructible-and-assignable-i-cannot-put-them-into-standard-containers-what-do-i-do">Since a pointer container is not Copy Constructible and Assignable, I cannot put them into standard containers; what do I do?</a></h1>
29
 
<p>Since they are <a class="reference" href="reference.html#the-clonable-concept">Clonable</a>, you simply put them in a pointer container.</p>
 
29
<p>Since they are <a class="reference" href="ptr_container.html#the-clonable-concept">Clonable</a>, you simply put them in a pointer container.</p>
30
30
</div>
31
31
<div class="section" id="calling-assign-is-very-costly-and-i-do-not-really-need-to-store-cloned-objects-i-merely-need-to-overwrite-the-existing-ones-what-do-i-do">
32
 
<h1><a class="toc-backref" href="#id5" name="calling-assign-is-very-costly-and-i-do-not-really-need-to-store-cloned-objects-i-merely-need-to-overwrite-the-existing-ones-what-do-i-do">Calling <tt class="docutils literal"><span class="pre">assign()</span></tt> is very costly and I do not really need to store cloned objects; I merely need to overwrite the existing ones; what do I do?</a></h1>
 
32
<h1><a class="toc-backref" href="#id5" name="calling-assign-is-very-costly-and-i-do-not-really-need-to-store-cloned-objects-i-merely-need-to-overwrite-the-existing-ones-what-do-i-do">Calling <tt class="docutils literal docutils literal"><span class="pre">assign()</span></tt> is very costly and I do not really need to store cloned objects; I merely need to overwrite the existing ones; what do I do?</a></h1>
33
33
<p>Call <tt class="docutils literal"><span class="pre">std::copy(</span> <span class="pre">first,</span> <span class="pre">last,</span> <span class="pre">c.begin()</span> <span class="pre">);</span></tt>.</p>
34
34
</div>
35
35
<div class="section" id="which-mutating-algorithms-are-safe-to-use-with-pointers">
41
41
provided as member functions.   -->
42
42
</div>
43
43
<div class="section" id="why-does-ptr-map-t-insert-replace-take-two-arguments-the-key-and-the-pointer-instead-of-one-std-pair-and-why-is-the-key-passed-by-non-const-reference">
44
 
<h1><a class="toc-backref" href="#id7" name="why-does-ptr-map-t-insert-replace-take-two-arguments-the-key-and-the-pointer-instead-of-one-std-pair-and-why-is-the-key-passed-by-non-const-reference">Why does <tt class="docutils literal"><span class="pre">ptr_map&lt;T&gt;::insert()/replace()</span></tt> take two arguments (the key and the pointer) instead of one <tt class="docutils literal"><span class="pre">std::pair</span></tt>? And why is the key passed by non-const reference?</a></h1>
 
44
<h1><a class="toc-backref" href="#id7" name="why-does-ptr-map-t-insert-replace-take-two-arguments-the-key-and-the-pointer-instead-of-one-std-pair-and-why-is-the-key-passed-by-non-const-reference">Why does <tt class="docutils literal docutils literal"><span class="pre">ptr_map&lt;T&gt;::insert()/replace()</span></tt> take two arguments (the key and the pointer) instead of one <tt class="docutils literal docutils literal"><span class="pre">std::pair</span></tt>? And why is the key passed by non-const reference?</a></h1>
45
45
<p>This is the only way the function can be implemented in an exception-safe 
46
46
manner; since the copy-constructor of the key might throw, and since 
47
47
function arguments are not guaranteed to be evaluated from left to right, 
49
49
Passing the key as a reference achieves just that.</p>
50
50
</div>
51
51
<div class="section" id="when-instantiating-a-pointer-container-with-a-type-t-is-t-then-allowed-to-be-incomplete-at-that-point">
52
 
<h1><a class="toc-backref" href="#id8" name="when-instantiating-a-pointer-container-with-a-type-t-is-t-then-allowed-to-be-incomplete-at-that-point">When instantiating a pointer container with a type <tt class="docutils literal"><span class="pre">T</span></tt>, is <tt class="docutils literal"><span class="pre">T</span></tt> then allowed to be incomplete at that point?</a></h1>
 
52
<h1><a class="toc-backref" href="#id8" name="when-instantiating-a-pointer-container-with-a-type-t-is-t-then-allowed-to-be-incomplete-at-that-point">When instantiating a pointer container with a type <tt class="docutils literal docutils literal"><span class="pre">T</span></tt>, is <tt class="docutils literal docutils literal"><span class="pre">T</span></tt> then allowed to be incomplete at that point?</a></h1>
53
53
<p>No. This is a distinct property of <tt class="docutils literal"><span class="pre">shared_ptr</span></tt> which implies some overhead.</p>
54
54
<p>However, one can leave <tt class="docutils literal"><span class="pre">T</span></tt> incomplete in the header file:</p>
55
55
<pre class="literal-block">
75
75
compared to cloning N objects.</p>
76
76
</div>
77
77
<div class="section" id="what-is-the-polymorphic-class-problem">
78
 
<h1><a class="toc-backref" href="#id10" name="what-is-the-polymorphic-class-problem">What is the <a class="target" id="polymorphic-class-problem" name="polymorphic-class-problem">polymorphic class problem</a>?</a></h1>
 
78
<h1><a class="toc-backref" href="#id10" name="what-is-the-polymorphic-class-problem">What is the <span class="target" id="polymorphic-class-problem">polymorphic class problem</span>?</a></h1>
79
79
<p>The problem refers to the relatively troublesome way C++ supports Object 
80
80
Oriented programming in connection with containers of pointers to 
81
81
polymorphic objects.  In a language without garbage collection, you end up 
95
95
these references: <a class="reference" href="ptr_container.html#references">[11]</a> and <a class="reference" href="ptr_container.html#references">[12]</a>.</p>
96
96
</div>
97
97
<div class="section" id="when-the-stored-pointers-cannot-be-0-how-do-i-allow-this-empty-behavior-anyway">
98
 
<h1><a class="toc-backref" href="#id12" name="when-the-stored-pointers-cannot-be-0-how-do-i-allow-this-empty-behavior-anyway">When the stored pointers cannot be <tt class="docutils literal"><span class="pre">0</span></tt>, how do I allow this &quot;empty&quot; behavior anyway?</a></h1>
 
98
<h1><a class="toc-backref" href="#id12" name="when-the-stored-pointers-cannot-be-0-how-do-i-allow-this-empty-behavior-anyway">When the stored pointers cannot be <tt class="docutils literal docutils literal"><span class="pre">0</span></tt>, how do I allow this &quot;empty&quot; behavior anyway?</a></h1>
99
99
<p>Storing a null-pointer among a list of pointers does not fit well into the Object Oriented paradigm. 
100
100
The most elegant design is to use the Null-Object Pattern where one basically makes a concrete
101
101
class with dummy implementations of the virtual functions. See <a class="reference" href="ptr_container.html#references">[13]</a> for details.</p>