--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<grammar xmlns="http://relaxng.org/ns/structure/1.0" ns="http://docbook.org/ns/docbook">
+ <!-- ========== Import DocBook DTD ========== -->
+ <include href="http://docbook.org/xml/5.0/rng/docbook.rng"/>
+ <start combine="choice">
+ <choice>
+ <ref name="header"/>
+ <ref name="library"/>
+ <ref name="boostbook"/>
+ <ref name="precondition"/>
+ </choice>
+ </start>
+ <define name="local.common.attrib">
+ <optional>
+ <attribute name="last-revision"/>
+ </optional>
+ </define>
+ <!-- ========== Define the BoostBook extensions ========== -->
+ <define name="boost.common.attrib">
+ <ref name="local.common.attrib"/>
+ <optional>
+ <ref name="db.xml.id.attribute"/>
+ </optional>
+ </define>
+ <define name="boost.namespace.mix">
+ <choice>
+ <ref name="class"/>
+ <ref name="class-specialization"/>
+ <ref name="struct"/>
+ <ref name="struct-specialization"/>
+ <ref name="union"/>
+ <ref name="union-specialization"/>
+ <ref name="typedef"/>
+ <ref name="enum"/>
+ <ref name="free-function-group"/>
+ <ref name="function"/>
+ <ref name="overloaded-function"/>
+ <ref name="namespace"/>
+ </choice>
+ </define>
+ <define name="boost.template.mix">
+ <choice>
+ <ref name="template-type-parameter"/>
+ <ref name="template-nontype-parameter"/>
+ <ref name="template-varargs"/>
+ </choice>
+ </define>
+ <define name="boost.class.members">
+ <choice>
+ <ref name="static-constant"/>
+ <ref name="typedef"/>
+ <ref name="enum"/>
+ <ref name="copy-assignment"/>
+ <ref name="constructor"/>
+ <ref name="destructor"/>
+ <ref name="method-group"/>
+ <ref name="method"/>
+ <ref name="overloaded-method"/>
+ <ref name="data-member"/>
+ <ref name="class"/>
+ <ref name="class-specialization"/>
+ <ref name="struct"/>
+ <ref name="struct-specialization"/>
+ <ref name="union"/>
+ <ref name="union-specialization"/>
+ </choice>
+ </define>
+ <define name="boost.class.mix">
+ <choice>
+ <ref name="boost.class.members"/>
+ <ref name="free-function-group"/>
+ <ref name="function"/>
+ <ref name="overloaded-function"/>
+ </choice>
+ </define>
+ <define name="boost.class.content">
+ <optional>
+ <ref name="template"/>
+ </optional>
+ <zeroOrMore>
+ <ref name="inherit"/>
+ </zeroOrMore>
+ <optional>
+ <ref name="purpose"/>
+ </optional>
+ <optional>
+ <ref name="description"/>
+ </optional>
+ <zeroOrMore>
+ <choice>
+ <ref name="boost.class.mix"/>
+ <ref name="access"/>
+ </choice>
+ </zeroOrMore>
+ </define>
+ <define name="boost.class-specialization.content">
+ <optional>
+ <ref name="template"/>
+ </optional>
+ <optional>
+ <ref name="specialization"/>
+ </optional>
+ <optional>
+ <ref name="inherit"/>
+ </optional>
+ <optional>
+ <ref name="purpose"/>
+ </optional>
+ <optional>
+ <ref name="description"/>
+ </optional>
+ <zeroOrMore>
+ <choice>
+ <ref name="boost.class.mix"/>
+ <ref name="access"/>
+ </choice>
+ </zeroOrMore>
+ </define>
+ <define name="boost.function.semantics">
+ <optional>
+ <ref name="purpose"/>
+ </optional>
+ <optional>
+ <ref name="description"/>
+ </optional>
+ <optional>
+ <ref name="requires"/>
+ </optional>
+ <optional>
+ <ref name="effects"/>
+ </optional>
+ <optional>
+ <ref name="postconditions"/>
+ </optional>
+ <optional>
+ <ref name="returns"/>
+ </optional>
+ <optional>
+ <ref name="throws"/>
+ </optional>
+ <optional>
+ <ref name="complexity"/>
+ </optional>
+ <optional>
+ <ref name="notes"/>
+ </optional>
+ <optional>
+ <ref name="rationale"/>
+ </optional>
+ </define>
+ <define name="library.content">
+ <ref name="libraryinfo"/>
+ <optional>
+ <ref name="db.title"/>
+ <oneOrMore>
+ <choice>
+ <ref name="db.section"/>
+ <ref name="library-reference"/>
+ <ref name="testsuite"/>
+ </choice>
+ </oneOrMore>
+ </optional>
+ </define>
+ <define name="library">
+ <element name="library">
+ <ref name="library.attlist"/>
+ <ref name="library.content"/>
+ </element>
+ </define>
+ <define name="library.attlist" combine="interleave">
+ <attribute name="name"/>
+ <attribute name="dirname"/>
+ <optional>
+ <attribute name="html-only"/>
+ </optional>
+ <optional>
+ <attribute name="url"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="boostbook">
+ <element name="boostbook">
+ <ref name="boostbook.attlist"/>
+ <ref name="db.title"/>
+ <zeroOrMore>
+ <choice>
+ <ref name="db.chapter"/>
+ <ref name="library"/>
+ </choice>
+ </zeroOrMore>
+ </element>
+ </define>
+ <define name="boostbook.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="libraryinfo">
+ <element name="libraryinfo">
+ <ref name="libraryinfo.attlist"/>
+ <oneOrMore>
+ <ref name="db.author"/>
+ </oneOrMore>
+ <zeroOrMore>
+ <ref name="db.copyright"/>
+ </zeroOrMore>
+ <zeroOrMore>
+ <ref name="db.legalnotice"/>
+ </zeroOrMore>
+ <ref name="librarypurpose"/>
+ <zeroOrMore>
+ <ref name="librarycategory"/>
+ </zeroOrMore>
+ </element>
+ </define>
+ <define name="libraryinfo.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="librarypurpose">
+ <element name="librarypurpose">
+ <ref name="librarypurpose.attlist"/>
+ <zeroOrMore>
+ <choice>
+ <text/>
+ <ref name="code"/>
+ <ref name="functionname"/>
+ <ref name="db.methodname"/>
+ <ref name="db.classname"/>
+ <ref name="macroname"/>
+ <ref name="headername"/>
+ <ref name="enumname"/>
+ <ref name="globalname"/>
+ </choice>
+ </zeroOrMore>
+ </element>
+ </define>
+ <define name="librarypurpose.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="librarycategory">
+ <element name="librarycategory">
+ <ref name="librarycategory.attlist"/>
+ <text/>
+ </element>
+ </define>
+ <define name="librarycategory.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="libraryname">
+ <element name="libraryname">
+ <ref name="libraryname.attlist"/>
+ <text/>
+ </element>
+ </define>
+ <define name="libraryname.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="library-reference">
+ <element name="library-reference">
+ <ref name="library-reference.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="library-reference.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="librarylist">
+ <element name="librarylist">
+ <ref name="librarylist.attlist"/>
+ <empty/>
+ </element>
+ </define>
+ <define name="librarylist.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="librarycategorylist">
+ <element name="librarycategorylist">
+ <ref name="librarycategorylist.attlist"/>
+ <zeroOrMore>
+ <ref name="librarycategorydef"/>
+ </zeroOrMore>
+ </element>
+ </define>
+ <define name="librarycategorylist.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="librarycategorydef">
+ <element name="librarycategorydef">
+ <ref name="librarycategorydef.attlist"/>
+ <text/>
+ </element>
+ </define>
+ <define name="librarycategorydef.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="header">
+ <element name="header">
+ <ref name="header.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="header.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="namespace">
+ <element name="namespace">
+ <ref name="namespace.attlist"/>
+ <zeroOrMore>
+ <ref name="boost.namespace.mix"/>
+ </zeroOrMore>
+ </element>
+ </define>
+ <define name="namespace.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="class">
+ <element name="class">
+ <ref name="class.attlist"/>
+ <ref name="boost.class.content"/>
+ </element>
+ </define>
+ <define name="class.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="struct">
+ <element name="struct">
+ <ref name="struct.attlist"/>
+ <ref name="boost.class.content"/>
+ </element>
+ </define>
+ <define name="struct.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="union">
+ <element name="union">
+ <ref name="union.attlist"/>
+ <ref name="boost.class.content"/>
+ </element>
+ </define>
+ <define name="union.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="class-specialization">
+ <element name="class-specialization">
+ <ref name="class-specialization.attlist"/>
+ <ref name="boost.class-specialization.content"/>
+ </element>
+ </define>
+ <define name="class-specialization.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="struct-specialization">
+ <element name="struct-specialization">
+ <ref name="struct-specialization.attlist"/>
+ <ref name="boost.class-specialization.content"/>
+ </element>
+ </define>
+ <define name="struct-specialization.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="union-specialization">
+ <element name="union-specialization">
+ <ref name="union-specialization.attlist"/>
+ <ref name="boost.class-specialization.content"/>
+ </element>
+ </define>
+ <define name="union-specialization.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="access">
+ <element name="access">
+ <ref name="access.attlist"/>
+ <oneOrMore>
+ <ref name="boost.class.members"/>
+ </oneOrMore>
+ </element>
+ </define>
+ <define name="access.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <!-- ========= C++ Templates ========= -->
+ <define name="template">
+ <element name="template">
+ <ref name="template.attlist"/>
+ <zeroOrMore>
+ <ref name="boost.template.mix"/>
+ </zeroOrMore>
+ </element>
+ </define>
+ <define name="template.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="template-type-parameter">
+ <element name="template-type-parameter">
+ <ref name="template-type-parameter.attlist"/>
+ <optional>
+ <ref name="default"/>
+ </optional>
+ <optional>
+ <ref name="purpose"/>
+ </optional>
+ </element>
+ </define>
+ <define name="template-type-parameter.attlist" combine="interleave">
+ <attribute name="name"/>
+ <optional>
+ <attribute name="pack"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="template-nontype-parameter">
+ <element name="template-nontype-parameter">
+ <ref name="template-nontype-parameter.attlist"/>
+ <ref name="type"/>
+ <optional>
+ <ref name="default"/>
+ </optional>
+ <optional>
+ <ref name="purpose"/>
+ </optional>
+ </element>
+ </define>
+ <define name="template-nontype-parameter.attlist" combine="interleave">
+ <attribute name="name"/>
+ <optional>
+ <attribute name="pack"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="template-varargs">
+ <element name="template-varargs">
+ <ref name="template-varargs.attlist"/>
+ <empty/>
+ </element>
+ </define>
+ <define name="template-varargs.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="specialization">
+ <element name="specialization">
+ <ref name="specialization.attlist"/>
+ <zeroOrMore>
+ <ref name="template-arg"/>
+ </zeroOrMore>
+ </element>
+ </define>
+ <define name="specialization.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="template-arg">
+ <element name="template-arg">
+ <ref name="template-arg.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="template-arg.attlist" combine="interleave">
+ <optional>
+ <attribute name="pack"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="default">
+ <element name="default">
+ <ref name="default.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="default.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="inherit">
+ <element name="inherit">
+ <ref name="inherit.attlist"/>
+ <ref name="type"/>
+ <optional>
+ <ref name="purpose"/>
+ </optional>
+ </element>
+ </define>
+ <define name="inherit.attlist" combine="interleave">
+ <optional>
+ <attribute name="access"/>
+ </optional>
+ <optional>
+ <attribute name="pack"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="purpose">
+ <element name="purpose">
+ <ref name="purpose.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="purpose.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="description">
+ <element name="description">
+ <ref name="description.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="description.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="type">
+ <element name="type">
+ <ref name="type.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="type.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="typedef">
+ <element name="typedef">
+ <ref name="typedef.attlist"/>
+ <ref name="type"/>
+ <optional>
+ <ref name="purpose"/>
+ </optional>
+ <optional>
+ <ref name="description"/>
+ </optional>
+ </element>
+ </define>
+ <define name="typedef.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="enum">
+ <element name="enum">
+ <ref name="enum.attlist"/>
+ <zeroOrMore>
+ <ref name="enumvalue"/>
+ </zeroOrMore>
+ <optional>
+ <ref name="purpose"/>
+ </optional>
+ <optional>
+ <ref name="description"/>
+ </optional>
+ </element>
+ </define>
+ <define name="enum.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="enumvalue">
+ <element name="enumvalue">
+ <ref name="enumvalue.attlist"/>
+ <optional>
+ <ref name="default"/>
+ </optional>
+ <optional>
+ <ref name="purpose"/>
+ </optional>
+ <optional>
+ <ref name="description"/>
+ </optional>
+ </element>
+ </define>
+ <define name="enumvalue.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="static-constant">
+ <element name="static-constant">
+ <ref name="static-constant.attlist"/>
+ <ref name="type"/>
+ <ref name="default"/>
+ <optional>
+ <ref name="purpose"/>
+ </optional>
+ <optional>
+ <ref name="description"/>
+ </optional>
+ </element>
+ </define>
+ <define name="static-constant.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="data-member">
+ <element name="data-member">
+ <ref name="data-member.attlist"/>
+ <ref name="type"/>
+ <optional>
+ <ref name="purpose"/>
+ </optional>
+ <optional>
+ <ref name="description"/>
+ </optional>
+ </element>
+ </define>
+ <define name="data-member.attlist" combine="interleave">
+ <attribute name="name"/>
+ <optional>
+ <attribute name="specifiers"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="paramtype">
+ <element name="paramtype">
+ <ref name="paramtype.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="paramtype.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="effects">
+ <element name="effects">
+ <ref name="effects.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="effects.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="postconditions">
+ <element name="postconditions">
+ <ref name="postconditions.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="postconditions.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="method-group">
+ <element name="method-group">
+ <ref name="method-group.attlist"/>
+ <zeroOrMore>
+ <choice>
+ <ref name="method"/>
+ <ref name="overloaded-method"/>
+ </choice>
+ </zeroOrMore>
+ </element>
+ </define>
+ <define name="method-group.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="constructor">
+ <element name="constructor">
+ <ref name="constructor.attlist"/>
+ <optional>
+ <ref name="template"/>
+ </optional>
+ <zeroOrMore>
+ <ref name="parameter"/>
+ </zeroOrMore>
+ <ref name="boost.function.semantics"/>
+ </element>
+ </define>
+ <define name="constructor.attlist" combine="interleave">
+ <optional>
+ <attribute name="specifiers"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="destructor">
+ <element name="destructor">
+ <ref name="destructor.attlist"/>
+ <ref name="boost.function.semantics"/>
+ </element>
+ </define>
+ <define name="destructor.attlist" combine="interleave">
+ <optional>
+ <attribute name="specifiers"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="method">
+ <element name="method">
+ <ref name="method.attlist"/>
+ <optional>
+ <ref name="template"/>
+ </optional>
+ <ref name="type"/>
+ <zeroOrMore>
+ <ref name="parameter"/>
+ </zeroOrMore>
+ <ref name="boost.function.semantics"/>
+ </element>
+ </define>
+ <define name="method.attlist" combine="interleave">
+ <attribute name="name"/>
+ <optional>
+ <attribute name="cv"/>
+ </optional>
+ <optional>
+ <attribute name="specifiers"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="function">
+ <element name="function">
+ <ref name="function.attlist"/>
+ <optional>
+ <ref name="template"/>
+ </optional>
+ <ref name="type"/>
+ <zeroOrMore>
+ <ref name="parameter"/>
+ </zeroOrMore>
+ <ref name="boost.function.semantics"/>
+ </element>
+ </define>
+ <define name="function.attlist" combine="interleave">
+ <attribute name="name"/>
+ <optional>
+ <attribute name="specifiers"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="overloaded-method">
+ <element name="overloaded-method">
+ <ref name="overloaded-method.attlist"/>
+ <zeroOrMore>
+ <ref name="signature"/>
+ </zeroOrMore>
+ <ref name="boost.function.semantics"/>
+ </element>
+ </define>
+ <define name="overloaded-method.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="overloaded-function">
+ <element name="overloaded-function">
+ <ref name="overloaded-function.attlist"/>
+ <zeroOrMore>
+ <ref name="signature"/>
+ </zeroOrMore>
+ <ref name="boost.function.semantics"/>
+ </element>
+ </define>
+ <define name="overloaded-function.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="signature">
+ <element name="signature">
+ <ref name="signature.attlist"/>
+ <optional>
+ <ref name="template"/>
+ </optional>
+ <ref name="type"/>
+ <zeroOrMore>
+ <ref name="parameter"/>
+ </zeroOrMore>
+ </element>
+ </define>
+ <define name="signature.attlist" combine="interleave">
+ <optional>
+ <attribute name="cv"/>
+ </optional>
+ <optional>
+ <attribute name="specifiers"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="requires">
+ <element name="requires">
+ <ref name="requires.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="requires.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="returns">
+ <element name="returns">
+ <ref name="returns.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="returns.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="throws">
+ <element name="throws">
+ <ref name="throws.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="throws.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="complexity">
+ <element name="complexity">
+ <ref name="complexity.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="complexity.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="notes">
+ <element name="notes">
+ <ref name="notes.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="notes.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="rationale">
+ <element name="rationale">
+ <ref name="rationale.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="rationale.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="functionname">
+ <element name="functionname">
+ <ref name="functionname.attlist"/>
+ <text/>
+ </element>
+ </define>
+ <define name="functionname.attlist" combine="interleave">
+ <optional>
+ <attribute name="alt"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="enumname">
+ <element name="enumname">
+ <ref name="enumname.attlist"/>
+ <text/>
+ </element>
+ </define>
+ <define name="enumname.attlist" combine="interleave">
+ <optional>
+ <attribute name="alt"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="macroname">
+ <element name="macroname">
+ <ref name="macroname.attlist"/>
+ <text/>
+ </element>
+ </define>
+ <define name="macroname.attlist" combine="interleave">
+ <optional>
+ <attribute name="alt"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="headername">
+ <element name="headername">
+ <ref name="headername.attlist"/>
+ <text/>
+ </element>
+ </define>
+ <define name="headername.attlist" combine="interleave">
+ <optional>
+ <attribute name="alt"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="globalname">
+ <element name="globalname">
+ <ref name="globalname.attlist"/>
+ <text/>
+ </element>
+ </define>
+ <define name="globalname.attlist" combine="interleave">
+ <optional>
+ <attribute name="alt"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="copy-assignment">
+ <element name="copy-assignment">
+ <ref name="copy-assignment.attlist"/>
+ <optional>
+ <ref name="template"/>
+ </optional>
+ <optional>
+ <ref name="type"/>
+ </optional>
+ <zeroOrMore>
+ <ref name="parameter"/>
+ </zeroOrMore>
+ <ref name="boost.function.semantics"/>
+ </element>
+ </define>
+ <define name="copy-assignment.attlist" combine="interleave">
+ <optional>
+ <attribute name="cv"/>
+ </optional>
+ <optional>
+ <attribute name="specifiers"/>
+ </optional>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="free-function-group">
+ <element name="free-function-group">
+ <ref name="free-function-group.attlist"/>
+ <zeroOrMore>
+ <choice>
+ <ref name="function"/>
+ <ref name="overloaded-function"/>
+ </choice>
+ </zeroOrMore>
+ </element>
+ </define>
+ <define name="free-function-group.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="precondition">
+ <element name="precondition">
+ <ref name="precondition.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="precondition.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="code" combine="choice">
+ <element name="code">
+ <ref name="code.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="code.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="using-namespace">
+ <element name="using-namespace">
+ <ref name="using-namespace.attlist"/>
+ <empty/>
+ </element>
+ </define>
+ <define name="using-namespace.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="using-class">
+ <element name="using-class">
+ <ref name="using-class.attlist"/>
+ <empty/>
+ </element>
+ </define>
+ <define name="using-class.attlist" combine="interleave">
+ <attribute name="name"/>
+ <ref name="boost.common.attrib"/>
+ </define>
+ <!-- ========== Boost Testsuite Extensions ========== -->
+ <define name="boost.testsuite.tests">
+ <choice>
+ <ref name="compile-test"/>
+ <ref name="link-test"/>
+ <ref name="run-test"/>
+ <ref name="compile-fail-test"/>
+ <ref name="link-fail-test"/>
+ <ref name="run-fail-test"/>
+ </choice>
+ </define>
+ <define name="boost.testsuite.test.content">
+ <zeroOrMore>
+ <ref name="source"/>
+ </zeroOrMore>
+ <zeroOrMore>
+ <ref name="lib"/>
+ </zeroOrMore>
+ <zeroOrMore>
+ <ref name="requirement"/>
+ </zeroOrMore>
+ <ref name="purpose"/>
+ <optional>
+ <ref name="if-fails"/>
+ </optional>
+ </define>
+ <define name="testsuite">
+ <element name="testsuite">
+ <ref name="testsuite.attlist"/>
+ <oneOrMore>
+ <ref name="boost.testsuite.tests"/>
+ </oneOrMore>
+ </element>
+ </define>
+ <define name="testsuite.attlist" combine="interleave">
+ <ref name="boost.common.attrib"/>
+ </define>
+ <define name="compile-test">
+ <element name="compile-test">
+ <ref name="compile-test.attlist"/>
+ <ref name="boost.testsuite.test.content"/>
+ </element>
+ </define>
+ <define name="compile-test.attlist" combine="interleave">
+ <attribute name="filename"/>
+ <optional>
+ <attribute name="name"/>
+ </optional>
+ </define>
+ <define name="link-test">
+ <element name="link-test">
+ <ref name="link-test.attlist"/>
+ <ref name="boost.testsuite.test.content"/>
+ </element>
+ </define>
+ <define name="link-test.attlist" combine="interleave">
+ <attribute name="filename"/>
+ <optional>
+ <attribute name="name"/>
+ </optional>
+ </define>
+ <define name="run-test">
+ <element name="run-test">
+ <ref name="run-test.attlist"/>
+ <ref name="boost.testsuite.test.content"/>
+ </element>
+ </define>
+ <define name="run-test.attlist" combine="interleave">
+ <attribute name="filename"/>
+ <optional>
+ <attribute name="name"/>
+ </optional>
+ </define>
+ <define name="compile-fail-test">
+ <element name="compile-fail-test">
+ <ref name="compile-fail-test.attlist"/>
+ <ref name="boost.testsuite.test.content"/>
+ </element>
+ </define>
+ <define name="compile-fail-test.attlist" combine="interleave">
+ <attribute name="filename"/>
+ <optional>
+ <attribute name="name"/>
+ </optional>
+ </define>
+ <define name="link-fail-test">
+ <element name="link-fail-test">
+ <ref name="link-fail-test.attlist"/>
+ <ref name="boost.testsuite.test.content"/>
+ </element>
+ </define>
+ <define name="link-fail-test.attlist" combine="interleave">
+ <attribute name="filename"/>
+ <optional>
+ <attribute name="name"/>
+ </optional>
+ </define>
+ <define name="run-fail-test">
+ <element name="run-fail-test">
+ <ref name="run-fail-test.attlist"/>
+ <ref name="boost.testsuite.test.content"/>
+ </element>
+ </define>
+ <define name="run-fail-test.attlist" combine="interleave">
+ <attribute name="filename"/>
+ <optional>
+ <attribute name="name"/>
+ </optional>
+ </define>
+ <define name="source">
+ <element name="source">
+ <ref name="source.attlist"/>
+ <zeroOrMore>
+ <choice>
+ <text/>
+ <ref name="snippet"/>
+ </choice>
+ </zeroOrMore>
+ </element>
+ </define>
+ <define name="source.attlist" combine="interleave">
+ <empty/>
+ </define>
+ <define name="snippet">
+ <element name="snippet">
+ <ref name="snippet.attlist"/>
+ <empty/>
+ </element>
+ </define>
+ <define name="snippet.attlist" combine="interleave">
+ <attribute name="name"/>
+ </define>
+ <define name="lib">
+ <element name="lib">
+ <ref name="lib.attlist"/>
+ <text/>
+ </element>
+ </define>
+ <define name="lib.attlist" combine="interleave">
+ <empty/>
+ </define>
+ <define name="requirement">
+ <element name="requirement">
+ <ref name="requirement.attlist"/>
+ <text/>
+ </element>
+ </define>
+ <define name="requirement.attlist" combine="interleave">
+ <attribute name="name"/>
+ </define>
+ <define name="if-fails">
+ <element name="if-fails">
+ <ref name="if-fails.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="if-fails.attlist" combine="interleave">
+ <empty/>
+ </define>
+ <define name="parameter">
+ <element name="parameter">
+ <ref name="parameter.attlist"/>
+ <ref name="paramtype"/>
+ <optional>
+ <ref name="default"/>
+ </optional>
+ <optional>
+ <ref name="description"/>
+ </optional>
+ </element>
+ </define>
+ <define name="parameter.attlist" combine="interleave">
+ <optional>
+ <attribute name="name"/>
+ </optional>
+ <optional>
+ <attribute name="pack"/>
+ </optional>
+ </define>
+ <define name="programlisting" combine="interleave">
+ <element name="programlisting">
+ <ref name="db.programlisting.attlist"/>
+ <ref name="any"/>
+ </element>
+ </define>
+ <define name="db.programlisting.attlist" combine="choice">
+ <optional>
+ <attribute name="name"/>
+ </optional>
+ </define>
+ <!-- ========== Customize the DocBook DTD ========== -->
+ <define name="db.programming.inlines" combine="choice">
+ <choice>
+ <ref name="functionname"/>
+ <ref name="libraryname"/>
+ <ref name="enumname"/>
+ <ref name="headername"/>
+ <ref name="macroname"/>
+ <ref name="code"/>
+ </choice>
+ </define>
+ <define name="db.para" combine="choice">
+ <choice>
+ <ref name="using-namespace"/>
+ <ref name="using-class"/>
+ <ref name="librarylist"/>
+ <ref name="librarycategorylist"/>
+ </choice>
+ </define>
+ <define name="local.descobj.class">
+ <ref name="libraryinfo"/>
+ </define>
+ <define name="local.classname.attrib">
+ <optional>
+ <attribute name="alt"/>
+ </optional>
+ </define>
+ <define name="local.methodname.attrib">
+ <optional>
+ <attribute name="alt"/>
+ </optional>
+ </define>
+ <define name="local.refentry.class">
+ <choice>
+ <ref name="library-reference"/>
+ <ref name="testsuite"/>
+ </choice>
+ </define>
+ <define name="local.title.char.mix">
+ <notAllowed/>
+ </define>
+ <define name="any">
+ <zeroOrMore>
+ <choice>
+ <element>
+ <anyName/>
+ <zeroOrMore>
+ <attribute>
+ <anyName/>
+ </attribute>
+ </zeroOrMore>
+ <ref name="any"/>
+ </element>
+ <text/>
+ </choice>
+ </zeroOrMore>
+ </define>
+</grammar>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<library name="Any" dirname="any" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns="http://docbook.org/ns/docbook"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xml:id="any" last-revision="$Date: 2009-07-22 23:35:08 +0100 (Wed, 22 Jul 2009) $">
+ <libraryinfo>
+ <author>
+ <personname>Kevlin Henney</personname>
+ </author>
+
+ <copyright>
+ <year>2001</year>
+ <holder>Kevlin Henney</holder>
+ </copyright>
+
+ <legalnotice>
+ <para>Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file <filename>LICENSE_1_0.txt</filename> or copy at
+ <link xlink:href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</link>)
+ </para>
+ </legalnotice>
+
+ <librarypurpose>
+ Safe, generic container for single values of different value types
+ </librarypurpose>
+
+ <librarycategory name="category:data-structures"/>
+
+ </libraryinfo>
+
+ <title>Boost.Any</title>
+
+ <section>
+ <title>Introduction</title>
+
+ <para>There are times when a generic (in the sense of
+ <emphasis>general</emphasis> as opposed to
+ <emphasis>template-based programming</emphasis>) type is needed:
+ variables that are truly variable, accommodating values of many
+ other more specific types rather than C++'s normal strict and
+ static types. We can distinguish three basic kinds of generic
+ type:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>Converting types that can hold one of a number of
+ possible value types, e.g. <code>int</code> and
+ <code>string</code>, and freely convert between them, for
+ instance interpreting <code>5</code> as <code>"5"</code> or
+ vice-versa. Such types are common in scripting and other
+ interpreted
+ languages.
+ <code><functionname>boost::lexical_cast</functionname></code>
+ supports such conversion functionality.</para>
+ </listitem>
+ <listitem>
+ <para>
+ Discriminated types that contain values of different types but
+ do not attempt conversion between them, i.e. <code>5</code> is
+ held strictly as an <code>int</code> and is not implicitly
+ convertible either to <code>"5"</code> or to
+ <code>5.0</code>. Their indifference to interpretation but
+ awareness of type effectively makes them safe, generic
+ containers of single values, with no scope for surprises from
+ ambiguous conversions.</para>
+ </listitem>
+ <listitem>
+ <para>
+ Indiscriminate types that can refer to anything but are
+ oblivious to the actual underlying type, entrusting all forms
+ of access and interpretation to the programmer. This niche is
+ dominated by <code>void *</code>, which offers plenty of scope
+ for surprising, undefined behavior.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>The <code><classname>boost::any</classname></code> class
+ (based on the class of the same name described in <link xlink:href="http://www.two-sdg.demon.co.uk/curbralan/papers/ValuedConversions.pdf">"Valued
+ Conversions"</link> by Kevlin Henney, <emphasis>C++
+ Report</emphasis> 12(7), July/August 2000) is a variant value type
+ based on the second category. It supports copying of any value
+ type and safe checked extraction of that value strictly against
+ its type. A similar design, offering more appropriate operators,
+ can be used for a generalized function adaptor,
+ <code>any_function</code>, a generalized iterator adaptor,
+ <code>any_iterator</code>, and other object types that need
+ uniform runtime treatment but support only compile-time template
+ parameter conformance.</para>
+ </section>
+
+ <section>
+ <title>Examples</title>
+
+ <using-namespace name="boost"/>
+ <using-class name="boost::any"/>
+
+ <para>The following code demonstrates the syntax for using
+ implicit conversions to and copying of any objects:</para>
+
+<programlisting name="any.example.first">
+#include <list>
+#include <boost/any.hpp>
+
+using <functionname>boost::any_cast</functionname>;
+typedef std::list<<classname>boost::any</classname>> many;
+
+void append_int(many & values, int value)
+{
+ <classname>boost::any</classname> to_append = value;
+ values.push_back(to_append);
+}
+
+void append_string(many & values, const std::string & value)
+{
+ values.push_back(value);
+}
+
+void append_char_ptr(many & values, const char * value)
+{
+ values.push_back(value);
+}
+
+void append_any(many & values, const <classname>boost::any</classname> & value)
+{
+ values.push_back(value);
+}
+
+void append_nothing(many & values)
+{
+ values.push_back(<classname>boost::any</classname>());
+}
+</programlisting>
+
+ <para>The following predicates follow on from the previous
+ definitions and demonstrate the use of queries on any
+ objects:</para>
+
+<programlisting name="any.example.second">
+bool is_empty(const <classname>boost::any</classname> & operand)
+{
+ return operand.<methodname>empty</methodname>();
+}
+
+bool is_int(const <classname>boost::any</classname> & operand)
+{
+ return operand.<methodname>type</methodname>() == typeid(int);
+}
+
+bool is_char_ptr(const <classname>boost::any</classname> & operand)
+{
+ try
+ {
+ <functionname>any_cast</functionname><const char *>(operand);
+ return true;
+ }
+ catch(const <classname>boost::bad_any_cast</classname> &)
+ {
+ return false;
+ }
+}
+
+bool is_string(const <classname>boost::any</classname> & operand)
+{
+ return <functionname>any_cast</functionname><std::string>(&operand);
+}
+
+void count_all(many & values, std::ostream & out)
+{
+ out << "#empty == "
+ << std::count_if(values.begin(), values.end(), is_empty) << std::endl;
+ out << "#int == "
+ << std::count_if(values.begin(), values.end(), is_int) << std::endl;
+ out << "#const char * == "
+ << std::count_if(values.begin(), values.end(), is_char_ptr) << std::endl;
+ out << "#string == "
+ << std::count_if(values.begin(), values.end(), is_string) << std::endl;
+}
+</programlisting>
+
+ <para>The following type, patterned after the OMG's Property Service, defines name-value pairs for arbitrary value types:</para>
+
+<programlisting>
+struct property
+{
+ property();
+ property(const std::string &, const <classname>boost::any</classname> &);
+
+ std::string name;
+ <classname>boost::any</classname> value;
+};
+
+typedef std::list<property> properties;
+</programlisting>
+
+ <para>The following base class demonstrates one approach to
+ runtime polymorphism based callbacks that also require arbitrary
+ argument types. The absence of virtual member templates requires
+ that different solutions have different trade-offs in terms of
+ efficiency, safety, and generality. Using a checked variant type
+ offers one approach:</para>
+
+<programlisting>
+class consumer
+{
+public:
+ virtual void notify(const <classname>any</classname> &) = 0;
+ ...
+};
+</programlisting>
+ </section>
+
+ <library-reference>
+ <section id="any.ValueType">
+ <title><emphasis>ValueType</emphasis> requirements</title>
+
+ <para>Values are strongly informational objects for which
+ identity is not significant, i.e. the focus is principally on
+ their state content and any behavior organized around
+ that. Another distinguishing feature of values is their
+ granularity: normally fine-grained objects representing simple
+ concepts in the system such as quantities.</para>
+
+ <para>As the emphasis of a value lies in its state not its
+ identity, values can be copied and typically assigned one to
+ another, requiring the explicit or implicit definition of a
+ public copy constructor and public assignment operator. Values
+ typically live within other scopes, i.e. within objects or
+ blocks, rather than on the heap. Values are therefore normally
+ passed around and manipulated directly as variables or through
+ references, but not as pointers that emphasize identity and
+ indirection.</para>
+
+ <para>The specific requirements on value types to be used in an
+ <code><classname alt="boost::any">any</classname></code>
+ are:</para>
+
+ <itemizedlist spacing="compact">
+ <listitem><simpara>A <emphasis>ValueType</emphasis> is
+ <emphasis>CopyConstructible</emphasis> [20.1.3].</simpara>
+ </listitem>
+
+ <listitem><simpara>A <emphasis>ValueType</emphasis> is
+ optionally <emphasis>Assignable</emphasis> [23.1]. The strong
+ exception-safety guarantee is required for all forms of
+ assignment.</simpara>
+ </listitem>
+
+ <listitem><simpara>The destructor for a
+ <emphasis>ValueType</emphasis> upholds the no-throw
+ exception-safety guarantee.</simpara>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <header name="boost/any.hpp">
+ <namespace name="boost">
+ <class name="bad_any_cast">
+ <inherit access="public">
+ <classname>std::bad_cast</classname>
+ </inherit>
+ <purpose>The exception thrown in the event of a failed
+ <code><functionname>any_cast</functionname></code> of an
+ <code><classname>any</classname></code> value.</purpose>
+
+ <method name="what" specifiers="virtual" cv="const">
+ <type>const char *</type>
+ </method>
+ </class>
+
+ <class name="any">
+ <purpose>A class whose instances can hold instances of any
+ type that satisfies <link
+ linkend="any.ValueType">ValueType</link>
+ requirements.</purpose>
+
+ <constructor>
+ <postconditions><simpara><code>this-><methodname>empty</methodname>()</code></simpara></postconditions>
+ </constructor>
+
+ <constructor>
+ <parameter name="other">
+ <paramtype>const <classname>any</classname> &</paramtype>
+ </parameter>
+
+ <effects><simpara> Copy constructor that copies content of
+ <code>other</code> into new instance, so that any content
+ is equivalent in both type and value to the content of
+ <code>other</code>, or empty if <code>other</code> is
+ empty. </simpara></effects>
+
+ <throws><simpara>May fail with a
+ <code><classname>std::bad_alloc</classname></code>
+ exception or any exceptions arising from the copy
+ constructor of the contained type.</simpara></throws>
+ </constructor>
+
+ <constructor>
+ <template>
+ <template-type-parameter name="ValueType"/>
+ </template>
+
+ <parameter name="value">
+ <paramtype>const ValueType &</paramtype>
+ </parameter>
+
+ <effects><simpara>Makes a copy of <code>value</code>, so
+ that the initial content of the new instance is equivalent
+ in both type and value to
+ <code>value</code>.</simpara></effects>
+
+ <throws><simpara><code><classname>std::bad_alloc</classname></code>
+ or any exceptions arising from the copy constructor of the
+ contained type.</simpara></throws>
+ </constructor>
+
+ <destructor>
+ <effects><simpara>Releases any and all resources used in
+ management of instance.</simpara></effects>
+ <throws><simpara>Nothing.</simpara></throws>
+ </destructor>
+
+ <copy-assignment>
+ <type><classname>any</classname> &</type>
+
+ <parameter name="rhs">
+ <paramtype>const <classname>any</classname> &</paramtype>
+ </parameter>
+
+ <effects><simpara>Copies content of <code>rhs</code> into
+ current instance, discarding previous content, so that the
+ new content is equivalent in both type and value to the
+ content of <code>rhs</code>, or empty if
+ <code>rhs.<methodname>empty</methodname>()</code>.</simpara></effects>
+
+ <throws><simpara><code><classname>std::bad_alloc</classname></code>
+ or any exceptions arising from the copy constructor of the
+ contained type. Assignment satisfies the strong guarantee
+ of exception safety.</simpara></throws>
+ </copy-assignment>
+
+ <copy-assignment>
+ <template>
+ <template-type-parameter name="ValueType"/>
+ </template>
+
+ <type><classname>any</classname> &</type>
+
+ <parameter name="rhs">
+ <paramtype>const ValueType &</paramtype>
+ </parameter>
+
+ <effects><simpara>Makes a copy of <code>rhs</code>,
+ discarding previous content, so that the new content of is
+ equivalent in both type and value to
+ <code>rhs</code>.</simpara></effects>
+
+ <throws><simpara><code><classname>std::bad_alloc</classname></code>
+ or any exceptions arising from the copy constructor of the
+ contained type. Assignment satisfies the strong guarantee
+ of exception safety.</simpara></throws>
+ </copy-assignment>
+
+ <method-group name="modifiers">
+ <method name="swap">
+ <type><classname>any</classname> &</type>
+
+ <parameter name="rhs">
+ <paramtype><classname>any</classname> &</paramtype>
+ </parameter>
+
+ <effects><simpara>Exchange of the contents of
+ <code>*this</code> and
+ <code>rhs</code>.</simpara></effects>
+
+ <returns><simpara><code>*this</code></simpara></returns>
+
+ <throws><simpara>Nothing.</simpara></throws>
+ </method>
+ </method-group>
+
+ <method-group name="queries">
+ <method name="empty" cv="const">
+ <type>bool</type>
+
+ <returns><simpara><code>true</code> if instance is
+ empty, otherwise <code>false</code>.</simpara></returns>
+
+ <throws><simpara>Will not throw.</simpara></throws>
+ </method>
+
+ <method name="type" cv="const">
+ <type>const <classname>std::type_info</classname> &</type>
+
+ <returns><simpara>the <code>typeid</code> of the
+ contained value if instance is non-empty, otherwise
+ <code>typeid(void)</code>.</simpara></returns>
+
+ <notes><simpara>Useful for querying against types known
+ either at compile time or only at
+ runtime.</simpara></notes>
+ </method>
+ </method-group>
+ </class>
+
+ <overloaded-function name="any_cast">
+ <signature>
+ <template>
+ <template-type-parameter name="T"/>
+ </template>
+
+ <type>T</type>
+
+ <parameter name="operand">
+ <paramtype><classname>any</classname> &</paramtype>
+ </parameter>
+ </signature>
+
+ <signature>
+ <template>
+ <template-type-parameter name="T"/>
+ </template>
+
+ <type>T</type>
+
+ <parameter name="operand">
+ <paramtype>const <classname>any</classname> &</paramtype>
+ </parameter>
+ </signature>
+
+ <signature>
+ <template>
+ <template-type-parameter name="ValueType"/>
+ </template>
+
+ <type>const ValueType *</type>
+
+ <parameter name="operand">
+ <paramtype>const <classname>any</classname> *</paramtype>
+ </parameter>
+ </signature>
+
+ <signature>
+ <template>
+ <template-type-parameter name="ValueType"/>
+ </template>
+
+ <type>ValueType *</type>
+
+ <parameter name="operand">
+ <paramtype><classname>any</classname> *</paramtype>
+ </parameter>
+ </signature>
+
+ <purpose><simpara>Custom keyword cast for extracting a value
+ of a given type from an
+ <code><classname>any</classname></code>.</simpara></purpose>
+
+ <returns><simpara> If passed a pointer, it returns a
+ similarly qualified pointer to the value content if
+ successful, otherwise null is returned.
+ If T is ValueType, it returns a copy of the held value, otherwise, if T is a reference
+ to (possibly const qualified) ValueType, it returns a reference to the held
+ value.</simpara></returns>
+
+ <throws><simpara>Overloads taking an
+ <code><classname>any</classname></code> pointer do not
+ throw; overloads taking an
+ <code><classname>any</classname></code> value or reference
+ throws <code><classname>bad_any_cast</classname></code> if
+ unsuccessful.</simpara></throws>
+
+ </overloaded-function>
+ </namespace>
+ </header>
+ </library-reference>
+
+ <section>
+ <title>Acknowledgements</title>
+
+ <para>Doug Gregor ported the documentation to the BoostBook format.</para>
+ </section>
+</library>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<library name="Array" dirname="array" xml:id="array" last-revision="$Date: 2006-12-01 10:29:49 +0000 (Fri, 01 Dec 2006) $"
+ xmlns="http://docbook.org/ns/docbook"
+ xmlns:xlink="http://www.w3.org/1999/xlink">
+ <libraryinfo>
+ <author>
+ <personname>
+ <firstname>Nicolai</firstname>
+ <surname>Josuttis</surname>
+ </personname>
+ </author>
+
+ <copyright>
+ <year>2001</year>
+ <year>2002</year>
+ <year>2003</year>
+ <year>2004</year>
+ <holder>Nicolai M. Josuttis</holder>
+ </copyright>
+
+ <legalnotice>
+ <para>Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file <filename>LICENSE_1_0.txt</filename> or copy at
+ <link
+ xlink:href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</link>)
+ </para>
+ </legalnotice>
+
+ <librarypurpose>STL compliant container wrapper for arrays of constant size</librarypurpose>
+ <librarycategory name="category:containers"/>
+ </libraryinfo>
+
+ <title>Boost.Array</title>
+
+ <section xml:id="array.intro">
+ <title>Introduction</title>
+
+ <using-namespace name="boost"/>
+ <using-class name="array"/>
+
+ <para>The C++ Standard Template Library STL as part of the C++
+ Standard Library provides a framework for processing algorithms on
+ different kind of containers. However, ordinary arrays don't
+ provide the interface of STL containers (although, they provide
+ the iterator interface of STL containers).</para>
+
+ <para>As replacement for ordinary arrays, the STL provides class
+ <code><classname>std::vector</classname></code>. However,
+ <code><classname>std::vector<></classname></code> provides
+ the semantics of dynamic arrays. Thus, it manages data to be able
+ to change the number of elements. This results in some overhead in
+ case only arrays with static size are needed.</para>
+
+ <para>In his book, <emphasis>Generic Programming and the
+ STL</emphasis>, Matthew H. Austern introduces a useful wrapper
+ class for ordinary arrays with static size, called
+ <code>block</code>. It is safer and has no worse performance than
+ ordinary arrays. In <emphasis>The C++ Programming
+ Language</emphasis>, 3rd edition, Bjarne Stroustrup introduces a
+ similar class, called <code>c_array</code>, which I (<link
+ xlink:href="http://www.josuttis.com">Nicolai Josuttis</link>) present
+ slightly modified in my book <emphasis>The C++ Standard Library -
+ A Tutorial and Reference</emphasis>, called
+ <code>carray</code>. This is the essence of these approaches
+ spiced with many feedback from <link
+ xlink:href="http://www.boost.org">boost</link>.</para>
+
+ <para>After considering different names, we decided to name this
+ class simply <code><classname>array</classname></code>.</para>
+
+ <para>Note that this class is suggested to be part of the next
+ Technical Report, which will extend the C++ Standard (see
+ <link xlink:href="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm">http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm</link>).</para>
+
+ <para>Class <code><classname>array</classname></code> fulfills most
+ but not all of the requirements of "reversible containers" (see
+ Section 23.1, [lib.container.requirements] of the C++
+ Standard). The reasons array is not an reversible STL container is
+ because:
+ <itemizedlist spacing="compact">
+ <listitem><simpara>No constructors are provided.</simpara></listitem>
+ <listitem><simpara>Elements may have an undetermined initial value (see <xref linkend="array.rationale"/>).</simpara></listitem>
+ <listitem><simpara><functionname>swap</functionname>() has no constant complexity.</simpara></listitem>
+ <listitem><simpara><methodname>size</methodname>() is always constant, based on the second template argument of the type.</simpara></listitem>
+ <listitem><simpara>The container provides no allocator support.</simpara></listitem>
+ </itemizedlist>
+ </para>
+
+ <para>It doesn't fulfill the requirements of a "sequence" (see Section 23.1.1, [lib.sequence.reqmts] of the C++ Standard), except that:
+ <itemizedlist spacing="compact">
+ <listitem><simpara><methodname>front</methodname>() and <methodname>back</methodname>() are provided.</simpara></listitem>
+ <listitem><simpara><methodname>operator[]</methodname> and <methodname>at</methodname>() are provided.</simpara></listitem>
+ </itemizedlist>
+ </para>
+ </section>
+
+ <library-reference>
+ <header name="boost/array.hpp">
+ <namespace name="boost">
+ <class name="array">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <purpose><para>STL compliant container wrapper for arrays of constant size</para></purpose>
+ <typedef name="value_type">
+ <type>T</type>
+ </typedef>
+ <typedef name="iterator">
+ <type>T*</type>
+ </typedef>
+ <typedef name="const_iterator">
+ <type>const T*</type>
+ </typedef>
+ <typedef name="reverse_iterator">
+ <type><classname>std::reverse_iterator</classname><iterator></type>
+ </typedef>
+ <typedef name="const_reverse_iterator">
+ <type><classname>std::reverse_iterator</classname><const_iterator></type>
+ </typedef>
+ <typedef name="reference">
+ <type>T&</type>
+ </typedef>
+ <typedef name="const_reference">
+ <type>const T&</type>
+ </typedef>
+ <typedef name="size_type">
+ <type>std::size_t</type>
+ </typedef>
+ <typedef name="difference_type">
+ <type>std::ptrdiff_t</type>
+ </typedef>
+
+ <static-constant name="static_size">
+ <type>size_type</type>
+ <default>N</default>
+ </static-constant>
+
+ <copy-assignment>
+ <template>
+ <template-type-parameter name="U"/>
+ </template>
+ <parameter name="other">
+ <paramtype>const <classname>array</classname><U, N>&</paramtype>
+ </parameter>
+ <effects><simpara><code>std::copy(rhs.<methodname>begin</methodname>(),rhs.<methodname>end</methodname>(), <methodname>begin</methodname>())</code></simpara></effects>
+ </copy-assignment>
+
+ <method-group name="iterator support">
+ <overloaded-method name="begin">
+ <signature>
+ <type>iterator</type>
+ </signature>
+ <signature cv="const">
+ <type>const_iterator</type>
+ </signature>
+
+ <returns><simpara>iterator for the first element</simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </overloaded-method>
+
+ <overloaded-method name="end">
+ <signature>
+ <type>iterator</type>
+ </signature>
+ <signature cv="const">
+ <type>const_iterator</type>
+ </signature>
+
+ <returns><simpara>iterator for position after the last element</simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </overloaded-method>
+ </method-group>
+
+ <method-group name="reverse iterator support">
+ <overloaded-method name="rbegin">
+ <signature>
+ <type>reverse_iterator</type>
+ </signature>
+ <signature cv="const">
+ <type>const_reverse_iterator</type>
+ </signature>
+
+ <returns><simpara>reverse iterator for the first element of reverse iteration</simpara></returns>
+ </overloaded-method>
+
+ <overloaded-method name="rend">
+ <signature>
+ <type>reverse_iterator</type>
+ </signature>
+ <signature cv="const">
+ <type>const_reverse_iterator</type>
+ </signature>
+
+ <returns><simpara>reverse iterator for position after the last element in reverse iteration</simpara></returns>
+ </overloaded-method>
+ </method-group>
+
+ <method-group name="capacity">
+ <method name="size">
+ <type>size_type</type>
+ <returns><simpara><code>N</code></simpara></returns>
+ </method>
+ <method name="empty">
+ <type>bool</type>
+ <returns><simpara><code>N==0</code></simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </method>
+ <method name="max_size">
+ <type>size_type</type>
+ <returns><simpara><code>N</code></simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </method>
+ </method-group>
+
+ <method-group name="element access">
+ <overloaded-method name="operator[]">
+ <signature>
+ <type>reference</type>
+ <parameter name="i">
+ <paramtype>size_type</paramtype>
+ </parameter>
+ </signature>
+
+ <signature cv="const">
+ <type>const_reference</type>
+ <parameter name="i">
+ <paramtype>size_type</paramtype>
+ </parameter>
+ </signature>
+
+ <requires><simpara><code>i < N</code></simpara></requires>
+ <returns><simpara>element with index <code>i</code></simpara></returns>
+ <throws><simpara>will not throw.</simpara></throws>
+ </overloaded-method>
+
+ <overloaded-method name="at">
+ <signature>
+ <type>reference</type>
+ <parameter name="i">
+ <paramtype>size_type</paramtype>
+ </parameter>
+ </signature>
+
+ <signature cv="const">
+ <type>const_reference</type>
+ <parameter name="i">
+ <paramtype>size_type</paramtype>
+ </parameter>
+ </signature>
+
+ <returns><simpara>element with index <code>i</code></simpara></returns>
+ <throws><simpara><code><classname>std::range_error</classname></code> if <code>i >= N</code></simpara></throws>
+ </overloaded-method>
+
+ <overloaded-method name="front">
+ <signature>
+ <type>reference</type>
+ </signature>
+ <signature cv="const">
+ <type>const_reference</type>
+ </signature>
+ <requires><simpara><code>N > 0</code></simpara></requires>
+ <returns><simpara>the first element</simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </overloaded-method>
+
+ <overloaded-method name="back">
+ <signature>
+ <type>reference</type>
+ </signature>
+ <signature cv="const">
+ <type>const_reference</type>
+ </signature>
+ <requires><simpara><code>N > 0</code></simpara></requires>
+ <returns><simpara>the last element</simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </overloaded-method>
+
+ <method name="data" cv="const">
+ <type>const T*</type>
+ <returns><simpara><code>elems</code></simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </method>
+
+ <method name="c_array">
+ <type>T*</type>
+ <returns><simpara><code>elems</code></simpara></returns>
+ <throws><simpara>will not throw</simpara></throws>
+ </method>
+ </method-group>
+
+ <method-group name="modifiers">
+ <method name="swap">
+ <type>void</type>
+ <parameter name="other">
+ <paramtype><classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <effects><simpara><code>std::swap_ranges(<methodname>begin</methodname>(), <methodname>end</methodname>(), other.<methodname>begin</methodname>())</code></simpara></effects>
+ <complexity><simpara>linear in <code>N</code></simpara></complexity>
+ </method>
+ <method name="assign">
+ <type>void</type>
+ <parameter name="value">
+ <paramtype>const T&</paramtype>
+ </parameter>
+ <effects><simpara><code>std::fill_n(<methodname>begin</methodname>(), N, value)</code></simpara></effects>
+ </method>
+ </method-group>
+
+ <data-member name="elems[N]"> <!-- HACK -->
+ <type>T</type>
+ </data-member>
+
+ <free-function-group name="specialized algorithms">
+ <function name="swap">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <type>void</type>
+
+ <parameter name="x">
+ <paramtype><classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype><classname>array</classname><T, N>&</paramtype>
+ </parameter>
+
+ <effects><simpara><code>x.<methodname>swap</methodname>(y)</code></simpara></effects>
+ <throws><simpara>will not throw.</simpara></throws>
+ </function>
+ </free-function-group>
+
+ <free-function-group name="comparisons">
+ <function name="operator==">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <type>bool</type>
+
+ <parameter name="x">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+
+ <returns><simpara><code>std::equal(x.<methodname>begin</methodname>(), x.<methodname>end</methodname>(), y.<methodname>begin</methodname>())</code></simpara>
+ </returns>
+ </function>
+
+ <function name="operator!=">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <type>bool</type>
+
+ <parameter name="x">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+
+ <returns><simpara><code>!(x == y)</code></simpara>
+ </returns>
+ </function>
+
+ <function name="operator<">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <type>bool</type>
+
+ <parameter name="x">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+
+ <returns><simpara><code>std::lexicographical_compare(x.<methodname>begin</methodname>(), x.<methodname>end</methodname>(), y.<methodname>begin</methodname>(), y.<methodname>end</methodname>())</code></simpara>
+ </returns>
+ </function>
+
+ <function name="operator>">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <type>bool</type>
+
+ <parameter name="x">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+
+ <returns><simpara><code>y < x</code></simpara></returns>
+ </function>
+
+ <function name="operator<=">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <type>bool</type>
+
+ <parameter name="x">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+
+ <returns><simpara><code>!(y < x)</code></simpara></returns>
+ </function>
+
+ <function name="operator>=">
+ <template>
+ <template-type-parameter name="T"/>
+ <template-nontype-parameter name="N">
+ <type>std::size_t</type>
+ </template-nontype-parameter>
+ </template>
+
+ <type>bool</type>
+
+ <parameter name="x">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+ <parameter name="y">
+ <paramtype>const <classname>array</classname><T, N>&</paramtype>
+ </parameter>
+
+ <returns><simpara><code>!(x < y)</code></simpara></returns>
+ </function>
+ </free-function-group>
+ </class>
+ </namespace>
+ </header>
+ </library-reference>
+
+<section xml:id="array.rationale">
+ <title>Design Rationale</title>
+
+ <para>There was an important design tradeoff regarding the
+ constructors: We could implement array as an "aggregate" (see
+ Section 8.5.1, [dcl.init.aggr], of the C++ Standard). This would
+ mean:
+ <itemizedlist>
+ <listitem><simpara>An array can be initialized with a
+ brace-enclosing, comma-separated list of initializers for the
+ elements of the container, written in increasing subscript
+ order:</simpara>
+
+ <programlisting><classname>boost::array</classname><int,4> a = { { 1, 2, 3 } };</programlisting>
+
+ <simpara>Note that if there are fewer elements in the
+ initializer list, then each remaining element gets
+ default-initialized (thus, it has a defined value).</simpara>
+ </listitem></itemizedlist></para>
+
+ <para>However, this approach has its drawbacks: <emphasis
+ role="bold"> passing no initializer list means that the elements
+ have an indetermined initial value</emphasis>, because the rule says
+ that aggregates may have:
+ <itemizedlist>
+ <listitem><simpara>No user-declared constructors.</simpara></listitem>
+ <listitem><simpara>No private or protected non-static data members.</simpara></listitem>
+ <listitem><simpara>No base classes.</simpara></listitem>
+ <listitem><simpara>No virtual functions.</simpara></listitem>
+ </itemizedlist>
+ </para>
+
+ <para>Nevertheless, The current implementation uses this approach.</para>
+
+ <para>Note that for standard conforming compilers it is possible to
+ use fewer braces (according to 8.5.1 (11) of the Standard). That is,
+ you can initialize an array as follows:</para>
+
+<programlisting>
+<classname>boost::array</classname><int,4> a = { 1, 2, 3 };
+</programlisting>
+
+ <para>I'd appreciate any constructive feedback. <emphasis
+ role="bold">Please note: I don't have time to read all boost
+ mails. Thus, to make sure that feedback arrives to me, please send
+ me a copy of each mail regarding this class.</emphasis></para>
+
+ <para>The code is provided "as is" without expressed or implied
+ warranty.</para>
+
+</section>
+
+<section xml:id="array.more.info">
+ <title>For more information...</title>
+ <para>To find more details about using ordinary arrays in C++ and
+ the framework of the STL, see e.g.
+
+ <literallayout>The C++ Standard Library - A Tutorial and Reference
+by Nicolai M. Josuttis
+Addison Wesley Longman, 1999
+ISBN 0-201-37926-0</literallayout>
+ </para>
+
+ <para><link xlink:href="http://www.josuttis.com/">Home Page of Nicolai
+ Josuttis</link></para>
+</section>
+
+<section xml:id="array.ack">
+ <title>Acknowledgements</title>
+
+ <para>Doug Gregor ported the documentation to the BoostBook format.</para>
+</section>
+
+<!-- Notes:
+ empty() should return N != 0
+ size(), empty(), max_size() should be const
+ -->
+
+</library>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2002-2006 Pavol Droba.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section xml:id="string_algo.concept"
+xmlns="http://docbook.org/ns/docbook"
+ xmlns:xlink="http://www.w3.org/1999/xlink">
+ <title>Concepts</title>
+
+ <using-namespace name="boost"/>
+ <using-namespace name="boost::algorithm"/>
+
+ <section>
+ <title>Definitions</title>
+
+ <table>
+ <title>Notation</title>
+ <tgroup cols="2" align="left">
+ <tbody>
+ <row>
+ <entry><code>F</code></entry>
+ <entry>A type that is a model of Finder</entry>
+ </row>
+ <row>
+ <entry><code>Fmt</code></entry>
+ <entry>A type that is a model of Formatter</entry>
+ </row>
+ <row>
+ <entry><code>Iter</code></entry>
+ <entry>
+ Iterator Type
+ </entry>
+ </row>
+ <row>
+ <entry><code>f</code></entry>
+ <entry>Object of type <code>F</code></entry>
+ </row>
+ <row>
+ <entry><code>fmt</code></entry>
+ <entry>Object of type <code>Fmt</code></entry>
+ </row>
+ <row>
+ <entry><code>i,j</code></entry>
+ <entry>Objects of type <code>Iter</code></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+
+ <section xml:id="string_algo.finder_concept">
+ <title>Finder Concept</title>
+
+ <para>
+ Finder is a functor which searches for an arbitrary part of a container.
+ The result of the search is given as an <classname>iterator_range</classname>
+ delimiting the selected part.
+ </para>
+
+ <table>
+ <title>Valid Expressions</title>
+ <tgroup cols="3" align="left">
+ <thead>
+ <row>
+ <entry>Expression</entry>
+ <entry>Return Type</entry>
+ <entry>Effects</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><code>f(i,j)</code></entry>
+ <entry>Convertible to <code>iterator_range<Iter></code></entry>
+ <entry>Perform the search on the interval [i,j) and returns the result of the search</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>
+ Various algorithms need to perform a search in a container and a Finder is a generalization of such
+ search operations that allows algorithms to abstract from searching. For instance, generic replace
+ algorithms can replace any part of the input, and the Finder is used to select the desired one.
+ </para>
+ <para>
+ Note, that it is only required that the finder works with a particular iterator type. However,
+ a Finder operation can be defined as a template, allowing the Finder to work with any iterator.
+ </para>
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+ <para>
+ <itemizedlist>
+ <listitem>
+ <para>Finder implemented as a class. This Finder always returns the whole input as a match. <code>operator()</code>
+ is templated, so that the finder can be used on any iterator type.
+
+ <programlisting>
+struct simple_finder
+{
+ template<typename ForwardIteratorT>
+ boost::iterator_range<ForwardIteratorT> operator()(
+ ForwardIteratorT Begin,
+ ForwardIteratorT End )
+ {
+ return boost::make_range( Begin, End );
+ }
+};
+ </programlisting>
+ </para></listitem>
+ <listitem>
+ <para>Function Finder. Finder can be any function object. That is, any ordinary function with the
+ required signature can be used as well. However, such a function can be used only for
+ a specific iterator type.
+
+ <programlisting>
+boost::iterator_range<std::string> simple_finder(
+ std::string::const_iterator Begin,
+ std::string::const_iterator End )
+{
+ return boost::make_range( Begin, End );
+}
+ </programlisting>
+ </para></listitem>
+ </itemizedlist>
+ </para>
+ </section>
+ <section xml:id="string_algo.formatter_concept">
+ <title>Formatter concept</title>
+
+ <para>
+ Formatters are used by <link linkend="string_algo.replace">replace algorithms</link>.
+ They are used in close combination with finders.
+ A formatter is a functor, which takes a result from a Finder operation and transforms it in a specific way.
+ The operation of the formatter can use additional information provided by a specific finder,
+ for example <functionname>regex_formatter()</functionname> uses the match information from
+ <functionname>regex_finder()</functionname> to format the result of formatter operation.
+ </para>
+
+ <table>
+ <title>Valid Expressions</title>
+ <tgroup cols="3" align="left">
+ <thead>
+ <row>
+ <entry>Expression</entry>
+ <entry>Return Type</entry>
+ <entry>Effects</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><code>fmt(f(i,j))</code></entry>
+ <entry>A container type, accessible using container traits</entry>
+ <entry>Formats the result of the finder operation</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <para>
+ Similarly to finders, formatters generalize format operations. When a finder is used to
+ select a part of the input, formatter takes this selection and performs some formating
+ on it. Algorithms can abstract from formating using a formatter.
+ </para>
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+ <para>
+ <itemizedlist>
+ <listitem>
+ <para>Formatter implemented as a class. This Formatter does not perform any formating and
+ returns the match, repackaged. <code>operator()</code>
+ is templated, so that the Formatter can be used on any Finder type.
+
+ <programlisting>
+struct simple_formatter
+{
+ template<typename FindResultT>
+ std::string operator()( const FindResultT& Match )
+ {
+ std::string Temp( Match.begin(), Match.end() );
+ return Temp;
+ }
+};
+ </programlisting>
+ </para> </listitem>
+ <listitem>
+ <para>Function Formatter. Similarly to Finder, Formatter can be any function object.
+ However, as a function, it can be used only with a specific Finder type.
+
+ <programlisting>
+std::string simple_formatter( boost::iterator_range<std::string::const_iterator>& Match )
+{
+ std::string Temp( Match.begin(), Match.end() );
+ return Temp;
+}
+ </programlisting>
+ </para></listitem>
+ </itemizedlist>
+ </para>
+ </section>
+</section>