gcc/libstdc++-v3/doc/xml/manual/utilities.xml
Benjamin Kosnik c6a21af2ff DocBook 4.5 to 5.0 transition.
2010-07-22  Benjamin Kosnik  <bkoz@redhat.com>

	DocBook 4.5 to 5.0 transition.
	* doc/xml/authors.xml: Update markup to DocBook 5.0.
	* doc/xml/faq.xml: Same.
	* doc/xml/api.xml: Same.
	* doc/xml/class.txml
	* doc/xml/gnu/gpl-3.0.xml: Same.
	* doc/xml/gnu/fdl-1.2.xml: Same.
	* doc/xml/gnu/fdl-1.3.xml: Same.
	* doc/xml/gnu/gpl-2.0.xml: Same.
	* doc/xml/chapter.txml: Same.
	* doc/xml/manual/mt_allocator.xml: Same.
	* doc/xml/manual/allocator.xml: Same.
	* doc/xml/manual/ctype.xml: Same.
	* doc/xml/manual/numerics.xml: Same.
	* doc/xml/manual/codecvt.xml: Same.
	* doc/xml/manual/backwards_compatibility.xml: Same.
	* doc/xml/manual/concurrency.xml: Same.
	* doc/xml/manual/intro.xml: Same.
	* doc/xml/manual/abi.xml: Same.
	* doc/xml/manual/shared_ptr.xml: Same.
	* doc/xml/manual/status_cxxtr1.xml: Same.
	* doc/xml/manual/auto_ptr.xml: Same.
	* doc/xml/manual/internals.xml: Same.
	* doc/xml/manual/atomics.xml: Same.
	* doc/xml/manual/parallel_mode.xml: Same.
	* doc/xml/manual/status_cxx1998.xml: Same.
	* doc/xml/manual/profile_mode.xml: Same.
	* doc/xml/manual/containers.xml: Same.
	* doc/xml/manual/io.xml: Same.
	* doc/xml/manual/concurrency_extensions.xml: Same.
	* doc/xml/manual/appendix_porting.xml: Same.
	* doc/xml/manual/utilities.xml: Same.
	* doc/xml/manual/support.xml: Same.
	* doc/xml/manual/bitmap_allocator.xml: Same.
	* doc/xml/manual/configure.xml: Same.
	* doc/xml/manual/build_hacking.xml: Same.
	* doc/xml/manual/evolution.xml: Same.
	* doc/xml/manual/using.xml: Same.
	* doc/xml/manual/using_exceptions.xml: Same.
	* doc/xml/manual/debug.xml: Same.
	* doc/xml/manual/localization.xml: Same.
	* doc/xml/manual/strings.xml: Same.
	* doc/xml/manual/debug_mode.xml: Same.
	* doc/xml/manual/locale.xml: Same.
	* doc/xml/manual/extensions.xml: Same.
	* doc/xml/manual/appendix_contributing.xml: Same.
	* doc/xml/manual/prerequisites.xml: Same.
	* doc/xml/manual/messages.xml: Same.
	* doc/xml/manual/diagnostics.xml: Same.
	* doc/xml/manual/algorithms.xml: Same.
	* doc/xml/manual/appendix_free.xml: Same.
	* doc/xml/manual/iterators.xml: Same.
	* doc/xml/manual/spine.xml: Same.
	* doc/xml/manual/status_cxxtr24733.xml: Same.
	* doc/xml/manual/status_cxx200x.xml: Same.
	* doc/xml/manual/test.xml: Same.
	* doc/xml/book.txml: Same.
	* doc/xml/spine.xml: Same.
	* doc/Makefile.am: Same.
	* doc/Makefile.in: Regenerate.

From-SVN: r162433
2010-07-22 22:58:15 +00:00

125 lines
4.5 KiB
XML

