variant.xml 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE header PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
  3. "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
  4. <!--
  5. Copyright 2003, Eric Friedman, Itay Maman.
  6. Distributed under the Boost Software License, Version 1.0. (See accompanying
  7. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  8. -->
  9. <header name="boost/variant/variant.hpp">
  10. <namespace name="boost">
  11. <class name="variant">
  12. <purpose>Safe, generic, stack-based discriminated union container.</purpose>
  13. <description>
  14. <simpara>The <code>variant</code> class template (inspired by Andrei
  15. Alexandrescu's class of the same name
  16. [<link linkend="variant.refs.ale01a">Ale01A</link>]) is an efficient,
  17. <link linkend="variant.tutorial.recursive">recursive-capable</link>,
  18. bounded discriminated union value type capable of containing any value
  19. type (either POD or non-POD). It supports construction from any type
  20. convertible to one of its bounded types or from a source
  21. <code>variant</code> whose bounded types are each convertible to one
  22. of the destination <code>variant</code>'s bounded types. As well,
  23. through <code><functionname>apply_visitor</functionname></code>,
  24. <code>variant</code> supports compile-time checked, type-safe
  25. visitation; and through <code><functionname>get</functionname></code>,
  26. <code>variant</code> supports run-time checked, type-safe value
  27. retrieval.</simpara>
  28. <simpara><emphasis role="bold">Notes</emphasis>:</simpara>
  29. <itemizedlist>
  30. <listitem>The bounded types of the <code>variant</code> are exposed
  31. via the nested typedef <code>types</code>, which is an
  32. <libraryname>MPL</libraryname>-compatible Sequence containing the
  33. set of types that must be handled by any
  34. <link linkend="variant.concepts.static-visitor">visitor</link> to
  35. the <code>variant</code>.</listitem>
  36. <listitem>All members of <code>variant</code> satisfy at least the
  37. basic guarantee of exception-safety. That is, all operations on
  38. a <code>variant</code> remain defined even after previous
  39. operations have failed.</listitem>
  40. <listitem>Each type specified as a template argument to
  41. <code>variant</code> must meet the requirements of the
  42. <emphasis><link linkend="variant.concepts.bounded-type">BoundedType</link></emphasis>
  43. concept.</listitem>
  44. <listitem>Each type specified as a template argument to
  45. <code>variant</code> must be distinct after removal of qualifiers.
  46. Thus, for instance, both <code>variant&lt;int, int&gt;</code> and
  47. <code>variant&lt;int, const int&gt;</code> have undefined
  48. behavior.</listitem>
  49. <listitem>Conforming implementations of <code>variant</code> must
  50. allow at least ten types as template arguments. The exact number
  51. of allowed arguments is exposed by the preprocessor macro
  52. <code><macroname>BOOST_VARIANT_LIMIT_TYPES</macroname></code>.
  53. (See <code><classname>make_variant_over</classname></code> for a
  54. means to specify the bounded types of a <code>variant</code> by
  55. the elements of an <libraryname>MPL</libraryname> or compatible
  56. Sequence, thus overcoming this limitation.)</listitem>
  57. </itemizedlist>
  58. </description>
  59. <template>
  60. <template-type-parameter name="T1"/>
  61. <template-type-parameter name="T2">
  62. <default><emphasis>unspecified</emphasis></default>
  63. </template-type-parameter>
  64. <template-varargs/>
  65. <template-type-parameter name="TN">
  66. <default><emphasis>unspecified</emphasis></default>
  67. </template-type-parameter>
  68. </template>
  69. <typedef name="types">
  70. <type><emphasis>unspecified</emphasis></type>
  71. </typedef>
  72. <destructor>
  73. <effects>
  74. <simpara>Destroys the content of <code>*this</code>.</simpara>
  75. </effects>
  76. <throws>Will not throw.</throws>
  77. </destructor>
  78. <constructor>
  79. <requires>
  80. <simpara>The first bounded type of the <code>variant</code> (i.e.,
  81. <code>T1</code>) must fulfill the requirements of the
  82. <emphasis>DefaultConstructible</emphasis> [20.1.4]
  83. concept.</simpara>
  84. </requires>
  85. <postconditions>
  86. <simpara>Content of <code>*this</code> is the default value of the
  87. first bounded type (i.e, <code>T1</code>).</simpara>
  88. </postconditions>
  89. <throws>
  90. <simpara>May fail with any exceptions arising from the default
  91. constructor of <code>T1</code>.</simpara>
  92. </throws>
  93. </constructor>
  94. <constructor>
  95. <parameter name="other">
  96. <paramtype>const variant &amp;</paramtype>
  97. </parameter>
  98. <postconditions>
  99. <simpara>Content of <code>*this</code> is a copy of the content of
  100. <code>other</code>.</simpara>
  101. </postconditions>
  102. <throws>
  103. <simpara>May fail with any exceptions arising from the
  104. copy constructor of <code>other</code>'s contained type.</simpara>
  105. </throws>
  106. </constructor>
  107. <constructor>
  108. <parameter name="other">
  109. <paramtype>variant &amp;&amp;</paramtype>
  110. </parameter>
  111. <requires>
  112. <simpara>C++11 compatible compiler.</simpara>
  113. </requires>
  114. <postconditions>
  115. <simpara>Content of <code>*this</code> is move constructed from the content of
  116. <code>other</code>.</simpara>
  117. </postconditions>
  118. <throws>
  119. <simpara>May fail with any exceptions arising from the
  120. move constructor of <code>other</code>'s contained type.</simpara>
  121. </throws>
  122. </constructor>
  123. <constructor>
  124. <template>
  125. <template-type-parameter name="T"/>
  126. </template>
  127. <parameter name="operand">
  128. <paramtype>T &amp;</paramtype>
  129. </parameter>
  130. <requires>
  131. <simpara><code>T</code> must be unambiguously convertible to one of
  132. the bounded types (i.e., <code>T1</code>, <code>T2</code>,
  133. etc.).</simpara>
  134. </requires>
  135. <postconditions>
  136. <simpara>Content of <code>*this</code> is the best conversion of
  137. <code>operand</code> to one of the bounded types, as determined
  138. by standard overload resolution rules.</simpara>
  139. </postconditions>
  140. <throws>
  141. <simpara>May fail with any exceptions arising from the conversion of
  142. <code>operand</code> to one of the bounded types.</simpara>
  143. </throws>
  144. </constructor>
  145. <constructor>
  146. <template>
  147. <template-type-parameter name="T"/>
  148. </template>
  149. <parameter name="operand">
  150. <paramtype>const T &amp;</paramtype>
  151. </parameter>
  152. <notes>
  153. <simpara>Same semantics as previous constructor, but allows
  154. construction from temporaries.</simpara>
  155. </notes>
  156. </constructor>
  157. <constructor>
  158. <template>
  159. <template-type-parameter name="T"/>
  160. </template>
  161. <parameter name="operand">
  162. <paramtype>T &amp;&amp;</paramtype>
  163. </parameter>
  164. <requires>
  165. <simpara>C++11 compatible compiler.</simpara>
  166. </requires>
  167. <notes>
  168. <simpara>Same semantics as previous constructor, but allows
  169. move construction if <code>operand</code> is an rvalue.</simpara>
  170. </notes>
  171. </constructor>
  172. <constructor>
  173. <template>
  174. <template-type-parameter name="U1"/>
  175. <template-type-parameter name="U2"/>
  176. <template-varargs/>
  177. <template-type-parameter name="UN"/>
  178. </template>
  179. <parameter name="operand">
  180. <paramtype>variant&lt;U1, U2, ..., UN&gt; &amp;</paramtype>
  181. </parameter>
  182. <requires>
  183. <simpara><emphasis>Every</emphasis> one of <code>U1</code>,
  184. <code>U2</code>, ..., <code>UN</code> must have an unambiguous
  185. conversion to one of the bounded types (i.e., <code>T1</code>,
  186. <code>T2</code>, ..., <code>TN</code>).</simpara>
  187. </requires>
  188. <postconditions>
  189. <simpara>If <code>variant&lt;U1, U2, ..., UN&gt;</code> is itself
  190. one of the bounded types, then content of <code>*this</code> is a
  191. copy of <code>operand</code>. Otherwise, content of
  192. <code>*this</code> is the best conversion of the content of
  193. <code>operand</code> to one of the bounded types, as determined
  194. by standard overload resolution rules.</simpara>
  195. </postconditions>
  196. <throws>
  197. <simpara>If <code>variant&lt;U1, U2, ..., UN&gt;</code> is itself
  198. one of the bounded types, then may fail with any exceptions arising
  199. from the copy constructor of
  200. <code>variant&lt;U1, U2, ..., UN&gt;</code>. Otherwise, may fail
  201. with any exceptions arising from the conversion of the content of
  202. <code>operand</code> to one of the bounded types.</simpara>
  203. </throws>
  204. </constructor>
  205. <constructor>
  206. <template>
  207. <template-type-parameter name="U1"/>
  208. <template-type-parameter name="U2"/>
  209. <template-varargs/>
  210. <template-type-parameter name="UN"/>
  211. </template>
  212. <parameter name="operand">
  213. <paramtype>const variant&lt;U1, U2, ..., UN&gt; &amp;</paramtype>
  214. </parameter>
  215. <notes>
  216. <simpara>Same semantics as previous constructor, but allows
  217. construction from temporaries.</simpara>
  218. </notes>
  219. </constructor>
  220. <constructor>
  221. <template>
  222. <template-type-parameter name="U1"/>
  223. <template-type-parameter name="U2"/>
  224. <template-varargs/>
  225. <template-type-parameter name="UN"/>
  226. </template>
  227. <requires>
  228. <simpara>C++11 compatible compiler.</simpara>
  229. </requires>
  230. <parameter name="operand">
  231. <paramtype>variant&lt;U1, U2, ..., UN&gt; &amp;&amp;</paramtype>
  232. </parameter>
  233. <notes>
  234. <simpara>Same semantics as previous constructor, but allows
  235. move construction.</simpara>
  236. </notes>
  237. </constructor>
  238. <method-group name="modifiers">
  239. <method name="swap">
  240. <type>void</type>
  241. <parameter name="other">
  242. <paramtype>variant &amp;</paramtype>
  243. </parameter>
  244. <requires>
  245. <simpara>Every bounded type must fulfill the requirements of the
  246. <conceptname>MoveAssignable</conceptname>
  247. concept.</simpara>
  248. </requires>
  249. <effects>
  250. <simpara>Interchanges the content of <code>*this</code> and
  251. <code>other</code>.</simpara>
  252. </effects>
  253. <throws>
  254. <simpara>If the contained type of <code>other</code> is the same as
  255. the contained type of <code>*this</code>, then may fail with any
  256. exceptions arising from the <code>swap</code> of the contents of
  257. <code>*this</code> and <code>other</code>. Otherwise, may fail
  258. with any exceptions arising from either of the move or copy constructors
  259. of the contained types. Also, in the event of insufficient
  260. memory, may fail with <code>std::bad_alloc</code>
  261. (<link linkend="variant.design.never-empty.problem">why?</link>).</simpara>
  262. </throws>
  263. </method>
  264. <method name="operator=">
  265. <type>variant &amp;</type>
  266. <parameter name="rhs">
  267. <paramtype>const variant &amp;</paramtype>
  268. </parameter>
  269. <requires>
  270. <simpara>Every bounded type must fulfill the requirements of the
  271. <conceptname>Assignable</conceptname>
  272. concept.</simpara>
  273. </requires>
  274. <effects>
  275. <simpara>If the contained type of <code>rhs</code> is the same as
  276. the contained type of <code>*this</code>, then assigns the
  277. content of <code>rhs</code> into the content of
  278. <code>*this</code>. Otherwise, makes the content of
  279. <code>*this</code> a copy of the content of <code>rhs</code>,
  280. destroying the previous content of <code>*this</code>.</simpara>
  281. </effects>
  282. <throws>
  283. <simpara>If the contained type of <code>rhs</code> is the same as
  284. the contained type of <code>*this</code>, then may fail with any
  285. exceptions arising from the assignment of the content of
  286. <code>rhs</code> into the content <code>*this</code>. Otherwise,
  287. may fail with any exceptions arising from the copy constructor
  288. of the contained type of <code>rhs</code>. Also, in the event of
  289. insufficient memory, may fail with <code>std::bad_alloc</code>
  290. (<link linkend="variant.design.never-empty.problem">why?</link>).</simpara>
  291. </throws>
  292. </method>
  293. <method name="operator=">
  294. <type>variant &amp;</type>
  295. <parameter name="rhs">
  296. <paramtype>variant &amp;&amp;</paramtype>
  297. </parameter>
  298. <requires>
  299. <itemizedlist>
  300. <listitem>C++11 compatible compiler.</listitem>
  301. <listitem>Every bounded type must fulfill the requirements of the
  302. <conceptname>MoveAssignable</conceptname>
  303. concept.</listitem>
  304. </itemizedlist>
  305. </requires>
  306. <effects>
  307. <simpara>If the contained type of <code>rhs</code> is the same as
  308. the contained type of <code>*this</code>, then move assigns the
  309. content of <code>rhs</code> into the content of
  310. <code>*this</code>. Otherwise, move constructs
  311. <code>*this</code> using the content of <code>rhs</code>,
  312. destroying the previous content of <code>*this</code>.</simpara>
  313. </effects>
  314. <throws>
  315. <simpara>If the contained type of <code>rhs</code> is the same as
  316. the contained type of <code>*this</code>, then may fail with any
  317. exceptions arising from the move assignment of the content of
  318. <code>rhs</code> into the content <code>*this</code>. Otherwise,
  319. may fail with any exceptions arising from the move constructor
  320. of the contained type of <code>rhs</code>. Also, in the event of
  321. insufficient memory, may fail with <code>std::bad_alloc</code>
  322. (<link linkend="variant.design.never-empty.problem">why?</link>).</simpara>
  323. </throws>
  324. </method>
  325. <method name="operator=">
  326. <type>variant &amp;</type>
  327. <template>
  328. <template-type-parameter name="T"/>
  329. </template>
  330. <parameter name="rhs">
  331. <paramtype>const T &amp;</paramtype>
  332. </parameter>
  333. <requires>
  334. <itemizedlist>
  335. <listitem><code>T</code> must be unambiguously convertible to
  336. one of the bounded types (i.e., <code>T1</code>,
  337. <code>T2</code>, etc.).</listitem>
  338. <listitem>Every bounded type must fulfill the requirements of the
  339. <conceptname>Assignable</conceptname>
  340. concept.</listitem>
  341. </itemizedlist>
  342. </requires>
  343. <effects>
  344. <simpara>If the contained type of <code>*this</code> is
  345. <code>T</code>, then assigns <code>rhs</code> into the content
  346. of <code>*this</code>. Otherwise, makes the content of
  347. <code>*this</code> the best conversion of <code>rhs</code> to
  348. one of the bounded types, as determined by standard overload
  349. resolution rules, destroying the previous content of
  350. <code>*this</code>.</simpara>
  351. </effects>
  352. <throws>
  353. <simpara>If the contained type of <code>*this</code> is
  354. <code>T</code>, then may fail with any exceptions arising from
  355. the assignment of <code>rhs</code> into the content
  356. <code>*this</code>. Otherwise, may fail with any exceptions
  357. arising from the conversion of <code>rhs</code> to one of the
  358. bounded types. Also, in the event of insufficient memory, may
  359. fail with <code>std::bad_alloc</code>
  360. (<link linkend="variant.design.never-empty.problem">why?</link>).</simpara>
  361. </throws>
  362. </method>
  363. <method name="operator=">
  364. <type>variant &amp;</type>
  365. <template>
  366. <template-type-parameter name="T"/>
  367. </template>
  368. <parameter name="rhs">
  369. <paramtype>T &amp;&amp;</paramtype>
  370. </parameter>
  371. <requires>
  372. <itemizedlist>
  373. <listitem>C++11 compatible compiler.</listitem>
  374. <listitem><code>rhs</code> is an rvalue. Otherwise previous operator will be used.</listitem>
  375. <listitem><code>T</code> must be unambiguously convertible to
  376. one of the bounded types (i.e., <code>T1</code>,
  377. <code>T2</code>, etc.).</listitem>
  378. <listitem>Every bounded type must fulfill the requirements of the
  379. <conceptname>MoveAssignable</conceptname>
  380. concept.</listitem>
  381. </itemizedlist>
  382. </requires>
  383. <effects>
  384. <simpara>If the contained type of <code>*this</code> is
  385. <code>T</code>, then move assigns <code>rhs</code> into the content
  386. of <code>*this</code>. Otherwise, makes the content of
  387. <code>*this</code> the best conversion of <code>rhs</code> to
  388. one of the bounded types, as determined by standard overload
  389. resolution rules, destroying the previous content of
  390. <code>*this</code>(conversion is usually done via move construction).</simpara>
  391. </effects>
  392. <throws>
  393. <simpara>If the contained type of <code>*this</code> is
  394. <code>T</code>, then may fail with any exceptions arising from
  395. the move assignment of <code>rhs</code> into the content
  396. <code>*this</code>. Otherwise, may fail with any exceptions
  397. arising from the conversion of <code>rhs</code> to one of the
  398. bounded types. Also, in the event of insufficient memory, may
  399. fail with <code>std::bad_alloc</code>
  400. (<link linkend="variant.design.never-empty.problem">why?</link>).</simpara>
  401. </throws>
  402. </method>
  403. </method-group>
  404. <method-group name="queries">
  405. <method name="which" cv="const">
  406. <type>int</type>
  407. <returns>
  408. <simpara>The zero-based index into the set of bounded types
  409. of the contained type of <code>*this</code>. (For instance, if
  410. called on a <code>variant&lt;int, std::string&gt;</code> object
  411. containing a <code>std::string</code>, <code>which()</code>
  412. would return <code>1</code>.)</simpara>
  413. </returns>
  414. <throws>Will not throw.</throws>
  415. </method>
  416. <method name="empty" cv="const">
  417. <type>bool</type>
  418. <returns>
  419. <simpara><code>false</code>: <code>variant</code> always contains
  420. exactly one of its bounded types. (See
  421. <xref linkend="variant.design.never-empty"/>
  422. for more information.)</simpara>
  423. </returns>
  424. <rationale>
  425. <simpara>Facilitates generic compatibility with
  426. <classname>boost::any</classname>.</simpara>
  427. </rationale>
  428. <throws>Will not throw.</throws>
  429. </method>
  430. <method name="type" cv="const">
  431. <type>const std::type_info &amp;</type>
  432. <notes>
  433. <simpara><code>boost::variant</code> usues Boost.TypeIndex library so actually
  434. <code>const boost::typeindex::type_info &amp;</code> is returned.
  435. This method is available even if RTTI is off.</simpara>
  436. </notes>
  437. <returns>
  438. <simpara><code>typeid(x)</code>, where <code>x</code> is the the
  439. content of <code>*this</code>.</simpara>
  440. </returns>
  441. <throws>Will not throw.</throws>
  442. </method>
  443. </method-group>
  444. <method-group name="relational">
  445. <overloaded-method name="operator==" cv="const">
  446. <purpose>Equality comparison.</purpose>
  447. <signature cv="const">
  448. <type>bool</type>
  449. <parameter name="rhs">
  450. <paramtype>const variant &amp;</paramtype>
  451. </parameter>
  452. </signature>
  453. <signature cv="const">
  454. <type>void</type>
  455. <template>
  456. <template-type-parameter name="U"/>
  457. </template>
  458. <parameter>
  459. <paramtype>const U &amp;</paramtype>
  460. </parameter>
  461. </signature>
  462. <notes>
  463. <simpara>The overload returning <code>void</code> exists only to
  464. prohibit implicit conversion of the operator's right-hand side
  465. to <code>variant</code>; thus, its use will (purposefully)
  466. result in a compile-time error.</simpara>
  467. </notes>
  468. <requires>
  469. <simpara>Every bounded type of the <code>variant</code> must
  470. fulfill the requirements of the
  471. <conceptname>EqualityComparable</conceptname>
  472. concept.</simpara>
  473. </requires>
  474. <returns>
  475. <simpara><code>true</code> if <code>which() == rhs.which()</code>
  476. <emphasis>and</emphasis>
  477. <code>content_this == content_rhs</code>, where
  478. <code>content_this</code> is the content of <code>*this</code>
  479. and <code>content_rhs</code> is the content of
  480. <code>rhs</code>.</simpara>
  481. </returns>
  482. <throws>
  483. <simpara>If <code>which() == rhs.which()</code> then may fail with
  484. any exceptions arising from <code>operator==(T,T)</code>, where
  485. <code>T</code> is the contained type of
  486. <code>*this</code>.</simpara>
  487. </throws>
  488. </overloaded-method>
  489. <overloaded-method name="operator!=" cv="const">
  490. <purpose>InEquality comparison.</purpose>
  491. <signature cv="const">
  492. <type>bool</type>
  493. <parameter name="rhs">
  494. <paramtype>const variant &amp;</paramtype>
  495. </parameter>
  496. </signature>
  497. <signature cv="const">
  498. <type>void</type>
  499. <template>
  500. <template-type-parameter name="U"/>
  501. </template>
  502. <parameter>
  503. <paramtype>const U &amp;</paramtype>
  504. </parameter>
  505. </signature>
  506. <notes>
  507. <simpara>The overload returning <code>void</code> exists only to
  508. prohibit implicit conversion of the operator's right-hand side
  509. to <code>variant</code>; thus, its use will (purposefully)
  510. result in a compile-time error.</simpara>
  511. </notes>
  512. <requires>
  513. <simpara>Every bounded type of the <code>variant</code> must
  514. fulfill the requirements of the
  515. <conceptname>EqualityComparable</conceptname>
  516. concept.</simpara>
  517. </requires>
  518. <returns>
  519. <simpara><code>true</code> if <code>!(*this == rhs)</code>.</simpara>
  520. </returns>
  521. <throws>
  522. <simpara>If <code>which() == rhs.which()</code> then may fail with
  523. any exceptions arising from <code>operator==(T,T)</code>, where
  524. <code>T</code> is the contained type of
  525. <code>*this</code>.</simpara>
  526. </throws>
  527. </overloaded-method>
  528. <overloaded-method name="operator&lt;">
  529. <purpose>LessThan comparison.</purpose>
  530. <signature cv="const">
  531. <type>bool</type>
  532. <parameter name="rhs">
  533. <paramtype>const variant &amp;</paramtype>
  534. </parameter>
  535. </signature>
  536. <signature cv="const">
  537. <type>void</type>
  538. <template>
  539. <template-type-parameter name="U"/>
  540. </template>
  541. <parameter>
  542. <paramtype>const U &amp;</paramtype>
  543. </parameter>
  544. </signature>
  545. <notes>
  546. <simpara>The overload returning <code>void</code> exists only to
  547. prohibit implicit conversion of the operator's right-hand side
  548. to <code>variant</code>; thus, its use will (purposefully)
  549. result in a compile-time error.</simpara>
  550. </notes>
  551. <requires>
  552. <simpara>Every bounded type of the <code>variant</code> must
  553. fulfill the requirements of the
  554. <conceptname>LessThanComparable</conceptname>
  555. concept.</simpara>
  556. </requires>
  557. <returns>
  558. <simpara>If <code>which() == rhs.which()</code> then:
  559. <code>content_this &lt; content_rhs</code>, where
  560. <code>content_this</code> is the content of <code>*this</code>
  561. and <code>content_rhs</code> is the content of <code>rhs</code>.
  562. Otherwise: <code>which() &lt; rhs.which()</code>.</simpara>
  563. </returns>
  564. <throws>
  565. <simpara>If <code>which() == rhs.which()</code> then may fail with
  566. any exceptions arising from <code>operator&lt;(T,T)</code>,
  567. where <code>T</code> is the contained type of
  568. <code>*this</code>.</simpara>
  569. </throws>
  570. </overloaded-method>
  571. <overloaded-method name="operator&gt;">
  572. <purpose>GreaterThan comparison.</purpose>
  573. <signature cv="const">
  574. <type>bool</type>
  575. <parameter name="rhs">
  576. <paramtype>const variant &amp;</paramtype>
  577. </parameter>
  578. </signature>
  579. <signature cv="const">
  580. <type>void</type>
  581. <template>
  582. <template-type-parameter name="U"/>
  583. </template>
  584. <parameter>
  585. <paramtype>const U &amp;</paramtype>
  586. </parameter>
  587. </signature>
  588. <notes>
  589. <simpara>The overload returning <code>void</code> exists only to
  590. prohibit implicit conversion of the operator's right-hand side
  591. to <code>variant</code>; thus, its use will (purposefully)
  592. result in a compile-time error.</simpara>
  593. </notes>
  594. <requires>
  595. <simpara>Every bounded type of the <code>variant</code> must
  596. fulfill the requirements of the
  597. <conceptname>LessThanComparable</conceptname>
  598. concept.</simpara>
  599. </requires>
  600. <returns>
  601. <simpara>true if <code>rhs &lt; *this</code>.</simpara>
  602. </returns>
  603. <throws>
  604. <simpara>May fail with
  605. any exceptions arising from <code>operator&lt;(T,T)</code>,
  606. where <code>T</code> is the contained type of
  607. <code>*this</code>.</simpara>
  608. </throws>
  609. </overloaded-method>
  610. <overloaded-method name="operator&lt;=">
  611. <purpose>LessThan or Equal comparison.</purpose>
  612. <signature cv="const">
  613. <type>bool</type>
  614. <parameter name="rhs">
  615. <paramtype>const variant &amp;</paramtype>
  616. </parameter>
  617. </signature>
  618. <signature cv="const">
  619. <type>void</type>
  620. <template>
  621. <template-type-parameter name="U"/>
  622. </template>
  623. <parameter>
  624. <paramtype>const U &amp;</paramtype>
  625. </parameter>
  626. </signature>
  627. <notes>
  628. <simpara>The overload returning <code>void</code> exists only to
  629. prohibit implicit conversion of the operator's right-hand side
  630. to <code>variant</code>; thus, its use will (purposefully)
  631. result in a compile-time error.</simpara>
  632. </notes>
  633. <requires>
  634. <simpara>Every bounded type of the <code>variant</code> must
  635. fulfill the requirements of the
  636. <conceptname>LessThanComparable</conceptname>
  637. concept.</simpara>
  638. </requires>
  639. <returns>
  640. <simpara>true if <code>!(*this > rhs)</code>.</simpara>
  641. </returns>
  642. <throws>
  643. <simpara>May fail with
  644. any exceptions arising from <code>operator&lt;(T,T)</code>,
  645. where <code>T</code> is the contained type of
  646. <code>*this</code>.</simpara>
  647. </throws>
  648. </overloaded-method>
  649. <overloaded-method name="operator&gt;=">
  650. <purpose>GreaterThan or Equal comparison.</purpose>
  651. <signature cv="const">
  652. <type>bool</type>
  653. <parameter name="rhs">
  654. <paramtype>const variant &amp;</paramtype>
  655. </parameter>
  656. </signature>
  657. <signature cv="const">
  658. <type>void</type>
  659. <template>
  660. <template-type-parameter name="U"/>
  661. </template>
  662. <parameter>
  663. <paramtype>const U &amp;</paramtype>
  664. </parameter>
  665. </signature>
  666. <notes>
  667. <simpara>The overload returning <code>void</code> exists only to
  668. prohibit implicit conversion of the operator's right-hand side
  669. to <code>variant</code>; thus, its use will (purposefully)
  670. result in a compile-time error.</simpara>
  671. </notes>
  672. <requires>
  673. <simpara>Every bounded type of the <code>variant</code> must
  674. fulfill the requirements of the
  675. <conceptname>LessThanComparable</conceptname>
  676. concept.</simpara>
  677. </requires>
  678. <returns>
  679. <simpara>true if <code>!(*this &lt; lhs)</code>.</simpara>
  680. </returns>
  681. <throws>
  682. <simpara>May fail with
  683. any exceptions arising from <code>operator&lt;(T,T)</code>,
  684. where <code>T</code> is the contained type of
  685. <code>*this</code>.</simpara>
  686. </throws>
  687. </overloaded-method>
  688. </method-group>
  689. </class>
  690. <function name="swap">
  691. <template>
  692. <template-type-parameter name="T1"/>
  693. <template-type-parameter name="T2"/>
  694. <template-varargs/>
  695. <template-type-parameter name="TN"/>
  696. </template>
  697. <type>void</type>
  698. <parameter name="lhs">
  699. <paramtype><classname>variant</classname>&lt;T1, T2, ..., TN&gt; &amp;</paramtype>
  700. </parameter>
  701. <parameter name="rhs">
  702. <paramtype><classname>variant</classname>&lt;T1, T2, ..., TN&gt; &amp;</paramtype>
  703. </parameter>
  704. <effects>
  705. <simpara>Swaps <code>lhs</code> with <code>rhs</code> by application
  706. of <code><methodname>variant::swap</methodname></code>.</simpara>
  707. </effects>
  708. <throws>
  709. <simpara>May fail with any exception arising from
  710. <code><methodname>variant::swap</methodname></code>.</simpara>
  711. </throws>
  712. </function>
  713. <function name="operator&lt;&lt;">
  714. <purpose>Provides streaming output for <code>variant</code> types.</purpose>
  715. <template>
  716. <template-type-parameter name="ElemType"/>
  717. <template-type-parameter name="Traits"/>
  718. <template-type-parameter name="T1"/>
  719. <template-type-parameter name="T2"/>
  720. <template-varargs/>
  721. <template-type-parameter name="TN"/>
  722. </template>
  723. <type>std::basic_ostream&lt;ElemType,Traits&gt; &amp;</type>
  724. <parameter name="out">
  725. <paramtype>std::basic_ostream&lt;ElemType,Traits&gt; &amp;</paramtype>
  726. </parameter>
  727. <parameter name="rhs">
  728. <paramtype>const <classname>variant</classname>&lt;T1, T2, ..., TN&gt; &amp;</paramtype>
  729. </parameter>
  730. <requires>
  731. <simpara>Every bounded type of the <code>variant</code> must
  732. fulfill the requirements of the
  733. <link linkend="variant.concepts.output-streamable"><emphasis>OutputStreamable</emphasis></link>
  734. concept.</simpara>
  735. </requires>
  736. <effects>
  737. <simpara>Calls <code>out &lt;&lt; x</code>, where <code>x</code> is
  738. the content of <code>rhs</code>.</simpara>
  739. </effects>
  740. <notes>
  741. <simpara>Not available when <code>BOOST_NO_IOSTREAM</code> is
  742. defined.</simpara>
  743. </notes>
  744. </function>
  745. <function name="hash_value">
  746. <purpose>Provides hashing for <code>variant</code> types so
  747. that <code>boost::hash</code> may compute hash.</purpose>
  748. <template>
  749. <template-type-parameter name="T1"/>
  750. <template-type-parameter name="T2"/>
  751. <template-varargs/>
  752. <template-type-parameter name="TN"/>
  753. </template>
  754. <type>std::size_t</type>
  755. <parameter name="rhs">
  756. <paramtype>const <classname>variant</classname>&lt;T1, T2, ..., TN&gt; &amp;</paramtype>
  757. </parameter>
  758. <requires>
  759. <simpara>Every bounded type of the <code>variant</code> must
  760. fulfill the requirements of the
  761. <link linkend="variant.concepts.hashable"><emphasis>Hashable</emphasis></link>
  762. concept.</simpara>
  763. </requires>
  764. <effects>
  765. <simpara>Calls <code>boost::hash&lt;T&gt;()(x)</code>, where <code>x</code> is
  766. the content of <code>rhs</code> and <code>T</code> is its type.</simpara>
  767. </effects>
  768. <notes>
  769. <simpara>Actually, this function is defined in
  770. <code>&lt;boost/variant/detail/hash_variant.hpp&gt;</code>
  771. header.</simpara>
  772. </notes>
  773. </function>
  774. <class name="make_variant_over">
  775. <purpose>
  776. <simpara>Exposes a <code>variant</code> whose bounded types are the
  777. elements of the given type sequence.</simpara>
  778. </purpose>
  779. <template>
  780. <template-type-parameter name="Sequence"/>
  781. </template>
  782. <typedef name="type">
  783. <type>variant&lt; <emphasis>unspecified</emphasis> &gt;</type>
  784. </typedef>
  785. <description>
  786. <simpara><code>type</code> has behavior equivalent in every respect to
  787. <code><classname>variant</classname>&lt; Sequence[0], Sequence[1], ... &gt;</code>
  788. (where <code>Sequence[<emphasis>i</emphasis>]</code> denotes the
  789. <emphasis>i</emphasis>-th element of <code>Sequence</code>), except
  790. that no upper limit is imposed on the number of types.</simpara>
  791. <simpara><emphasis role="bold">Notes</emphasis>:</simpara>
  792. <itemizedlist>
  793. <listitem><code>Sequence</code> must meet the requirements of
  794. <libraryname>MPL</libraryname>'s <emphasis>Sequence</emphasis>
  795. concept.</listitem>
  796. <listitem>Due to standard conformance problems in several compilers,
  797. <code>make_variant_over</code> may not be supported on your
  798. compiler. See
  799. <code><macroname>BOOST_VARIANT_NO_TYPE_SEQUENCE_SUPPORT</macroname></code>
  800. for more information.</listitem>
  801. </itemizedlist>
  802. </description>
  803. </class>
  804. </namespace>
  805. </header>