/Src/Dependencies/Boost/doc/test/array.xml

http://hadesmem.googlecode.com/ · XML · 64 lines · 53 code · 11 blank · 0 comment · 0 complexity · 8a21654d78d6b6be8239799a2ba13ba8 MD5 · raw file

  1. <section id="array.intro">
  2. <title>Introduction</title>
  3. <using-namespace name="boost"/>
  4. <using-class name="array"/>
  5. <para>The C++ Standard Template Library STL as part of the C++
  6. Standard Library provides a framework for processing algorithms on
  7. different kind of containers. However, ordinary arrays don't
  8. provide the interface of STL containers (although, they provide
  9. the iterator interface of STL containers).</para>
  10. <para>As replacement for ordinary arrays, the STL provides class
  11. <code><classname>std::vector</classname></code>. However,
  12. <code><classname>std::vector&lt;&gt;</classname></code> provides
  13. the semantics of dynamic arrays. Thus, it manages data to be able
  14. to change the number of elements. This results in some overhead in
  15. case only arrays with static size are needed.</para>
  16. <para>In his book, <emphasis>Generic Programming and the
  17. STL</emphasis>, Matthew H. Austern introduces a useful wrapper
  18. class for ordinary arrays with static size, called
  19. <code>block</code>. It is safer and has no worse performance than
  20. ordinary arrays. In <emphasis>The C++ Programming
  21. Language</emphasis>, 3rd edition, Bjarne Stroustrup introduces a
  22. similar class, called <code>c_array</code>, which I (<ulink
  23. url="http://www.josuttis.com">Nicolai Josuttis</ulink>) present
  24. slightly modified in my book <emphasis>The C++ Standard Library -
  25. A Tutorial and Reference</emphasis>, called
  26. <code>carray</code>. This is the essence of these approaches
  27. spiced with many feedback from <ulink
  28. url="http://www.boost.org">boost</ulink>.</para>
  29. <para>After considering different names, we decided to name this
  30. class simply <code><classname>array</classname></code>.</para>
  31. <para>Note that this class is suggested to be part of the next
  32. Technical Report, which will extend the C++ Standard (see
  33. <ulink url="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm">http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm</ulink>).</para>
  34. <para>Class <code><classname>array</classname></code> fulfills most
  35. but not all of the requirements of "reversible containers" (see
  36. Section 23.1, [lib.container.requirements] of the C++
  37. Standard). The reasons array is not an reversible STL container is
  38. because:
  39. <itemizedlist spacing="compact">
  40. <listitem><simpara>No constructors are provided.</simpara></listitem>
  41. <listitem><simpara>Elements may have an undetermined initial value (see <xref linkend="array.rationale"/>).</simpara></listitem>
  42. <listitem><simpara><functionname>swap</functionname>() has no constant complexity.</simpara></listitem>
  43. <listitem><simpara><methodname>size</methodname>() is always constant, based on the second template argument of the type.</simpara></listitem>
  44. <listitem><simpara>The container provides no allocator support.</simpara></listitem>
  45. </itemizedlist>
  46. </para>
  47. <para>It doesn't fulfill the requirements of a "sequence" (see Section 23.1.1, [lib.sequence.reqmts] of the C++ Standard), except that:
  48. <itemizedlist spacing="compact">
  49. <listitem><simpara><methodname>front</methodname>() and <methodname>back</methodname>() are provided.</simpara></listitem>
  50. <listitem><simpara><methodname>operator[]</methodname> and <methodname>at</methodname>() are provided.</simpara></listitem>
  51. </itemizedlist>
  52. </para>
  53. </section>