ptr_multimap_adapter.rst 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. ++++++++++++++++++++++++++++++++++
  2. |Boost| Pointer Container Library
  3. ++++++++++++++++++++++++++++++++++
  4. .. |Boost| image:: boost.png
  5. Class ``ptr_multimap_adapter``
  6. ------------------------------
  7. This class is used to build custom pointer containers with
  8. an underlying multimap-like container. The interface of the class is an extension
  9. of the interface from ``associative_ptr_container``.
  10. **Hierarchy:**
  11. - `reversible_ptr_container <reversible_ptr_container.html>`_
  12. - `associative_ptr_container <associative_ptr_container.html>`_
  13. - `ptr_set_adapter <ptr_set_adapter.html>`_
  14. - `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
  15. - `ptr_map_adapter <ptr_map_adapter.html>`_
  16. - ``ptr_multi_map_adapter``
  17. - `ptr_set <ptr_set.html>`_
  18. - `ptr_multi_set <ptr_multiset.html>`_
  19. - `ptr_map <ptr_map.html>`_
  20. - `ptr_multimap <ptr_multimap.html>`_
  21. **Navigate:**
  22. - `home <ptr_container.html>`_
  23. - `reference <reference.html>`_
  24. **Synopsis:**
  25. .. parsed-literal::
  26. namespace boost
  27. {
  28. template
  29. <
  30. T,
  31. class VoidPtrMultiMap,
  32. class CloneAllocator = heap_clone_allocator
  33. >
  34. class ptr_multimap_adapter
  35. {
  36. public: // `typedefs`_
  37. typedef VoidPtrMap::key_type key_type;
  38. typedef T* mapped_type;
  39. typedef T& mapped_reference;
  40. typedef const T& const_mapped_reference;
  41. typedef ... value_type;
  42. typedef ... reference;
  43. typedef ... const_reference;
  44. typedef ... pointer;
  45. typedef ... const_pointer;
  46. public: // `modifiers`_
  47. iterator insert( key_type& k, T* x );
  48. template< class U >
  49. iterator insert( const key_type&, compatible-smart-ptr<U> x );
  50. public: // `pointer container requirements`_
  51. void transfer( iterator object, ptr_multimap_adapter& from );
  52. size_type transfer( iterator first, iterator last, ptr_multimap_adapter& from );
  53. template< class Range >
  54. size_type transfer( const Range& r, ptr_multimap_adapter& from );
  55. void transfer( ptr_multimap_adapter& from );
  56. }; // class 'ptr_multimap_adapter'
  57. } // namespace 'boost'
  58. Semantics
  59. ---------
  60. . _`typedefs`:
  61. Semantics: typedefs
  62. ^^^^^^^^^^^^^^^^^^^
  63. The following types are implementation defined::
  64. typedef ... value_type;
  65. typedef ... reference;
  66. typedef ... const_reference;
  67. typedef ... pointer;
  68. typedef ... const_pointer;
  69. However, the structure of the type mimics ``std::pair`` s.t. one
  70. can use ``first`` and ``second`` members. The reference-types
  71. are not real references and the pointer-types are not real pointers.
  72. However, one may still write ::
  73. map_type::value_type a_value = *m.begin();
  74. a_value.second->foo();
  75. map_type::reference a_reference = *m.begin();
  76. a_reference.second->foo();
  77. map_type::const_reference a_creference = *const_begin(m);
  78. map_type::pointer a_pointer = &*m.begin();
  79. a_pointer->second->foo();
  80. map_type::const_pointer a_cpointer = &*const_begin(m);
  81. The difference compared to ``std::map<Key,T*>`` is that constness
  82. is propagated to the pointer (that is, to ``second``) in ``const_itertor``.
  83. .. _`modifiers`:
  84. Semantics: modifiers
  85. ^^^^^^^^^^^^^^^^^^^^
  86. - ``iterator insert( key_type& k, T* x );``
  87. - Requirements: ``x != 0``
  88. - Effects: Takes ownership of ``x`` and returns an iterator pointing to it.
  89. - Throws: bad_pointer if ``x == 0``
  90. - Exception safety: Strong guarantee
  91. - ``template< class U > iterator insert( const key_type& k, compatible-smart-ptr<U> x );``
  92. - Equivalent to (but without the ``const_cast``): ``return insert( const_cast<key_type&>(k), x.release() );``
  93. ..
  94. - ``iterator insert( key_type& k, const_reference x );``
  95. - Effects: ``return insert( allocate_clone( x ) );``
  96. - Exception safety: Strong guarantee
  97. .. _`lookup`:
  98. ..
  99. Semantics: lookup
  100. ^^^^^^^^^^^^^^^^^
  101. - ``reference operator[]( const Key& key );``
  102. - ``const_reference operator[]( const Key& key ) const;``
  103. - Requirements: the key exists
  104. - Effects: returns the object with key ``key``
  105. - Throws: ``bad_ptr_container_operation`` if the key does not exist
  106. .. _`pointer container requirements`:
  107. Semantics: pointer container requirements
  108. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  109. - ``void transfer( iterator object, ptr_multimap_adapter& from );``
  110. - Requirements: ``not from.empty()``
  111. - Effects: Inserts the object defined by ``object`` into the container and remove it from ``from``.
  112. - Postconditions: ``size()`` is one more, ``from.size()`` is one less.
  113. - Exception safety: Strong guarantee
  114. - ``void transfer( iterator first, iterator last, ptr_multimap_adapter& from );``
  115. - Requirements: ``not from.empty()``
  116. - Effects: Inserts the objects defined by the range ``[first,last)`` into the container and remove it from ``from``.
  117. - Postconditions: Let ``N == std::distance(first,last);`` then ``size()`` is ``N`` more, ``from.size()`` is ``N`` less.
  118. - Exception safety: Basic guarantee
  119. - ``template< class Range > void transfer( const Range& r, ptr_multimap_adapter& from );``
  120. - Effects: ``transfer( boost::begin(r), boost::end(r), from );``
  121. - ``void transfer( ptr_multimap_adapter& from );``
  122. - Effects: ``transfer( from.begin(), from.end(), from );``.
  123. - Postconditions: ``from.empty();``
  124. - Exception safety: Basic guarantee
  125. .. raw:: html
  126. <hr>
  127. :Copyright: Thorsten Ottosen 2004-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt__).
  128. __ http://www.boost.org/LICENSE_1_0.txt