1 <?xml version=
"1.0" encoding=
"utf-8" ?>
2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en" lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
6 <meta name=
"generator" content=
"Docutils 0.3.10: http://docutils.sourceforge.net/" />
7 <title>Boost Pointer Container Library
</title>
8 <style type=
"text/css">
11 :Author: David Goodger
12 :Contact: goodger@users.sourceforge.net
15 :Copyright: This stylesheet has been placed in the public domain.
17 Default cascading style sheet for the HTML output of Docutils.
19 See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
20 customize this style sheet.
23 /*
"! important" is used here to override other ``margin-top`` and
24 ``margin-bottom`` styles that are later in the stylesheet or
25 more specific. See http://www.w3.org/TR/CSS1#the-cascade */
27 margin-top:
0 ! important }
29 .last, .with-subtitle {
30 margin-bottom:
0 ! important }
36 text-decoration: none ;
43 margin-bottom:
0.5em }
45 /* Uncomment (and remove this text!) to get bold-faced definition list terms
53 div.abstract p.topic-title {
57 div.admonition, div.attention, div.caution, div.danger, div.error,
58 div.hint, div.important, div.note, div.tip, div.warning {
60 border: medium outset ;
63 div.admonition p.admonition-title, div.hint p.admonition-title,
64 div.important p.admonition-title, div.note p.admonition-title,
65 div.tip p.admonition-title {
67 font-family: sans-serif }
69 div.attention p.admonition-title, div.caution p.admonition-title,
70 div.danger p.admonition-title, div.error p.admonition-title,
71 div.warning p.admonition-title {
74 font-family: sans-serif }
76 /* Uncomment (and remove this text!) to get reduced vertical space in
78 div.compound .compound-first, div.compound .compound-middle {
79 margin-bottom:
0.5em }
81 div.compound .compound-last, div.compound .compound-middle {
90 div.dedication p.topic-title {
97 div.footer, div.header {
106 div.line-block div.line-block {
113 border: medium outset ;
115 background-color: #ffffee ;
120 div.sidebar p.rubric {
121 font-family: sans-serif ;
124 div.system-messages {
127 div.system-messages h1 {
131 border: medium outset ;
134 div.system-message p.system-message-title {
141 h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
142 h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
163 ol.simple, ul.simple {
167 list-style: decimal }
170 list-style: lower-alpha }
173 list-style: upper-alpha }
176 list-style: lower-roman }
179 list-style: upper-roman }
193 white-space: nowrap }
202 font-family: sans-serif ;
207 font-family: sans-serif ;
223 pre.literal-block, pre.doctest-block {
226 background-color: #eeeeee }
229 font-family: sans-serif ;
230 font-style: oblique }
232 span.classifier-delimiter {
233 font-family: sans-serif ;
237 font-family: sans-serif }
240 white-space: nowrap }
248 span.section-subtitle {
249 /* font-size relative to parent (h1..h6 element) */
253 border-left: solid thin gray }
260 margin-bottom:
0.5em }
263 border-left: solid thin black }
265 table.docutils td, table.docutils th,
266 table.docinfo td, table.docinfo th {
267 padding-left:
0.5em ;
268 padding-right:
0.5em ;
269 vertical-align: top }
271 table.docutils th.field-name, table.docinfo th.docinfo-name {
274 white-space: nowrap ;
277 h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
278 h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
282 background-color: #eeeeee }
285 list-style-type: none }
290 <div class=
"document" id=
"boost-pointer-container-library">
291 <h1 class=
"title"><img alt=
"Boost" src=
"boost.png" /> Pointer Container Library
</h1>
292 <div class=
"section">
293 <h1><a id=
"class-ptr-map-adapter" name=
"class-ptr-map-adapter">Class
<tt class=
"docutils literal"><span class=
"pre">ptr_map_adapter
</span></tt></a></h1>
294 <p>This class is used to build custom pointer containers with
295 an underlying map-like container. The interface of the class is an extension
296 of the interface from
<tt class=
"docutils literal"><span class=
"pre">associative_ptr_container
</span></tt>.
</p>
297 <p><strong>Hierarchy:
</strong></p>
299 <li><a class=
"reference" href=
"reversible_ptr_container.html">reversible_ptr_container
</a><ul>
300 <li><a class=
"reference" href=
"associative_ptr_container.html">associative_ptr_container
</a><ul>
301 <li><a class=
"reference" href=
"ptr_set_adapter.html">ptr_set_adapter
</a></li>
302 <li><a class=
"reference" href=
"ptr_multiset_adapter.html">ptr_multiset_adapter
</a></li>
303 <li><tt class=
"docutils literal"><span class=
"pre">ptr_map_adapter
</span></tt></li>
304 <li><a class=
"reference" href=
"ptr_multimap_adapter.html">ptr_multi_map_adapter
</a><ul>
305 <li><a class=
"reference" href=
"ptr_set.html">ptr_set
</a></li>
306 <li><a class=
"reference" href=
"ptr_multiset.html">ptr_multi_set
</a></li>
307 <li><a class=
"reference" href=
"ptr_map.html">ptr_map
</a></li>
308 <li><a class=
"reference" href=
"ptr_multimap.html">ptr_multimap
</a></li>
316 <p><strong>Navigate:
</strong></p>
318 <li><a class=
"reference" href=
"ptr_container.html">home
</a></li>
319 <li><a class=
"reference" href=
"reference.html">reference
</a></li>
321 <p><strong>Synopsis:
</strong></p>
322 <pre class=
"literal-block">
329 class CloneAllocator = heap_clone_allocator
331 class ptr_map_adapter
333 public: //
<a class=
"reference" href=
"#typedefs">typedefs
</a>
334 typedef VoidPtrMap::key_type key_type;
335 typedef T* mapped_type;
336 typedef T
& mapped_reference;
337 typedef const T
& const_mapped_reference;
338 typedef ... value_type;
339 typedef ... reference;
340 typedef ... const_reference;
342 typedef ... const_pointer;
344 public: //
<a class=
"reference" href=
"#modifiers">modifiers
</a>
345 std::pair
<iterator,bool
> insert( key_type
& k, T* x );
346 template
< class U
>
347 std::pair
<iterator,bool
> insert( const key_type
& k, std::auto_ptr
<U
> x );
349 public; //
<a class=
"reference" href=
"#lookup">lookup
</a>
350 T
& operator[]( const key_type
& key );
351 T
& at( const key_type
& key );
352 const T
& at( const key_type
& key ) const;
354 public: //
<a class=
"reference" href=
"#pointer-container-requirements">pointer container requirements
</a>
355 bool transfer( iterator object, ptr_map_adapter
& from );
356 size_type transfer( iterator first, iterator last, ptr_map_adapter
& from );
357 template
< class Range
>
358 size_type transfer( const Range
& r, ptr_map_adapter
& from );
359 size_type transfer( ptr_map_adapter
& from );
361 }; // class 'ptr_map_adapter'
363 } // namespace 'boost'
366 <div class=
"section">
367 <h1><a id=
"semantics" name=
"semantics">Semantics
</a></h1>
368 <div class=
"section">
369 <h2><a id=
"semantics-typedefs" name=
"semantics-typedefs"><span id=
"typedefs"></span>Semantics: typedefs
</a></h2>
370 <p>The following types are implementation defined:
</p>
371 <pre class=
"literal-block">
372 typedef ... value_type;
373 typedef ... reference;
374 typedef ... const_reference;
376 typedef ... const_pointer;
378 <p>However, the structure of the type mimics
<tt class=
"docutils literal"><span class=
"pre">std::pair
</span></tt> s.t. one
379 can use
<tt class=
"docutils literal"><span class=
"pre">first
</span></tt> and
<tt class=
"docutils literal"><span class=
"pre">second
</span></tt> members. The reference-types
380 are not real references and the pointer-types are not real pointers.
381 However, one may still write
</p>
382 <pre class=
"literal-block">
383 map_type::value_type a_value = *m.begin();
384 a_value.second-
>foo();
385 map_type::reference a_reference = *m.begin();
386 a_reference.second-
>foo();
387 map_type::const_reference a_creference = *const_begin(m);
388 map_type::pointer a_pointer =
&*m.begin();
389 a_pointer-
>second-
>foo();
390 map_type::const_pointer a_cpointer =
&*const_begin(m);
392 <p>The difference compared to
<tt class=
"docutils literal"><span class=
"pre">std::map
<Key,T*
></span></tt> is that constness
393 is propagated to the pointer (that is, to
<tt class=
"docutils literal"><span class=
"pre">second
</span></tt>) in
<tt class=
"docutils literal"><span class=
"pre">const_itertor
</span></tt>.
</p>
395 <div class=
"section">
396 <h2><a id=
"semantics-modifiers" name=
"semantics-modifiers"><span id=
"modifiers"></span>Semantics: modifiers
</a></h2>
398 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">std::pair
<iterator,bool
></span> <span class=
"pre">insert(
</span> <span class=
"pre">key_type
&</span> <span class=
"pre">k,
</span> <span class=
"pre">value_type
</span> <span class=
"pre">x
</span> <span class=
"pre">);
</span></tt></p>
401 <li>Requirements:
<tt class=
"docutils literal"><span class=
"pre">x
</span> <span class=
"pre">!=
</span> <span class=
"pre">0</span></tt></li>
402 <li>Effects: Takes ownership of
<tt class=
"docutils literal"><span class=
"pre">x
</span></tt> and insert it iff there is no equivalent of it already. The bool part of the return value indicates insertion and the iterator points to the element with key
<tt class=
"docutils literal"><span class=
"pre">x
</span></tt>.
</li>
403 <li>Throws: bad_pointer if
<tt class=
"docutils literal"><span class=
"pre">x
</span> <span class=
"pre">==
</span> <span class=
"pre">0</span></tt></li>
404 <li>Exception safety: Strong guarantee
</li>
408 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">template
<</span> <span class=
"pre">class
</span> <span class=
"pre">U
</span> <span class=
"pre">></span> <span class=
"pre">std::pair
<iterator,bool
></span> <span class=
"pre">insert(
</span> <span class=
"pre">const
</span> <span class=
"pre">key_type
&</span> <span class=
"pre">k,
</span> <span class=
"pre">std::auto_ptr
<U
></span> <span class=
"pre">x
</span> <span class=
"pre">);
</span></tt></p>
411 <li>Equivalent to (but without the
<tt class=
"docutils literal"><span class=
"pre">const_cast
</span></tt>):
<tt class=
"docutils literal"><span class=
"pre">return
</span> <span class=
"pre">insert(
</span> <span class=
"pre">const_cast
<key_type
&>(k),
</span> <span class=
"pre">x.release()
</span> <span class=
"pre">);
</span></tt></li>
416 <!-- - ``std::pair<iterator,bool> insert( key_type& k, const_reference x );``
418 - Effects: ``return insert( allocate_clone( x ) );``
420 - Exception safety: Strong guarantee -->
422 <div class=
"section">
423 <h2><a id=
"semantics-lookup" name=
"semantics-lookup"><span id=
"lookup"></span>Semantics: lookup
</a></h2>
425 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">T
&</span> <span class=
"pre">operator[](
</span> <span class=
"pre">const
</span> <span class=
"pre">key_type
&</span> <span class=
"pre">key
</span> <span class=
"pre">);
</span></tt></p>
428 <li>Effects: returns the object with key
<tt class=
"docutils literal"><span class=
"pre">key
</span></tt> if it exists; otherwise a new object is allocated and inserted and its reference returned.
</li>
429 <li>Exception-safety: Strong guarantee
</li>
433 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">T
&</span> <span class=
"pre">at(
</span> <span class=
"pre">const
</span> <span class=
"pre">key_type
&</span> <span class=
"pre">key
</span> <span class=
"pre">);
</span></tt></p>
435 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">const
</span> <span class=
"pre">T
&</span> <span class=
"pre">at(
</span> <span class=
"pre">const
</span> <span class=
"pre">key_type
&</span> <span class=
"pre">jey
</span> <span class=
"pre">)
</span> <span class=
"pre">const;
</span></tt></p>
438 <li>Requirement: the key exists
</li>
439 <li>Throws:
<tt class=
"docutils literal"><span class=
"pre">bad_ptr_container_operation
</span></tt> if the key does not exist
</li>
445 <div class=
"section">
446 <h2><a id=
"semantics-pointer-container-requirements" name=
"semantics-pointer-container-requirements"><span id=
"pointer-container-requirements"></span>Semantics: pointer container requirements
</a></h2>
448 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">bool
</span> <span class=
"pre">transfer(
</span> <span class=
"pre">iterator
</span> <span class=
"pre">object,
</span> <span class=
"pre">ptr_map_adapter
&</span> <span class=
"pre">from
</span> <span class=
"pre">);
</span></tt></p>
451 <li>Requirements:
<tt class=
"docutils literal"><span class=
"pre">not
</span> <span class=
"pre">from.empty()
</span></tt></li>
452 <li>Effects: Inserts the object defined by
<tt class=
"docutils literal"><span class=
"pre">object
</span></tt> into the container and remove it from
<tt class=
"docutils literal"><span class=
"pre">from
</span></tt>
453 iff no equivalent object exists.
</li>
454 <li>Returns: whether the object was transfered
</li>
455 <li>Exception safety: Strong guarantee
</li>
459 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">size_type
</span> <span class=
"pre">transfer(
</span> <span class=
"pre">iterator
</span> <span class=
"pre">first,
</span> <span class=
"pre">iterator
</span> <span class=
"pre">last,
</span> <span class=
"pre">ptr__set_adapter
&</span> <span class=
"pre">from
</span> <span class=
"pre">);
</span></tt></p>
462 <li>Requirements:
<tt class=
"docutils literal"><span class=
"pre">not
</span> <span class=
"pre">from.empty()
</span></tt></li>
463 <li>Effects: Inserts the objects defined by the range
<tt class=
"docutils literal"><span class=
"pre">[first,last)
</span></tt> into the container and remove it from
<tt class=
"docutils literal"><span class=
"pre">from
</span></tt>.
464 An object is only transferred if no equivalent object exists.
</li>
465 <li>Returns: the number of transfered objects
</li>
466 <li>Exception safety: Basic guarantee
</li>
470 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">template
<</span> <span class=
"pre">class
</span> <span class=
"pre">Range
</span> <span class=
"pre">></span> <span class=
"pre">void
</span> <span class=
"pre">transfer(
</span> <span class=
"pre">const
</span> <span class=
"pre">Range
&</span> <span class=
"pre">r,
</span> <span class=
"pre">ptr_map_adapter
&</span> <span class=
"pre">from
</span> <span class=
"pre">);
</span></tt></p>
473 <li>Effects:
<tt class=
"docutils literal"><span class=
"pre">return
</span> <span class=
"pre">transfer(
</span> <span class=
"pre">boost::begin(r),
</span> <span class=
"pre">boost::end(r),
</span> <span class=
"pre">from
</span> <span class=
"pre">);
</span></tt></li>
477 <li><p class=
"first"><tt class=
"docutils literal"><span class=
"pre">size_type
</span> <span class=
"pre">transfer(
</span> <span class=
"pre">ptr_set_adapter
&</span> <span class=
"pre">from
</span> <span class=
"pre">);
</span></tt></p>
480 <li>Effects:
<tt class=
"docutils literal"><span class=
"pre">return
</span> <span class=
"pre">transfer(
</span> <span class=
"pre">from.begin(),
</span> <span class=
"pre">from.end(),
</span> <span class=
"pre">from
</span> <span class=
"pre">);
</span></tt>.
</li>
485 <hr><table class=
"docutils field-list" frame=
"void" rules=
"none">
486 <col class=
"field-name" />
487 <col class=
"field-body" />
489 <tr class=
"field"><th class=
"field-name">Copyright:
</th><td class=
"field-body">Thorsten Ottosen
2004-
2006. Use, modification and distribution is subject to the Boost Software License, Version
1.0 (see
<a class=
"reference" href=
"http://www.boost.org/LICENSE_1_0.txt">LICENSE_1_0.txt
</a>).
</td>