<chapter xmlns="http://docbook.org/ns/docbook" version="5.0"
xml:id="std.util" xreflabel="Utilities">
<?dbhtml filename="utilities.html"?>
<info><title>
Utilities
<indexterm><primary>Utilities</primary></indexterm>
</title>
<keywordset>
<keyword>
ISO C++
</keyword>
<keyword>
library
</keyword>
</keywordset>
</info>
<!-- Section 01 : Functors -->
<section xml:id="std.util.functors" xreflabel="Functors"><info><title>Functors</title></info>
<?dbhtml filename="functors.html"?>
<para>If you don't know what functors are, you're not alone. Many people
get slightly the wrong idea. In the interest of not reinventing
the wheel, we will refer you to the introduction to the functor
concept written by SGI as chapter of their STL, in
<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.sgi.com/tech/stl/functors.html">their
http://www.sgi.com/tech/stl/functors.html</link>.
</para>
</section>
<!-- Section 02 : Pairs -->
<section xml:id="std.util.pairs" xreflabel="Pairs"><info><title>Pairs</title></info>
<?dbhtml filename="pairs.html"?>
<para>The <code>pair&lt;T1,T2&gt;</code> is a simple and handy way to
carry around a pair of objects. One is of type T1, and another of
type T2; they may be the same type, but you don't get anything
extra if they are. The two members can be accessed directly, as
<code>.first</code> and <code>.second</code>.
</para>
<para>Construction is simple. The default ctor initializes each member
with its respective default ctor. The other simple ctor,
</para>
<programlisting>
pair (const T1&amp; x, const T2&amp; y);
</programlisting>
<para>does what you think it does, <code>first</code> getting <code>x</code>
and <code>second</code> getting <code>y</code>.
</para>
<para>There is a copy constructor, but it requires that your compiler
handle member function templates:
</para>
<programlisting>
template &lt;class U, class V&gt; pair (const pair&lt;U,V&gt;&amp; p);
</programlisting>
<para>The compiler will convert as necessary from U to T1 and from
V to T2 in order to perform the respective initializations.
</para>
<para>The comparison operators are done for you. Equality
of two <code>pair&lt;T1,T2&gt;</code>s is defined as both <code>first</code>
members comparing equal and both <code>second</code> members comparing
equal; this simply delegates responsibility to the respective
<code>operator==</code> functions (for types like MyClass) or builtin
comparisons (for types like int, char, etc).
</para>
<para>
The less-than operator is a bit odd the first time you see it. It
is defined as evaluating to:
</para>
<programlisting>
x.first &lt; y.first ||
( !(y.first &lt; x.first) &amp;&amp; x.second &lt; y.second )
</programlisting>
<para>The other operators are not defined using the <code>rel_ops</code>
functions above, but their semantics are the same.
</para>
<para>Finally, there is a template function called <function>make_pair</function>
that takes two references-to-const objects and returns an
instance of a pair instantiated on their respective types:
</para>
<programlisting>
pair&lt;int,MyClass&gt; p = make_pair(4,myobject);
</programlisting>
</section>
<!-- Section 03 : Memory -->
<section xml:id="std.util.memory" xreflabel="Memory"><info><title>Memory</title></info>
<?dbhtml filename="memory.html"?>
<para>
Memory contains three general areas. First, function and operator
calls via <function>new</function> and <function>delete</function>
operator or member function calls. Second, allocation via
<classname>allocator</classname>. And finally, smart pointer and
intelligent pointer abstractions.
</para>
<!-- Section 01 : allocator -->
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" href="allocator.xml">
</xi:include>
<!-- Section 02 : auto_ptr -->
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" href="auto_ptr.xml">
</xi:include>
<!-- Section 03 : shared_ptr -->
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" href="shared_ptr.xml">
</xi:include>
</section>
<!-- Section 04 : Traits -->
<section xml:id="std.util.traits" xreflabel="Traits"><info><title>Traits</title></info>
<?dbhtml filename="traits.html"?>
<para>
</para>
</section>
</chapter>