reference.qbk 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517
  1. [/
  2. Copyright 2016-2017 Joaquin M Lopez Munoz.
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt)
  6. ]
  7. [def _AllocatorAwareContainer_ [@http://en.cppreference.com/w/cpp/named_req/AllocatorAwareContainer [* `AllocatorAwareContainer`]]]
  8. [def _Callable_ [@http://en.cppreference.com/w/cpp/named_req/Callable [* `Callable`]]]
  9. [def _Container_ [@http://en.cppreference.com/w/cpp/named_req/Container [* `Container`]]]
  10. [def _CopyAssignable_ [@http://en.cppreference.com/w/cpp/named_req/CopyAssignable [* `CopyAssignable`]]]
  11. [def _CopyInsertable_ [@http://en.cppreference.com/w/cpp/named_req/CopyInsertable [* `CopyInsertable`]]]
  12. [def _DefaultConstructible_ [@http://en.cppreference.com/w/cpp/named_req/DefaultConstructible [* `DefaultConstructible`]]]
  13. [def _InputIterator_ [@http://en.cppreference.com/w/cpp/named_req/InputIterator [* `InputIterator`]]]
  14. [def _INVOKE_ [@http://en.cppreference.com/w/cpp/utility/functional/invoke ['[* `INVOKE`]]]]
  15. [def _MoveAssignable_ [@http://en.cppreference.com/w/cpp/named_req/MoveAssignable [* `MoveAssignable`]]]
  16. [def _MoveInsertable_ [@http://en.cppreference.com/w/cpp/named_req/MoveInsertable [* `MoveInsertable`]]]
  17. [section Reference]
  18. [section Polymorphism models]
  19. [def _polymorphism_model_ [link poly_collection.reference.polymorphism_models polymorphism model]]
  20. The key aspect of dynamic polymorphism is the ability for a value of type `T`
  21. to internally use another value of a possibily different type `U` for the
  22. implementation of a given interface. Base/derived polymorphism is the classic
  23. model of dynamic polymorphism in C++, but not the only possible one.
  24. Formally, a /polymorphism model/ is defined by
  25. * A family *Interface* of permissible interface types and, for each
  26. `I` \u2208 *Interface*, the family *Implementation*(`I`) of types satisfying
  27. `I`.
  28. * For a given interface type `I`, an operation *subobject*(`x`) that maps each
  29. value of an implementation type to its internally used value `y` of a possibly
  30. different implementation type
  31. [footnote This is a metalinguistic definition not directly expressible in C++.
  32. There are equivalent formulations that can indeed be realized in C++, but
  33. they add little to the comprehension of the concepts.].
  34. Static polymorphism is the trivial case where *subobject*(`x`) = `x` for all
  35. `x`. Base/derived polymorphism is characterized by:
  36. * *Interface* = { `Base` : `std::is_polymorphic_v<Base>` }.
  37. * *Implementation*(`Base`) = { `Derived` : `std::is_base_of_v<Base,Derived>` }.
  38. * *subobject*(`x`) = `static_cast<Derived&>(x)` with `typeid(x)==typeid(Derived)`.
  39. [endsect]
  40. [section Polymorphic containers]
  41. [def _PolymorphicContainer_ [link poly_collection.reference.polymorphic_containers [* `PolymorphicContainer`]]]
  42. A /polymorphic container/ is an object that stores objects of some type `T`
  43. implementing a given interface `I` under an implicitly associated polymorphism
  44. model. Polymorphic containers satisfy the requirements for _Container_ and
  45. _AllocatorAwareContainer_ with the following modifications:
  46. * Where it occurs, replace the requirement that `T` be _CopyInsertable_,
  47. _CopyAssignable_, _MoveInsertable_, _MoveAssignable_ or
  48. _EqualityComparable_, with the following semantic clause: may throw if
  49. some subobject in the container is not
  50. _CopyConstructible_ (respectively, _CopyAssignable_, _MoveConstructible_,
  51. _MoveAssignable_, _EqualityComparable_).
  52. * Replace [container.requirements.general]/3 with:
  53. `allocator_type` must have the property that for any type `U`
  54. implementing `I` and the associated type `A` =
  55. `std::allocator_traits<allocator_type>::rebind_alloc<U>`, `U` is
  56. _CopyInsertable_ (respectively _MoveInsertable_) with respect to `A` if and
  57. only if `U` is _CopyConstructible_ (respectively _MoveConstructible_);
  58. all subobjects of type `U` stored in these containers shall be constructed
  59. using the `std::allocator_traits<A>::construct` function and
  60. destroyed using the `std::allocator_traits<A>::destroy` function;
  61. these functions (or their equivalents for a rebound allocator) are called
  62. only for the types of the stored subobjects, not for
  63. any other type (internal or public) used by the container.
  64. [section Polymorphic collections]
  65. [def _PolymorphicCollection_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections [* `PolymorphicCollection`]]]
  66. /Polymorphic collections/ store their objects of type `value_type` in
  67. /segments/ dedicated to each of the types of the contained subojects.
  68. Only objects whose subobjects are of an /acceptable/ type are allowed,
  69. where a type `U` is said to be acceptable if
  70. * it implements the interface associated to the container,
  71. * it is _MoveConstructible_,
  72. * it is _MoveAssignable_ or
  73. [@http://en.cppreference.com/w/cpp/types/is_move_constructible
  74. `std::is_nothrow_move_constructible<U>::value`] is `true`.
  75. Polymorphic collections conform
  76. to the requirements of _PolymorphicContainer_ with the following
  77. modfications and extra guarantees:
  78. * The complexity of `empty()` and `size()` is linear on the number of
  79. segments of the collection.
  80. * `max_size()` is not provided.
  81. * `a==b` evaluates to `true` iff for each non-empty segment of subojects
  82. of type `U` in `a` there is a segment of `U` in `b` with the same size
  83. and equal elements in the same order, and vice versa.
  84. * No exceptions are thrown associated to some subobject type not being
  85. _CopyAssignable_, _MoveConstructible_ or _MoveAssignable_.
  86. A type `U` is said to be /registered/ into the collection if a
  87. (possibly empty) segment for `U` has been created. Registered types
  88. continue to stay so for the duration of the container except if it is
  89. moved from, assigned to, or swapped.
  90. Each segment has an associated capacity indicating the maximum size
  91. that it can attain without reallocation. When the limit
  92. is exceeded (or explicitly through `reserve`) new storage space is
  93. allocated with greater capacity and elements are moved.
  94. Collection traversal goes through the elements of the first segment,
  95. then the second, etc. The order in which segments are visited is
  96. unspecified but remains stable until a new segment is created.
  97. Besides `iterator` and `const_iterator`, there are iterator types
  98. `local_base_iterator` and `local_iterator<U>` (and their `const_`
  99. counterparts) whose objects can be used to iterate over the segment
  100. for `U` (in the same order followed by global traversal).
  101. Local base iterators refer to `value_type`, whereas
  102. (`const_`)`local_iterator<U>` refers to `U`. All local iterators model
  103. _RandomAccessIterator_. Local base iterators may not be used
  104. to iterate across segments, and comparing local base iterators
  105. associated to different segments is undefined behavior. A (const)
  106. local base iterator to a segment for `U` can be explicitly converted
  107. to (`const_`)`local_iterator<U>` pointing to the same position,
  108. and vice versa.
  109. Insertion and erasure do not invalidate iterators (global or local)
  110. except those from the insertion/erasure point to the end of the
  111. affected segment, if its capacity is not exceeded, or all
  112. iterators/references to the segment otherwise
  113. [footnote The global `end()` iterator lies outside any segment, hence
  114. it always remain valid.].
  115. For the description of the remaining requirements of polymorphic collections,
  116. we use the following notation:
  117. * `C` is a polymorphic collection type,
  118. * `c` is an object of type `C`, `cc` is a possibly `const` object of type `C`,
  119. * `al` is a value of type `C::allocator_type`,
  120. * `info` is a `const std::type_info&`,
  121. * `U` is an acceptable type, `Us...` is a template parameter pack of
  122. acceptable types,
  123. * `n` is a value of `size_type`,
  124. * `x` is a value of a type `T` implementing the interface associated to the
  125. collection,
  126. * `args...` is a function parameter pack of types `Args&&...`,
  127. * `it` is a possibly const global iterator of `c`,
  128. * `it1` and `it2` are (same-typed) possibly const global iterators of a `C`
  129. collection other than `c` such that \[`it1`, `it2`) is a valid range.
  130. * `lbit` is a possibly const local base iterator of `c`,
  131. * `lbit1` and `lbit2` are (same-typed) possibly const local base iterators of
  132. a `C` collection other than `c` such that \[`lbit1`, `lbit2`) is a valid range.
  133. * `lit` is a (`const_`)`local_iterator<U>` of `c`,
  134. * `lit1` and `lit2` are (same-typed) (`const_`)`local_iterator<U>`s of
  135. a `C` collection other than `c` such that \[`lit1`, `lit2`) is a valid range,
  136. * `i1` and `i2` are iterators external to `c` referring to `T` such that
  137. \[`i1`, `i2`) is a valid range,
  138. * `j1` and `j2` are iterators external to `c` such that
  139. \[`j1`, `j2`) is a valid range,
  140. * `xit1` and `xit2` are (same-typed) possibly const iterators (global or
  141. local) of `c` such that \[`xit1`, `xit2`) is a valid range.
  142. [section Types]
  143. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.local_base_iterator]
  144. [def _local_base_iterator_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.local_base_iterator `local_base_iterator`]]
  145. `C::local_base_iterator`
  146. _RandomAccessIterator_ with same value type, difference type and pointer and
  147. reference types as `C::iterator`, valid for accessing elements of a given
  148. segment. Implicily convertible to `C::const_local_base_iterator`, explicitly
  149. convertible to `C::local_iterator<U>` if the segment it points to is actually
  150. that for `U`.
  151. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_local_base_iterator]
  152. [def _const_local_base_iterator_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_local_base_iterator `const_local_base_iterator`]]
  153. `C::const_local_base_iterator`
  154. _RandomAccessIterator_ with same value type, difference type and pointer and
  155. reference types as `C::const_iterator`, valid for accessing elements of a given
  156. segment. Explicitly convertible to `C::const_local_iterator<U>` if the segment
  157. it points to is actually that for `U`.
  158. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.local_iterator]
  159. [def _local_iterator_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.local_iterator `local_iterator`]]
  160. `C::local_iterator<U>`
  161. _RandomAccessIterator_ with value type `U`, reference type `U&`, pointer type
  162. `U*` and the same difference type as `C::iterator`, valid for accessing elements
  163. of the segment for `U`. Implicily convertible to `C::const_local_iterator<U>`,
  164. explicitly convertible to `C::local_base_iterator`.
  165. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_local_iterator]
  166. [def _const_local_iterator_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_local_iterator `const_local_iterator`]]
  167. `C::const_local_iterator<U>`
  168. _RandomAccessIterator_ with value type `U`, reference type `const U&`, pointer
  169. type `const U*` and the same difference type as `C::iterator`, valid for
  170. accessing elements of the segment for `U`. Explicitly convertible to
  171. `C::const_local_base_iterator`.
  172. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_base_segment_info]
  173. [def _const_base_segment_info_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_base_segment_info `const_base_segment_info`]]
  174. `C::const_base_segment_info`
  175. _CopyConstructible_ and _CopyAssignable_ type with information about a given
  176. segment of a collection. If `ci` is a possibly `const` object of type
  177. `C::const_base_segment_info` associated to the segment of `c` for `U`, then
  178. * `ci.begin()==c.cbegin(typeid(U))`
  179. * `ci.cbegin()==c.cbegin(typeid(U))`
  180. * `ci.begin<U>()==c.cbegin<U>()`
  181. * `ci.cbegin<U>()==c.cbegin<U>()`
  182. * `ci.end()==c.cend(typeid(U))`
  183. * `ci.cend()==c.cend(typeid(U))`
  184. * `ci.end<U>()==c.cend<U>()`
  185. * `ci.cend<U>()==c.cend<U>()`
  186. * `ci.type_info()==typeid(U)`
  187. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.base_segment_info]
  188. [def _base_segment_info_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.base_segment_info `base_segment_info`]]
  189. `C::base_segment_info`
  190. _CopyConstructible_ and _CopyAssignable_ type publicly derived from
  191. `C::const_base_segment_info` and exposing its public interface. Additionally,
  192. if `i` is an object of type `C::base_segment_info` associated to the
  193. segment of `c` for `U`, then
  194. * `i.begin()==c.begin(typeid(U))`
  195. * `i.begin<U>()==c.begin<U>()`
  196. * `i.end()==c.end(typeid(U))`
  197. * `i.end<U>()==c.end<U>()`
  198. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_segment_info]
  199. [def _const_segment_info_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_segment_info `const_segment_info`]]
  200. `C::const_segment_info<U>`
  201. _CopyConstructible_ and _CopyAssignable_ type with information about the segment
  202. for `U`. If `ci` is a possibly `const` object of type `C::const_segment_info<U>`
  203. associated to the collection `c`, then
  204. * `ci.begin()==c.cbegin<U>()`
  205. * `ci.cbegin()==c.cbegin<U>()`
  206. * `ci.end()==c.cend<U>()`
  207. * `ci.cend()==c.cend<U>()`
  208. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.segment_info]
  209. [def _segment_info_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.segment_info `segment_info`]]
  210. `C::segment_info<U>`
  211. _CopyConstructible_ and _CopyAssignable_ type publicly derived from
  212. `C::const_segment_info<U>` and exposing its public interface. Additionally,
  213. if `i` is an object of type `C::segment_info<U>` associated to the collection
  214. `c`, then
  215. * `i.begin()==c.begin<U>()`
  216. * `i.end()==c.end<U>()`
  217. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.base_segment_info_iterator]
  218. [def _base_segment_info_iterator_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.base_segment_info_iterator `base_segment_info_iterator`]]
  219. `C::base_segment_info_iterator`
  220. _InputIterator_ with value type and reference type `C::base_segment_info`.
  221. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_base_segment_info_iterator]
  222. [def _const_base_segment_info_iterator_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_base_segment_info_iterator `const_base_segment_info_iterator`]]
  223. `C::const_base_segment_info_iterator`
  224. _InputIterator_ with value type and reference type `C::const_base_segment_info`.
  225. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_segment_traversal_info]
  226. [def _const_segment_traversal_info_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.const_segment_traversal_info `const_segment_traversal_info`]]
  227. `C::const_segment_traversal_info`
  228. _CopyConstructible_ and _CopyAssignable_ type with `const` member
  229. functions `begin`/`cbegin` and `end`/`cend` returning
  230. `C::const_base_segment_info_iterator` objects that span over a range
  231. of `C::const_base_segment_info` objects.
  232. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.types.segment_traversal_info]
  233. [def _segment_traversal_info_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.types.segment_traversal_info `segment_traversal_info`]]
  234. `C::segment_traversal_info`
  235. _CopyConstructible_ and _CopyAssignable_ type publicly derived
  236. from with `C::const_segment_traversal_info` and exposing its
  237. public interface. Additionally, provides non-const member
  238. functions `begin` and `end` returning
  239. `C::base_segment_info_iterator` objects that span over an equivalent range
  240. of `C::base_segment_info` objects.
  241. [endsect]
  242. [section Construct/copy/destroy]
  243. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.construct_copy_destroy.range_construction]
  244. `C(j1,j2)`[br]
  245. `C d(j1,j2)`
  246. [*Requires:] `C::allocator_type` is _DefaultConstructible_. \[`j1`, `j2`) can be
  247. inserted into `C`.[br]
  248. [*Effects:] Copy constructs the internal allocator from `C::allocator_type()`.
  249. Internally calls `this->insert(j1,j2)` on construction.
  250. `C(j1,j2,al)`[br]
  251. `C d(j1,j2,al)`
  252. [*Requires:] \[`j1`, `j2`) can be inserted into `C`.[br]
  253. [*Effects:] Copy constructs the internal allocator from `al`.
  254. Internally calls `this->insert(j1,j2)` on construction.
  255. [endsect]
  256. [section Type registration]
  257. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.type_registration.register_types]
  258. [def _register_types_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.type_registration.register_types `register_types`]]
  259. `c.register_types<Us...>()`
  260. [*Effects:] Registers (if needed) each of the indicated types in the
  261. collection.
  262. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.type_registration.is_registered]
  263. [def _is_registered_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.type_registration.is_registered `is_registered`]]
  264. `cc.is_registered(info)`[br]
  265. `cc.is_registered<U>()`
  266. [*Returns:] `true` iff the indicated type is registered in the collection.
  267. [endsect]
  268. [section Iterators]
  269. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.begin]
  270. [def _begin_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.begin `begin`]]
  271. [def _cbegin_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.begin `cbegin`]]
  272. (1) `c.begin(info)`[br]
  273. (2) `c.begin<U>()`[br]
  274. (3) `const_cast<const C&>(c).begin(info)`[br]
  275. (4) `cc.cbegin(info)`[br]
  276. (5) `const_cast<const C&>(c).begin<U>()`[br]
  277. (6) `cc.cbegin<U>()`
  278. [*Returns:] A `local_base_iterator` (1) or `local_iterator<U>` (2) or
  279. `const_local_base_iterator` (3,4) or `const_local_iterator<U>` (5,6) to the
  280. beginning of the segment for the indicated type.[br]
  281. [*Throws:] If the indicated type is not registered.
  282. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.end]
  283. [def _end_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.end `end`]]
  284. [def _cend_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.end `cend`]]
  285. (1) `c.end(info)`[br]
  286. (2) `c.end<U>()`[br]
  287. (3) `const_cast<const C&>(c).end(info)`[br]
  288. (4) `cc.cend(info)`[br]
  289. (5) `const_cast<const C&>(c).end<U>()`[br]
  290. (6) `cc.cend<U>()`
  291. [*Returns:] A `local_base_iterator` (1) or `local_iterator<U>` (2) or
  292. `const_local_base_iterator` (3,4) or `const_local_iterator<U>` (5,6) to the
  293. end of the segment for the indicated type.[br]
  294. [*Throws:] If the indicated type is not registered.
  295. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.segment]
  296. [def _segment_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.segment `segment`]]
  297. (1) `c.segment(info)`[br]
  298. (2) `c.segment<U>()`[br]
  299. (3) `const_cast<const C&>(c).segment(info)`[br]
  300. (4) `const_cast<const C&>(c).segment<U>()`[br]
  301. [*Returns:] A `base_segment_info` (1) or `segment_info<U>` (2) or
  302. `const_base_segment_info` (3) or `const_segment_info<U>` (4) object
  303. referring to the segment for the indicated type.[br]
  304. [*Throws:] If the indicated type is not registered.
  305. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.segment_traversal]
  306. [def _segment_traversal_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.iterators.segment_traversal `segment_traversal`]]
  307. (1) `c.segment_traversal()`[br]
  308. (2) `const_cast<const C&>(c).segment_traversal()`
  309. [*Returns:] A `segment_traversal_info` (1) or `const_segment_traversal_info`
  310. (2) object spanning over a range of segment descriptors for the collection.
  311. The order in which segments are visited matches that of
  312. \[`c.begin()`, `c.end()`).
  313. [endsect]
  314. [section Capacity]
  315. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.empty]
  316. [def _empty_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.empty `empty`]]
  317. `cc.empty(info)`[br]
  318. `cc.empty<U>()`
  319. [*Returns:] `true` iff the segment for the indicated type exists and
  320. is empty.[br]
  321. [*Throws:] If the indicated type is not registered.
  322. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.size]
  323. [def _size_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.size `size`]]
  324. `cc.size(info)`[br]
  325. `cc.size<U>()`
  326. [*Returns:] The size of the segment for the indicated type.[br]
  327. [*Throws:] If the indicated type is not registered.
  328. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.max_size]
  329. [def _max_size_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.max_size `max_size`]]
  330. `cc.max_size(info)`[br]
  331. `cc.max_size<U>()`
  332. [*Returns:] The maximum size attainable by the segment for
  333. the indicated type.[br]
  334. [*Throws:] If the indicated type is not registered.
  335. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.capacity]
  336. [def _capacity_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.capacity `capacity`]]
  337. `cc.capacity(info)`[br]
  338. `cc.capacity<U>()`[br]
  339. [*Returns:] The maximum size that the segment for the indicated type can
  340. attain without requiring reallocation.[br]
  341. [*Throws:] If the indicated type is not registered.
  342. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.reserve]
  343. [def _reserve_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.reserve `reserve`]]
  344. `c.reserve(n)`
  345. [*Effects:] Calls `reserve` with `n` for each of the segments of the
  346. collection.
  347. (1) `c.reserve(info,n)`[br]
  348. (2) `c.reserve<U>(n)`
  349. [*Effects:] Throws if the type indicated by `info` is not registered (1)
  350. or registers `U` if needed (2). If `n` is greater than the current
  351. capacity of the segment for the indicated type, new storage space is allocated
  352. with a capacity of at least `n` and elements are moved there.[br]
  353. [*Complexity:] Linear in the size of the segment if reallocation happens,
  354. constant otherwise.[br]
  355. [*Throws:] `std::length_error` if `n` is greater than the return value of
  356. `max_size` for the segment.
  357. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.shrink_to_fit]
  358. [def _shrink_to_fit_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.capacity.shrink_to_fit `shrink_to_fit`]]
  359. `c.shrink_to_fit()`
  360. [*Effects:] Calls `shrink_to_fit` for each of the segments of the
  361. collection.
  362. `c.shrink_to_fit(info)`[br]
  363. `c.shrink_to_fit<U>()`
  364. [*Effects:] Non-binding request to reduce memory usage while preserving the
  365. sequence of elements of the segment for the indicated type. May invalidate
  366. all iterators and references to the segment.[br]
  367. [*Throws:] If the indicated type is not registered.
  368. [endsect]
  369. [section Modifiers]
  370. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.emplace]
  371. [def _emplace_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.emplace `emplace`]]
  372. [def _emplace_hint_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.emplace `emplace_hint`]]
  373. (1) `c.emplace<U>(args...)`[br]
  374. (2) `c.emplace_hint<U>(it,args...)`
  375. [*Requires:] `U` is constructible from `std::forward<Args>(args)...`.[br]
  376. [*Effects:] Registers `U` (if needed) and inserts a new element with
  377. a subobject constructed from `std::forward<Args>(args)...`: (1) at the end of
  378. the segment for `U`; (2) just before the
  379. position indicated by `it`, if it points to the segment for `U`, or at the
  380. end of the segment for `U` otherwise.[br]
  381. [*Returns:] An `iterator` to the newly inserted element.[br]
  382. [*Complexity:] Amortized constant time plus linear in the distance from the
  383. insertion position to the end of the segment.
  384. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.emplace_pos]
  385. [def _emplace_pos_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.emplace_pos `emplace_pos`]]
  386. (1) `c.emplace_pos<U>(lbit,args...)`[br]
  387. (2) `c.emplace_pos(lit,args...)`
  388. [*Requires:] `U` is constructible from `std::forward<Args>(args)...`.
  389. (1) `lbit` points to the segment for `U`.[br]
  390. [*Effects:] Inserts a new element with
  391. a subobject constructed from `std::forward<Args>(args)...` just before the
  392. position indicated.[br]
  393. [*Returns:] A `local_base_iterator` (1) or `local_iterator<U>` (2) to the
  394. newly inserted element.[br]
  395. [*Complexity:] Amortized constant time plus linear in the distance from
  396. the insertion position to the end of the segment.
  397. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.insert]
  398. [def _insert_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.insert `insert`]]
  399. [def _insert_hint_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.insert `insert`]]
  400. (1) `c.insert(x)`[br]
  401. (2) `c.insert(it,x)`
  402. [*Effects:] Let `Q` be the type of the subobject of `x`. If
  403. `Q` = `T` and `T` is acceptable, registers `T` if needed.
  404. If `Q` = `T` and `T` is not acceptable, throws.
  405. If `Q` \u2260 `T` and `Q` is not registered, throws.
  406. If `x` is not a non-const rvalue expression and `Q` is not _CopyConstructible_, throws.
  407. Inserts an element with a subobject move constructed or copy constructed
  408. from the subobject of `x`: (1) at the end of the corresponding segment;
  409. (2) just before the position indicated by `it`, if it points to the
  410. corresponding segment, or at the end of the segment otherwise.[br]
  411. [*Returns:] An `iterator` to the newly inserted element.[br]
  412. [*Complexity:] Amortized constant time plus linear in the distance
  413. from the insertion position to the end of the segment.
  414. (1) `c.insert(lbit,x)`[br]
  415. (2) `c.insert(lit,x)`
  416. [*Requires:] The type of the subobject of `x` corresponds to the indicated
  417. segment.[br]
  418. [*Effects:] Inserts an element with a subobject move constructed or copy
  419. constructed from the subobject of `x` just before the
  420. position indicated.[br]
  421. [*Returns:] A `local_base_iterator` (1) or `local_iterator<U>` (2) to the
  422. newly inserted element.[br]
  423. [*Complexity:] Amortized constant time plus linear in the distance
  424. from the insertion position to the end of the segment.
  425. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.insert_range]
  426. [def _insert_range_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.insert_range `insert`]]
  427. `c.insert(i1,i2)`
  428. [*Effects:] Equivalent to `while(i1!=i2)c.insert(*i1++)`.
  429. `c.insert(it1,it2)`[br]
  430. `c.insert(lbit1,lbit2)`[br]
  431. `c.insert(lit1,lit2)`
  432. [*Effects:] For each of the elements of the range in succession, registers the
  433. type of its subobject if needed and inserts it into the collection
  434. [footnote Note that, unlike `c.insert(i1,i2)`, these versions do not throw
  435. due to type registration problems.].
  436. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.insert_hint_range]
  437. [def _insert_hint_range_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.insert_hint_range `insert`]]
  438. `c.insert(it,i1,i2)`
  439. [*Effects:] If `it==c.end()`, equivalent to `while(i1!=i2)c.insert(it,*i1++)`,
  440. otherwise inserts each of the elements in \[`i1`, `i2`) in succession with a hint
  441. pointing to `*it`
  442. [footnote That is, the hint remains stable even if `it` may become invalid due
  443. to reallocations.].
  444. `c.insert(it,it1,it2)`[br]
  445. `c.insert(it,lbit1,lbit2)`[br]
  446. `c.insert(it,lit1,lit2)`
  447. [*Effects:] If `it==c.end()`, equivalent to the corresponding hint-less version,
  448. otherwise for each of the elements in \[`i1`, `i2`) in succession registers the
  449. type of its subobject if needed and inserts it into the collection with a hint
  450. pointing to `*it`
  451. [footnote The two previous notes apply here.].
  452. `c.insert(lbit,i1,i2)`
  453. [*Requires:] The subojects of elements in \[`i1`, `i2`) are all of the type
  454. corresponding to the indicated segment.[br]
  455. [*Effects:] Inserts a range of elements with subobjects copy constructed from
  456. those in \[`i1`, `i2`) just before `lbit`.[br]
  457. [*Returns:] A `local_base_iterator` to the beginning of the inserted range.
  458. `c.insert(lit,j1,j2)`
  459. [*Requires:] For each value `x` in \[`j1`, `j2`) either (a) `x` is of a type
  460. implementing the interface associated to the collection and the subobject of
  461. `x` is of type `U` or (b) `U` is constructible from `x`.[br]
  462. [*Effects:] Inserts a range of elements with subobjects copy
  463. constructed (a) or constructed (b) from the values in \[`j1`, `j2`)
  464. just before `lit`.[br]
  465. [*Returns:] A `local_iterator<U>` to the beginning of the inserted range.
  466. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.erase]
  467. [def _erase_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.erase `erase`]]
  468. `c.erase(xit1)`[br]
  469. `c.erase(xit1,xit2)`
  470. [*Effects:] Erases the indicated element(s).[br]
  471. [*Returns:] A non-const iterator of the same category as `xit` pointing
  472. to the position just after the erased element(s).[br]
  473. [*Complexity:] Linear on the number of elements erased plus the distance
  474. from the last one to the end of its segment.
  475. [#poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.clear]
  476. [def _clear_ [link poly_collection.reference.polymorphic_containers.polymorphic_collections.modifiers.clear `clear`]]
  477. `c.clear()`
  478. [*Effects:] Erases all the elements of the container.[br]
  479. [*Complexity:] Linear.
  480. `c.clear(info)`[br]
  481. `c.clear<U>()`
  482. [*Effects:] Erases all the elements of the segment for the indicated type.[br]
  483. [*Complexity:] Linear in the size of the segment.[br]
  484. [*Throws:] If the indicated type is not registered.
  485. [endsect]
  486. [endsect]
  487. [endsect]
  488. [import poly_collection_synopsis.qbk] [/ template poly_collection_synopsis]
  489. [section Header `"boost/poly_collection/exception.hpp"` synopsis]
  490. All the collections in Boost.PolyCollection use the following exceptions
  491. (and only these) to signal various run-time problems with contained types:
  492. namespace boost{
  493. namespace poly_collection{
  494. struct ``[link poly_collection.reference.header_boost_poly_collection_exc.class_unregistered_type unregistered_type]``;
  495. struct ``[link poly_collection.reference.header_boost_poly_collection_exc.class_not_copy_constructible not_copy_constructible]``;
  496. struct ``[link poly_collection.reference.header_boost_poly_collection_exc.class_not_equality_comparable not_equality_comparable]``;
  497. } /* namespace poly_collection */
  498. } /* namespace boost */
  499. [section Class `unregistered_type`]
  500. struct unregistered_type:std::logic_error
  501. {
  502. unregistered_type(const std::type_info& info);
  503. const std::type_info* pinfo;
  504. };
  505. `unregistered_type` is thrown when an operation is requested on a type which
  506. does not yet have an associated segment.
  507. `unregistered_type(const std::type_info& info);`
  508. [*Effects:] Constructs an `unregistered_type` object with the specified type
  509. information.
  510. [endsect]
  511. [section Class `not_copy_constructible`]
  512. struct not_copy_constructible:std::logic_error
  513. {
  514. not_copy_constructible(const std::type_info& info);
  515. const std::type_info* pinfo;
  516. };
  517. `not_copy_constructible` is thrown when a copy operation is tried that
  518. involves a non-_CopyConstructible_ type.
  519. `not_copy_constructible(const std::type_info& info);`
  520. [*Effects:] Constructs a `not_copy_constructible` object with the specified
  521. type information.
  522. [endsect]
  523. [section Class `not_equality_comparable`]
  524. struct not_equality_comparable:std::logic_error
  525. {
  526. not_equality_comparable(const std::type_info& info);
  527. const std::type_info* pinfo;
  528. };
  529. `not_equality_comparable` is thrown when comparing two collections
  530. for (in)equality involves a non-_EqualityComparable_ type.
  531. `not_equality_comparable(const std::type_info& info);`
  532. [*Effects:] Constructs a `not_equality_comparable` object with the specified
  533. type information.
  534. [endsect]
  535. [endsect]
  536. [section Header `"boost/poly_collection/base_collection_fwd.hpp"` synopsis]
  537. [def _base_collection_ [link poly_collection.reference.header_boost_poly_collection_ba0.class_template_base_collection `base_collection`]]
  538. #include <memory>
  539. namespace boost{
  540. namespace poly_collection{
  541. template<typename Base,typename Allocator=std::allocator<Base>>
  542. class _base_collection_;
  543. template<typename Base,typename Allocator>
  544. bool operator==(
  545. const base_collection<Base,Allocator>& x,
  546. const base_collection<Base,Allocator>& y);
  547. template<typename Base,typename Allocator>
  548. bool operator!=(
  549. const base_collection<Base,Allocator>& x,
  550. const base_collection<Base,Allocator>& y);
  551. template<typename Base,typename Allocator>
  552. void swap(
  553. base_collection<Base,Allocator>& x,base_collection<Base,Allocator>& y);
  554. } /* namespace poly_collection */
  555. using poly_collection::base_collection;
  556. } /* namespace boost */
  557. Forward declares the class template _base_collection_
  558. and specifies its default template arguments. Forward declares associated free
  559. functions and brings `boost::poly_collection::base_collection` to the `boost`
  560. namespace.
  561. [endsect]
  562. [section Header `"boost/poly_collection/base_collection.hpp"` synopsis]
  563. #include <boost/poly_collection/base_collection_fwd.hpp>
  564. namespace boost{
  565. namespace poly_collection{
  566. template<typename Base,typename Allocator>
  567. class _base_collection_;
  568. template<typename Base,typename Allocator>
  569. bool operator==(
  570. const base_collection<Base,Allocator>& x,
  571. const base_collection<Base,Allocator>& y);
  572. template<typename Base,typename Allocator>
  573. bool operator!=(
  574. const base_collection<Base,Allocator>& x,
  575. const base_collection<Base,Allocator>& y);
  576. template<typename Base,typename Allocator>
  577. void swap(
  578. base_collection<Base,Allocator>& x,base_collection<Base,Allocator>& y);
  579. } /* namespace poly_collection */
  580. } /* namespace boost */
  581. [section Class template `base_collection`]
  582. `base_collection<Base,Allocator>` is a _PolymorphicCollection_ associated to
  583. the classic base/derived _polymorphism_model_:
  584. * *Interface* = { `Base` : `std::is_polymorphic_v<Base>` }.
  585. * *Implementation*(`Base`) = { `Derived` : `std::is_base_of_v<Base,Derived>` }.
  586. * *subobject*(`x`) = `static_cast<Derived&>(x)` with `typeid(x)==typeid(Derived)`.
  587. [poly_collection_synopsis `base_collection`..`template<typename Base,typename Allocator>`..`Base`]
  588. [endsect]
  589. [endsect]
  590. [section Header `"boost/poly_collection/function_collection_fwd.hpp"` synopsis]
  591. [def _function_collection_ [link poly_collection.reference.header_boost_poly_collection_fu0.class_template_function_collecti `function_collection`]]
  592. [def _function_collection_value_type_ [link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti `function_collection_value_type`]]
  593. #include <memory>
  594. namespace boost{
  595. namespace poly_collection{
  596. template<typename Signature>
  597. using _function_collection_value_type_=``/implementation-defined/``;
  598. template<
  599. typename Signature,
  600. typename Allocator=std::allocator<function_collection_value_type<Signature>>
  601. >
  602. class _function_collection_;
  603. template<typename Signature,typename Allocator>
  604. bool operator==(
  605. const function_collection<Signature,Allocator>& x,
  606. const function_collection<Signature,Allocator>& y);
  607. template<typename Signature,typename Allocator>
  608. bool operator!=(
  609. const function_collection<Signature,Allocator>& x,
  610. const function_collection<Signature,Allocator>& y);
  611. template<typename Signature,typename Allocator>
  612. void swap(
  613. function_collection<Signature,Allocator>& x,
  614. function_collection<Signature,Allocator>& y);
  615. } /* namespace poly_collection */
  616. using poly_collection::function_collection;
  617. } /* namespace boost */
  618. Defines the alias template _function_collection_value_type_ (the actual type
  619. it refers to, though, is merely forward declared).
  620. Forward declares the class template _function_collection_
  621. and specifies its default template arguments. Forward declares associated free
  622. functions and brings `boost::poly_collection::function_collection` to the
  623. `boost` namespace.
  624. [endsect]
  625. [section Header `"boost/poly_collection/function_collection.hpp"` synopsis]
  626. #include <boost/poly_collection/function_collection_fwd.hpp>
  627. namespace boost{
  628. namespace poly_collection{
  629. // defines the type ``_function_collection_value_type_`` refers to
  630. template<typename Signature,typename Allocator>
  631. class _function_collection_;
  632. template<typename Signature,typename Allocator>
  633. bool operator==(
  634. const function_collection<Signature,Allocator>& x,
  635. const function_collection<Signature,Allocator>& y);
  636. template<typename Signature,typename Allocator>
  637. bool operator!=(
  638. const function_collection<Signature,Allocator>& x,
  639. const function_collection<Signature,Allocator>& y);
  640. template<typename Signature,typename Allocator>
  641. void swap(
  642. function_collection<Signature,Allocator>& x,
  643. function_collection<Signature,Allocator>& y);
  644. } /* namespace poly_collection */
  645. } /* namespace boost */
  646. [section Alias template `function_collection_value_type`]
  647. `function_collection_value_type<Signature>` is the `value_type` of
  648. `boost::function_collection<Signature,Allocator>`, where `Signature` must be a type
  649. of the form `R(Args...)`. `function_collection_value_type<Signature>` wraps a
  650. reference to an object modeling _Callable_ for the given `Signature`. The
  651. interface provided partially replicates that of _std::function_ and adds some
  652. extra facilities.
  653. In what follows, the name [' `function_collection_value_type_impl`]
  654. is used just for explanatory purposes in place of the actual
  655. class template name, which is implementation defined.
  656. template<typename Signature>
  657. using function_collection_value_type=
  658. ``/function_collection_value_type_impl/``<Signature>;
  659. template<typename Signature>
  660. class ``/function_collection_value_type_impl/``;
  661. template<typename R,typename... Args>
  662. class ``/function_collection_value_type_impl/``<R(Args...)>
  663. {
  664. public:
  665. explicit ``[link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.operator_bool operator bool]``()const noexcept;
  666. R ``[link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.operator_call operator()]``(Args... args)const;
  667. const std::type_info& ``[link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.target_type target_type]``()const noexcept;
  668. template<typename T> T* ``[link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.target target]``()noexcept;
  669. template<typename T> const T* ``[link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.target target]``()const noexcept;
  670. operator ``[link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.operator_std_function std::function<R(Args...)>]``()const noexcept;
  671. void* ``[link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.data data]``()noexcept;
  672. const void* ``[link poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.data data]``()const noexcept;
  673. };
  674. [#poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.operator_bool]
  675. `explicit operator bool()const noexcept;`
  676. [*Returns:] `true`.
  677. [#poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.operator_call]
  678. `R operator()(Args... args)const;`
  679. [*Effects:] `_INVOKE_(f,std::forward<Args>(args)...,R)`, where f is the wrapped
  680. callable object.[br]
  681. [*Returns:] Nothing if `R` is `void`, otherwise the return value of
  682. `_INVOKE_(f,std::forward<Args>(args)...,R)`.
  683. [#poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.target_type]
  684. `const std::type_info& target_type()const noexcept;`
  685. [*Returns:] `typeid(T)` where `T` is the type of the wrapped callable object.
  686. [#poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.target]
  687. `template<typename T> T* target()noexcept;`[br]
  688. `template<typename T> const T* target()const noexcept;`
  689. [*Returns:] If `target_type()==typeid(T)` a pointer to the wrapped callable
  690. object, otherwise `nullptr`.
  691. [#poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.operator_std_function]
  692. `operator std::function<R(Args...)>()const noexcept;`
  693. [*Returns:] A `std::function<R(Args...)>` object holding a reference to the
  694. wrapped callable object.
  695. [#poly_collection.reference.header_boost_poly_collection_fu0.alias_template_function_collecti.data]
  696. `void* data()noexcept;`[br]
  697. `const void* data()const noexcept;`
  698. [*Returns:] The address of the wrapped callable object.
  699. [endsect]
  700. [section Class template `function_collection`]
  701. `function_collection<Signature,Allocator>` is a _PolymorphicCollection_ associated to
  702. a dynamic _polymorphism_model_ based on call signature compatibility:
  703. [itemized_list
  704. [*Interface* = { `Signature` : `Signature` = `R(Args...)` }.]
  705. [*Implementation*(`Signature`) = { `Callable` : `std::is_invocable_r_v<R,Callable,Args...>` }.]
  706. [*subobject*(`x`) =[br]
  707. `x.target<T>()` with `typeid(T)==x.target_type()`, if `x` is an instantiation of _function_collection_value_type_,[br]
  708. `x`, otherwise.
  709. ]
  710. ]
  711. [poly_collection_synopsis `function_collection`..`template<typename Signature,typename Allocator>`..`_function_collection_value_type_<Signature>`]
  712. [endsect]
  713. [endsect]
  714. [section Header `"boost/poly_collection/any_collection_fwd.hpp"` synopsis]
  715. [def _any_collection_ [link poly_collection.reference.header_boost_poly_collection_an0.class_template_any_collection `any_collection`]]
  716. [def _any_collection_value_type_ [link poly_collection.reference.header_boost_poly_collection_an0.alias_template_any_collection_va `any_collection_value_type`]]
  717. #include <memory>
  718. namespace boost{
  719. namespace poly_collection{
  720. template<typename Concept>
  721. using _any_collection_value_type_=``/implementation-defined/``;
  722. template<
  723. typename Concept,
  724. typename Allocator=std::allocator<any_collection_value_type<Concept>>
  725. >
  726. class _any_collection_;
  727. template<typename Concept,typename Allocator>
  728. bool operator==(
  729. const any_collection<Concept,Allocator>& x,
  730. const any_collection<Concept,Allocator>& y);
  731. template<typename Concept,typename Allocator>
  732. bool operator!=(
  733. const any_collection<Concept,Allocator>& x,
  734. const any_collection<Concept,Allocator>& y);
  735. template<typename Concept,typename Allocator>
  736. void swap(
  737. any_collection<Concept,Allocator>& x,any_collection<Concept,Allocator>& y);
  738. } /* namespace poly_collection */
  739. using poly_collection::any_collection;
  740. } /* namespace boost */
  741. Defines the alias template _any_collection_value_type_ (the actual type
  742. it refers to, though, is merely forward declared).
  743. Forward declares the class template _any_collection_
  744. and specifies its default template arguments. Forward declares associated free
  745. functions and brings `boost::poly_collection::any_collection` to the
  746. `boost` namespace.
  747. [endsect]
  748. [section Header `"boost/poly_collection/any_collection.hpp"` synopsis]
  749. #include <boost/poly_collection/any_collection_fwd.hpp>
  750. namespace boost{
  751. namespace poly_collection{
  752. // defines the type ``_any_collection_value_type_`` refers to
  753. template<typename Concept,typename Allocator>
  754. class _any_collection_;
  755. template<typename Concept,typename Allocator>
  756. bool operator==(
  757. const any_collection<Concept,Allocator>& x,
  758. const any_collection<Concept,Allocator>& y);
  759. template<typename Concept,typename Allocator>
  760. bool operator!=(
  761. const any_collection<Concept,Allocator>& x,
  762. const any_collection<Concept,Allocator>& y);
  763. template<typename Concept,typename Allocator>
  764. void swap(
  765. any_collection<Concept,Allocator>& x,any_collection<Concept,Allocator>& y);
  766. } /* namespace poly_collection */
  767. } /* namespace boost */
  768. [section Alias template `any_collection_value_type`]
  769. `any_collection_value_type<Concept>` is the `value_type` of
  770. `boost::any_collection<Concept,Allocator>`, where `Concept` is defined according to
  771. the [@boost:/doc/html/boost_typeerasure/conceptdef.html requisites]
  772. of _Boost.TypeErasure_ using
  773. [@boost:/doc/html/boost/type_erasure/_self.html `_self`]
  774. as its [@boost:/doc/html/boost/type_erasure/placeholder.html placeholder].
  775. The alias template definition has the form
  776. template<typename Concept>
  777. using any_collection_value_type=
  778. boost::type_erasure::``[@boost:/doc/html/boost/type_erasure/any.html any]``<Concept2,boost::type_erasure::_self&>;
  779. with `boost::type_erasure::`[@boost:/doc/html/boost/type_erasure/is_subconcept.html `is_subconcept`]`<Concept,Concept2>::value==true`.
  780. The exact definition of `Concept2` is implementation defined.
  781. [endsect]
  782. [section Class template `any_collection`]
  783. `any_collection<Concept,Allocator>` is a _PolymorphicCollection_ associated to
  784. a dynamic _polymorphism_model_ based on _duck_typing_ as implemented by
  785. _Boost.TypeErasure_:
  786. [itemized_list
  787. [*Interface* = { `Concept` :
  788. as [@boost:/doc/html/boost_typeerasure/conceptdef.html specified] by _Boost.TypeErasure_,
  789. using the [@boost:/doc/html/boost/type_erasure/_self.html `_self`]
  790. [@boost:/doc/html/boost/type_erasure/placeholder.html placeholder] }.]
  791. [*Implementation*(`Concept`) = { `Concrete` : `Concrete` satisfies `Concept` }.]
  792. [*subobject*(`x`) =[br]
  793. `boost::type_erasure::`[@boost:/doc/html/boost/type_erasure/any_cast.html `any_cast`]`<T&>(x)`
  794. with `typeid(T)==boost::type_erasure::`[@boost:/doc/html/boost/type_erasure/typeid_of.html `typeid_of`]`(x)`,
  795. if `x` is an instantiation of `boost::type_erasure::`[@boost:/doc/html/boost/type_erasure/any.html `any`]
  796. including [@boost:/doc/html/boost/type_erasure/typeid_.html `typeid_`]`<>`,[br]
  797. `x`, otherwise.
  798. ]
  799. ]
  800. [poly_collection_synopsis `any_collection`..`template<typename Concept,typename Allocator>`..`_any_collection_value_type_<Concept>`]
  801. [endsect]
  802. [endsect]
  803. [section Header `"boost/poly_collection/algorithm.hpp"` synopsis]
  804. namespace boost{
  805. namespace poly_collection{
  806. ``['`// non-modifying sequence operations:`]``
  807. template<typename... Ts,typename PolyCollectionIterator,typename Predicate>
  808. bool all_of(
  809. PolyCollectionIterator first,PolyCollectionIterator last,Predicate pred);
  810. template<typename... Ts,typename PolyCollectionIterator,typename Predicate>
  811. bool any_of(
  812. PolyCollectionIterator first,PolyCollectionIterator last,Predicate pred);
  813. template<typename... Ts,typename PolyCollectionIterator,typename Predicate>
  814. bool none_of(
  815. PolyCollectionIterator first,PolyCollectionIterator last,Predicate pred);
  816. template<typename... Ts,typename PolyCollectionIterator,typename Function>
  817. Function for_each(
  818. PolyCollectionIterator first,PolyCollectionIterator last,Function f);
  819. template<
  820. typename... Ts,typename PolyCollectionIterator,
  821. typename Size,typename Function
  822. >
  823. Iterator for_each_n(
  824. PolyCollectionIterator first,Size n,Function f);
  825. template<typename... Ts,typename PolyCollectionIterator,typename T>
  826. PolyCollectionIterator find(
  827. PolyCollectionIterator first,PolyCollectionIterator last,const T& x);
  828. template<typename... Ts,typename PolyCollectionIterator,typename Predicate>
  829. PolyCollectionIterator find_if(
  830. PolyCollectionIterator first,PolyCollectionIterator last,Predicate pred);
  831. template<typename... Ts,typename PolyCollectionIterator,typename Predicate>
  832. PolyCollectionIterator find_if_not(
  833. PolyCollectionIterator first,PolyCollectionIterator last,Predicate pred);
  834. template<
  835. typename... Ts,typename PolyCollectionIterator,typename ForwardIterator
  836. >
  837. PolyCollectionIterator find_end(
  838. PolyCollectionIterator first1,PolyCollectionIterator last1,
  839. ForwardIterator first2,ForwardIterator last2);
  840. template<
  841. typename... Ts,typename PolyCollectionIterator,
  842. typename ForwardIterator,typename BinaryPredicate
  843. >
  844. PolyCollectionIterator find_end(
  845. PolyCollectionIterator first1,PolyCollectionIterator last1,
  846. ForwardIterator first2,ForwardIterator last2,BinaryPredicate pred);
  847. template<
  848. typename... Ts,typename PolyCollectionIterator,typename ForwardIterator
  849. >
  850. PolyCollectionIterator find_first_of(
  851. PolyCollectionIterator first1,PolyCollectionIterator last1,
  852. ForwardIterator first2,ForwardIterator last2);
  853. template<
  854. typename... Ts,typename PolyCollectionIterator,
  855. typename ForwardIterator,typename BinaryPredicate
  856. >
  857. PolyCollectionIterator find_first_of(
  858. PolyCollectionIterator first1,PolyCollectionIterator last1,
  859. ForwardIterator first2,ForwardIterator last2,BinaryPredicate pred);
  860. template<typename... Ts,typename PolyCollectionIterator>
  861. PolyCollectionIterator adjacent_find(
  862. PolyCollectionIterator first,PolyCollectionIterator last);
  863. template<
  864. typename... Ts,typename PolyCollectionIterator,typename BinaryPredicate
  865. >
  866. PolyCollectionIterator adjacent_find(
  867. PolyCollectionIterator first,PolyCollectionIterator last,
  868. BinaryPredicate pred);
  869. template<typename... Ts,typename PolyCollectionIterator,typename T>
  870. std::ptrdiff_t count(
  871. PolyCollectionIterator first,PolyCollectionIterator last,const T& x);
  872. template<typename... Ts,typename PolyCollectionIterator,typename Predicate>
  873. std::ptrdiff_t count_if(
  874. PolyCollectionIterator first,PolyCollectionIterator last,Predicate pred);
  875. template<
  876. typename... Ts,typename PolyCollectionIterator,typename InputIterator
  877. >
  878. std::pair<PolyCollectionIterator,InputIterator> mismatch(
  879. PolyCollectionIterator first1,PolyCollectionIterator last1,
  880. InputIterator first2);
  881. template<
  882. typename... Ts,typename PolyCollectionIterator,
  883. typename InputIterator,typename BinaryPredicate
  884. >
  885. std::pair<PolyCollectionIterator,InputIterator> mismatch(
  886. PolyCollectionIterator first1,PolyCollectionIterator last1,
  887. InputIterator first2,BinaryPredicate pred);
  888. template<
  889. typename... Ts,typename PolyCollectionIterator,typename InputIterator
  890. >
  891. std::pair<PolyCollectionIterator,InputIterator> mismatch(
  892. PolyCollectionIterator first1,PolyCollectionIterator last1,
  893. InputIterator first2,InputIterator last2);
  894. template<
  895. typename... Ts,typename PolyCollectionIterator,
  896. typename InputIterator,typename BinaryPredicate
  897. >
  898. std::pair<PolyCollectionIterator,InputIterator> mismatch(
  899. PolyCollectionIterator first1,PolyCollectionIterator last1,
  900. InputIterator first2,InputIterator last2,BinaryPredicate pred);
  901. template<
  902. typename... Ts,typename PolyCollectionIterator,typename InputIterator
  903. >
  904. bool equal(
  905. PolyCollectionIterator first1,PolyCollectionIterator last1,
  906. InputIterator first2);
  907. template<
  908. typename... Ts,typename PolyCollectionIterator,
  909. typename InputIterator,typename BinaryPredicate
  910. >
  911. bool equal(
  912. PolyCollectionIterator first1,PolyCollectionIterator last1,
  913. InputIterator first2,BinaryPredicate pred);
  914. template<
  915. typename... Ts,typename PolyCollectionIterator,typename InputIterator
  916. >
  917. bool equal(
  918. PolyCollectionIterator first1,PolyCollectionIterator last1,
  919. InputIterator first2,InputIterator last2);
  920. template<
  921. typename... Ts,typename PolyCollectionIterator,
  922. typename InputIterator,typename BinaryPredicate
  923. >
  924. bool equal(
  925. PolyCollectionIterator first1,PolyCollectionIterator last1,
  926. InputIterator first2,InputIterator last2,BinaryPredicate pred);
  927. template<
  928. typename... Ts,typename PolyCollectionIterator,typename ForwardIterator
  929. >
  930. bool is_permutation(
  931. PolyCollectionIterator first1,PolyCollectionIterator last1,
  932. ForwardIterator first2);
  933. template<
  934. typename... Ts,typename PolyCollectionIterator,
  935. typename ForwardIterator,typename BinaryPredicate
  936. >
  937. bool is_permutation(
  938. PolyCollectionIterator first1,PolyCollectionIterator last1,
  939. ForwardIterator first2,BinaryPredicate pred);
  940. template<
  941. typename... Ts,typename PolyCollectionIterator,typename ForwardIterator
  942. >
  943. bool is_permutation(
  944. PolyCollectionIterator first1,PolyCollectionIterator last1,
  945. ForwardIterator first2,ForwardIterator last2);
  946. template<
  947. typename... Ts,typename PolyCollectionIterator,
  948. typename ForwardIterator,typename BinaryPredicate
  949. >
  950. bool is_permutation(
  951. PolyCollectionIterator first1,PolyCollectionIterator last1,
  952. ForwardIterator first2,ForwardIterator last2,BinaryPredicate pred);
  953. template<
  954. typename... Ts,typename PolyCollectionIterator,typename ForwardIterator
  955. >
  956. PolyCollectionIterator search(
  957. PolyCollectionIterator first1,PolyCollectionIterator last1,
  958. ForwardIterator first2,ForwardIterator last2);
  959. template<
  960. typename... Ts,typename PolyCollectionIterator,
  961. typename ForwardIterator,typename BinaryPredicate
  962. >
  963. PolyCollectionIterator search(
  964. PolyCollectionIterator first1,PolyCollectionIterator last1,
  965. ForwardIterator first2,ForwardIterator last2,BinaryPredicate pred);
  966. template<
  967. typename... Ts,typename PolyCollectionIterator,typename Size,typename T
  968. >
  969. PolyCollectionIterator search_n(
  970. PolyCollectionIterator first1,PolyCollectionIterator last1,
  971. Size count,const T& x);
  972. template<
  973. typename... Ts,typename PolyCollectionIterator,
  974. typename Size,typename T,typename BinaryPredicate
  975. >
  976. PolyCollectionIterator search_n(
  977. PolyCollectionIterator first1,PolyCollectionIterator last1,
  978. Size count,const T& x,BinaryPredicate pred);
  979. ``['`// modifying sequence operations:`]``
  980. template<
  981. typename... Ts,typename PolyCollectionIterator,typename OutputIterator
  982. >
  983. OutputIterator copy(
  984. PolyCollectionIterator first,PolyCollectionIterator last,
  985. OutputIterator res);
  986. template<
  987. typename... Ts,typename PolyCollectionIterator,
  988. typename Size,typename OutputIterator
  989. >
  990. OutputIterator copy_n(
  991. PolyCollectionIterator first,Size count,OutputIterator res);
  992. template<
  993. typename... Ts,typename PolyCollectionIterator,
  994. typename OutputIterator,typename Predicate
  995. >
  996. OutputIterator copy_if(
  997. PolyCollectionIterator first,PolyCollectionIterator last,
  998. OutputIterator res,Predicate pred);
  999. template<
  1000. typename... Ts,typename PolyCollectionIterator,typename OutputIterator
  1001. >
  1002. OutputIterator move(
  1003. PolyCollectionIterator first,PolyCollectionIterator last,
  1004. OutputIterator res);
  1005. template<
  1006. typename... Ts,typename PolyCollectionIterator,
  1007. typename OutputIterator,typename UnaryOperation
  1008. >
  1009. OutputIterator transform(
  1010. PolyCollectionIterator first,PolyCollectionIterator last,
  1011. OutputIterator res,UnaryOperation op);
  1012. template<
  1013. typename... Ts,typename PolyCollectionIterator,
  1014. typename InputIterator,typename OutputIterator,typename BinaryOperation
  1015. >
  1016. OutputIterator transform(
  1017. PolyCollectionIterator first1,PolyCollectionIterator last1,
  1018. InputIterator first2,OutputIterator res,BinaryOperation op);
  1019. template<
  1020. typename... Ts,typename PolyCollectionIterator,
  1021. typename OutputIterator,typename T
  1022. >
  1023. OutputIterator replace_copy(
  1024. PolyCollectionIterator first,PolyCollectionIterator last,
  1025. OutputIterator res,const T& old_x,const T& new_x);
  1026. template<
  1027. typename... Ts,typename PolyCollectionIterator,
  1028. typename OutputIterator,typename Predicate,typename T
  1029. >
  1030. OutputIterator replace_copy_if(
  1031. PolyCollectionIterator first,PolyCollectionIterator last,
  1032. OutputIterator res,Predicate pred,const T& new_x);
  1033. template<
  1034. typename... Ts,typename PolyCollectionIterator,
  1035. typename OutputIterator,typename T
  1036. >
  1037. OutputIterator remove_copy(
  1038. PolyCollectionIterator first,PolyCollectionIterator last,
  1039. OutputIterator res,const T& x);
  1040. template<
  1041. typename... Ts,typename PolyCollectionIterator,
  1042. typename OutputIterator,typename Predicate
  1043. >
  1044. OutputIterator remove_copy_if(
  1045. PolyCollectionIterator first,PolyCollectionIterator last,
  1046. OutputIterator res,Predicate pred);
  1047. template<
  1048. typename... Ts,typename PolyCollectionIterator,typename OutputIterator
  1049. >
  1050. OutputIterator unique_copy(
  1051. PolyCollectionIterator first,PolyCollectionIterator last,
  1052. OutputIterator res);
  1053. template<
  1054. typename... Ts,typename PolyCollectionIterator,
  1055. typename OutputIterator,typename BinaryPredicate
  1056. >
  1057. OutputIterator unique_copy(
  1058. PolyCollectionIterator first,PolyCollectionIterator last,
  1059. OutputIterator res,BinaryPredicate pred);
  1060. template<
  1061. typename... Ts,typename PolyCollectionIterator,typename OutputIterator
  1062. >
  1063. OutputIterator rotate_copy(
  1064. PolyCollectionIterator first,PolyCollectionIterator middle,
  1065. PolyCollectionIterator last,OutputIterator res);
  1066. template<
  1067. typename... Ts,typename PolyCollectionIterator,typename OutputIterator,
  1068. typename Distance,typename UniformRandomBitGenerator
  1069. >
  1070. OutputIterator sample(
  1071. PolyCollectionIterator first,PolyCollectionIterator last,
  1072. OutputIterator res,Distance n,UniformRandomBitGenerator&& g);
  1073. template<typename... Ts,typename PolyCollectionIterator,typename Predicate>
  1074. bool is_partitioned(
  1075. PolyCollectionIterator first,PolyCollectionIterator last,Predicate pred);
  1076. template<
  1077. typename... Ts,typename PolyCollectionIterator,
  1078. typename OutputIterator1,typename OutputIterator2,typename Predicate
  1079. >
  1080. std::pair<OutputIterator1,OutputIterator2> partition_copy(
  1081. PolyCollectionIterator first,PolyCollectionIterator last,
  1082. OutputIterator1 rest,OutputIterator2 resf,Predicate pred);
  1083. template<typename... Ts,typename PolyCollectionIterator,typename Predicate>
  1084. PolyCollectionIterator partition_point(
  1085. PolyCollectionIterator first,PolyCollectionIterator last,Predicate pred);
  1086. } /* namespace poly_collection */
  1087. } /* namespace boost */
  1088. The algorithms provided mimic the functionality of their homonyms in
  1089. [@http://en.cppreference.com/w/cpp/algorithm `<algorithm>`] but take advantage
  1090. of the segmented nature of Boost.PolyCollection (global) iterators to
  1091. deliver better performance. Additionally, concrete types can be passed to
  1092. these algorithms for /type restitution/.
  1093. For the description of the algorithms we use the following notation:
  1094. * [' `alg`] is the (unqualified) name of any of the algorithms in
  1095. `"boost/poly_collection/algorithm.hpp"` except `copy_n` and `rotate_copy`.
  1096. * `first`, `middle` and `last` are (same-typed) possibly const global iterators
  1097. of a collection of Boost.PolyCollection such that \[`first`, `middle`) and
  1098. \[`middle`, `last`) are valid ranges.
  1099. * `args...` is a function parameter pack of types `Args&&...`,
  1100. * `Ts...` is a template parameter pack of arbitrary types.
  1101. (1) [' `alg`]`(first,last,args...)`[br]
  1102. (2) `for_each_n(first,args...)`[br]
  1103. (3) `copy_n(first,args...)`[br]
  1104. (4) `rotate_copy(first,middle,last,args...)`
  1105. [*Requires:] The expression `expr` is well-formed, where `expr` is defined
  1106. as:[br]
  1107. (1) `std::`[' `alg`]`(first,last,args...)`,[br]
  1108. (2) `std::for_each_n(first,args...)`,[br]
  1109. (3) `std::copy_n(first,args...)`,[br]
  1110. (4) `std::rotate_copy(first,middle,last,args...)`.[br]
  1111. [*Effects:] Equivalent to `expr`.[br]
  1112. [*Returns:] `expr`.[br]
  1113. [*Complexity:] That of `expr`.
  1114. (1) [' `alg`]`<Ts...>(first,last,args...)`[br]
  1115. (2) `for_each_n<Ts...>(first,args...)`[br]
  1116. (3) `copy_n<Ts...>(first,args...)`[br]
  1117. (4) `rotate_copy<Ts...>(first,middle,last,args...)`
  1118. [*Requires:] The expression `expr` is well-formed, where `expr` is defined
  1119. as:[br]
  1120. (1) `std::`[' `alg`]`(rfirst,rlast,args...)`,[br]
  1121. (2) `std::for_each_n(rfirst,args...)`,[br]
  1122. (3) `std::copy_n(rfirst,args...)`,[br]
  1123. (4) `std::rotate_copy(rfirst,rmiddle,rlast,args...)`,[br]
  1124. and `rfirst`, `rmiddle` and `rlast` are iterator-like objects behaving like
  1125. their `first`, `middle` and `last` counterparts except that they
  1126. dereference to the corresponding subobject (`const`) `T&` if pointing to a
  1127. segment for `T` and `T` is in `Ts...`
  1128. [footnote Strictly speaking a proper _ForwardIterator_ cannot behave
  1129. like this as dereferencing must yield /exactly/ a (`const`) `value_type&`
  1130. value, which disallows this type of polymorphism.].[br]
  1131. [*Effects:] Equivalent to `expr`.[br]
  1132. [*Returns:] `expr`.[br]
  1133. [*Complexity:] That of `expr`.
  1134. [endsect]
  1135. [endsect]