algorithms.html 5.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="generator" content="Docutils 0.7: http://docutils.sourceforge.net/" />
  7. <title>The MPL Reference Manual: Algorithms</title>
  8. <link rel="stylesheet" href="../style.css" type="text/css" />
  9. </head>
  10. <body class="docframe refmanual">
  11. <table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./iterator-category.html" class="navigation-link">Prev</a>&nbsp;<a href="./algorithms-concepts.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iterators.html" class="navigation-link">Back</a>&nbsp;<a href="./metafunctions.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="../refmanual.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
  12. <td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./algorithms.html" class="navigation-link">Algorithms</a></td>
  13. </tr></table><div class="header-separator"></div>
  14. <div class="section" id="algorithms">
  15. <h1><a class="toc-backref" href="../refmanual.html#id1460">Algorithms</a></h1>
  16. <p id="label-algorithms">The MPL provides a broad range of fundamental algorithms aimed to
  17. satisfy the majority of sequential compile-time data processing
  18. needs. The algorithms include compile-time counterparts
  19. of many of the STL algorithms, iteration algorithms borrowed from
  20. functional programming languages, and more.</p>
  21. <p>Unlike the algorithms in the C++ Standard Library, which operate on
  22. implict <em>iterator ranges</em>, the majority of MPL counterparts take
  23. and return <em>sequences</em>. This derivation is not dictated by the
  24. functional nature of C++ compile-time computations per se, but
  25. rather by a desire to improve general usability of the library,
  26. making programming with compile-time data structures as enjoyable
  27. as possible.</p>
  28. <!-- This can be seen as a further generalization and extension of
  29. the STL's conceptual framework. -->
  30. <p>In the spirit of the STL, MPL algorithms are <em>generic</em>, meaning
  31. that they are not tied to particular sequence class
  32. implementations, and can operate on a wide range of arguments as
  33. long as they satisfy the documented requirements. The requirements
  34. are formulated in terms of concepts. Under the hood,
  35. algorithms are decoupled from concrete sequence
  36. implementations by operating on <a class="reference internal" href="./iterators.html">Iterators</a>.</p>
  37. <p>All MPL algorithms can be sorted into three
  38. major categories: iteration algorithms, querying algorithms, and
  39. transformation algorithms. The transformation algorithms introduce
  40. an associated <a class="reference internal" href="./inserter.html">Inserter</a> concept, a rough equivalent for the notion of
  41. <a class="reference external" href="https://boost.org/sgi/stl/OutputIterator.html" target="_top">Output Iterator</a> in the Standard Library. Moreover, every
  42. transformation algorithm provides a <tt class="literal"><span class="pre">reverse_</span></tt> counterpart,
  43. allowing for a wider range of efficient transformations — a
  44. common functionality documented by the <a class="reference internal" href="./reversible-algorithm.html">Reversible Algorithm</a>
  45. concept.</p>
  46. <ul class="toc simple" id="outline">
  47. <li><a class="reference internal" href="./algorithms-concepts.html" id="id1461">Concepts</a></li>
  48. <li><a class="reference internal" href="./inserters.html" id="id1464">Inserters</a></li>
  49. <li><a class="reference internal" href="./iteration-algorithms.html" id="id1468">Iteration Algorithms</a></li>
  50. <li><a class="reference internal" href="./querying-algorithms.html" id="id1474">Querying Algorithms</a></li>
  51. <li><a class="reference internal" href="./transformation-algorithms.html" id="id1485">Transformation Algorithms</a></li>
  52. <li><a class="reference internal" href="./runtime-algorithms.html" id="id1508">Runtime Algorithms</a></li>
  53. </ul>
  54. </div>
  55. <div class="footer-separator"></div>
  56. <table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./iterator-category.html" class="navigation-link">Prev</a>&nbsp;<a href="./algorithms-concepts.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./iterators.html" class="navigation-link">Back</a>&nbsp;<a href="./metafunctions.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="../refmanual.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
  57. <td><div class="copyright-footer"><div class="copyright">Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams</div>
  58. Distributed under the Boost Software License, Version 1.0. (See accompanying
  59. file LICENSE_1_0.txt or copy at <a class="reference external" href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</div></td></tr></table></body>
  60. </html>