1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Chapter 23. Boost.Proto</title>
<link rel="stylesheet" href="../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="libraries.html" title="Part I. The Boost C++ Libraries (BoostBook Subset)">
<link rel="prev" href="boost/property_tree/xml_parser/write_xml_idp97810232.html" title="Function template write_xml">
<link rel="next" href="proto/users_guide.html" title="Users' Guide">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../boost.png"></td>
<td align="center"><a href="../../index.html">Home</a></td>
<td align="center"><a href="../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost/property_tree/xml_parser/write_xml_idp97810232.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="proto/users_guide.html"><img src="../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="chapter">
<div class="titlepage"><div>
<div><h2 class="title">
<a name="proto"></a>Chapter 23. Boost.Proto</h2></div>
<div><div class="author"><h3 class="author">
<span class="firstname">Eric</span> <span class="surname">Niebler</span>
</h3></div></div>
<div><p class="copyright">Copyright © 2008 Eric Niebler</p></div>
<div><div class="legalnotice">
<a name="proto.legal"></a><p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></div>
</div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl class="toc">
<dt><span class="section"><a href="proto.html#boost_proto.preface">Preface</a></span></dt>
<dt><span class="section"><a href="proto/users_guide.html">Users' Guide</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="proto/users_guide.html#boost_proto.users_guide.getting_started">Getting Started</a></span></dt>
<dt><span class="section"><a href="proto/users_guide.html#boost_proto.users_guide.front_end">Fronts Ends: Defining
Terminals and Non-Terminals of Your EDSL</a></span></dt>
<dt><span class="section"><a href="proto/users_guide.html#boost_proto.users_guide.intermediate_form">Intermediate
Form: Understanding and Introspecting Expressions</a></span></dt>
<dt><span class="section"><a href="proto/users_guide.html#boost_proto.users_guide.back_end">Back Ends: Making Expression
Templates Do Useful Work</a></span></dt>
<dt><span class="section"><a href="proto/users_guide.html#boost_proto.users_guide.examples">Examples</a></span></dt>
<dt><span class="section"><a href="proto/users_guide.html#boost_proto.users_guide.resources">Background and Resources</a></span></dt>
<dt><span class="section"><a href="proto/users_guide.html#boost_proto.users_guide.glossary">Glossary</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="proto/reference.html">Reference</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="proto/reference.html#proto.concepts">Concepts</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#proto.reference.classes">Classes</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#proto.reference.functions">Functions</a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.args_hpp">Header <boost/proto/args.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.core_hpp">Header <boost/proto/core.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.debug_hpp">Header <boost/proto/debug.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.deep_copy_hpp">Header <boost/proto/deep_copy.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.domain_hpp">Header <boost/proto/domain.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.eval_hpp">Header <boost/proto/eval.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.expr_hpp">Header <boost/proto/expr.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.extends_hpp">Header <boost/proto/extends.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional_hpp">Header <boost/proto/functional.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.fusion_hpp">Header <boost/proto/functional/fusion.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.fusion.at_hpp">Header <boost/proto/functional/fusion/at.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.fusion.pop_back_hpp">Header <boost/proto/functional/fusion/pop_back.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.fusion.pop_front_hpp">Header <boost/proto/functional/fusion/pop_front.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.fusion.push_back_hpp">Header <boost/proto/functional/fusion/push_back.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.fusion.push_front_hpp">Header <boost/proto/functional/fusion/push_front.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.fusion.reverse_hpp">Header <boost/proto/functional/fusion/reverse.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.range.begin_hpp">Header <boost/proto/functional/range/begin.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.range.empty_hpp">Header <boost/proto/functional/range/empty.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.range.end_hpp">Header <boost/proto/functional/range/end.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.range.rbegin_hpp">Header <boost/proto/functional/range/rbegin.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.range.rend_hpp">Header <boost/proto/functional/range/rend.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.range.size_hpp">Header <boost/proto/functional/range/size.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.std_hpp">Header <boost/proto/functional/std.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.std.iterator_hpp">Header <boost/proto/functional/std/iterator.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.functional.std.utility_hpp">Header <boost/proto/functional/std/utility.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.fusion_hpp">Header <boost/proto/fusion.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.generate_hpp">Header <boost/proto/generate.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.literal_hpp">Header <boost/proto/literal.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.make_expr_hpp">Header <boost/proto/make_expr.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.matches_hpp">Header <boost/proto/matches.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.operators_hpp">Header <boost/proto/operators.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.proto_hpp">Header <boost/proto/proto.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.proto_fwd_hpp">Header <boost/proto/proto_fwd.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.proto_typeof_hpp">Header <boost/proto/proto_typeof.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.repeat_hpp">Header <boost/proto/repeat.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.tags_hpp">Header <boost/proto/tags.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.traits_hpp">Header <boost/proto/traits.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform_hpp">Header <boost/proto/transform.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.arg_hpp">Header <boost/proto/transform/arg.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.call_hpp">Header <boost/proto/transform/call.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.default_hpp">Header <boost/proto/transform/default.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.env_hpp">Header <boost/proto/transform/env.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.fold_hpp">Header <boost/proto/transform/fold.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.fold_tree_hpp">Header <boost/proto/transform/fold_tree.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.impl_hpp">Header <boost/proto/transform/impl.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.integral_c_hpp">Header <boost/proto/transform/integral_c.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.lazy_hpp">Header <boost/proto/transform/lazy.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.make_hpp">Header <boost/proto/transform/make.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.pass_through_hpp">Header <boost/proto/transform/pass_through.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.transform.when_hpp">Header <boost/proto/transform/when.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.context_hpp">Header <boost/proto/context.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.context.callable_hpp">Header <boost/proto/context/callable.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.context.default_hpp">Header <boost/proto/context/default.hpp></a></span></dt>
<dt><span class="section"><a href="proto/reference.html#header.boost.proto.context.null_hpp">Header <boost/proto/context/null.hpp></a></span></dt>
</dl></dd>
<dt><span class="section"><a href="proto/appendices.html">Appendices</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="proto/appendices.html#boost_proto.appendices.release_notes">Appendix A: Release
Notes</a></span></dt>
<dt><span class="section"><a href="proto/appendices.html#boost_proto.appendices.history">Appendix B: History</a></span></dt>
<dt><span class="section"><a href="proto/appendices.html#boost_proto.appendices.rationale">Appendix C: Rationale</a></span></dt>
<dt><span class="section"><a href="proto/appendices.html#boost_proto.appendices.implementation">Appendix D: Implementation
Notes</a></span></dt>
<dt><span class="section"><a href="proto/appendices.html#boost_proto.appendices.acknowledgements">Appendix E:
Acknowledgements</a></span></dt>
</dl></dd>
</dl>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_proto.preface"></a><a class="link" href="proto.html#boost_proto.preface" title="Preface">Preface</a>
</h2></div></div></div>
<div class="blockquote"><blockquote class="blockquote"><p>
<span class="quote">“<span class="quote">There are more things in heaven and earth, Horatio, than are dreamt
of in your philosophy.</span>”</span>
</p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
<span class="bold"><strong><span class="emphasis"><em>-- William Shakespeare</em></span></strong></span>
</p></blockquote></div>
<h4>
<a name="boost_proto.preface.h0"></a>
<span class="phrase"><a name="boost_proto.preface.description"></a></span><a class="link" href="proto.html#boost_proto.preface.description">Description</a>
</h4>
<p>
Proto is a framework for building Embedded Domain-Specific Languages in C++.
It provides tools for constructing, type-checking, transforming and executing
<span class="emphasis"><em>expression templates</em></span><a href="#ftn.boost_proto.preface.f0" class="footnote" name="boost_proto.preface.f0"><sup class="footnote">[6]</sup></a>. More specifically, Proto provides:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
An expression tree data structure.
</li>
<li class="listitem">
A mechanism for giving expressions additional behaviors and members.
</li>
<li class="listitem">
Operator overloads for building the tree from an expression.
</li>
<li class="listitem">
Utilities for defining the grammar to which an expression must conform.
</li>
<li class="listitem">
An extensible mechanism for immediately executing an expression template.
</li>
<li class="listitem">
An extensible set of tree transformations to apply to expression trees.
</li>
</ul></div>
<h4>
<a name="boost_proto.preface.h1"></a>
<span class="phrase"><a name="boost_proto.preface.motivation"></a></span><a class="link" href="proto.html#boost_proto.preface.motivation">Motivation</a>
</h4>
<p>
Expression Templates are an advanced technique that C++ library developers
use to define embedded mini-languages that target specific problem domains.
The technique has been used to create efficient and easy-to-use libraries for
linear algebra as well as to define C++ parser generators with a readable syntax.
But developing such a library involves writing an inordinate amount of unreadable
and unmaintainable template mumbo-jumbo. Boost.Proto eases the development
of <a class="link" href="proto/users_guide.html#boost_proto.users_guide.glossary.edsl">domain-specific embedded
languages (EDSLs)</a>. Use Proto to define the primitives of your mini-language
and let Proto handle the operator overloading and the construction of the expression
parse tree. Immediately evaluate the expression tree by passing it a function
object. Or transform the expression tree by defining the grammar of your mini-language,
decorated with an assortment of tree transforms provided by Proto or defined
by you. Then use the grammar to give your users short and readable syntax errors
for invalid expressions! No more mumbo-jumbo -- an expression template library
developed with Proto is declarative and readable.
</p>
<p>
In short, Proto is an EDSL for defining EDSLs.
</p>
<h4>
<a name="boost_proto.preface.h2"></a>
<span class="phrase"><a name="boost_proto.preface.how_to_use_this_documentation"></a></span><a class="link" href="proto.html#boost_proto.preface.how_to_use_this_documentation">How
to Use This Documentation</a>
</h4>
<p>
This documentation makes use of the following naming and formatting conventions.
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
Code is in <code class="computeroutput"><span class="identifier">fixed</span> <span class="identifier">width</span>
<span class="identifier">font</span></code> and is syntax-highlighted.
</li>
<li class="listitem">
Replaceable text that you will need to supply is in <em class="replaceable"><code>italics</code></em>.
</li>
<li class="listitem">
If a name refers to a free function, it is specified like this: <code class="computeroutput"><span class="identifier">free_function</span><span class="special">()</span></code>;
that is, it is in code font and its name is followed by <code class="computeroutput"><span class="special">()</span></code>
to indicate that it is a free function.
</li>
<li class="listitem">
If a name refers to a class template, it is specified like this: <code class="computeroutput"><span class="identifier">class_template</span><span class="special"><></span></code>;
that is, it is in code font and its name is followed by <code class="computeroutput"><span class="special"><></span></code>
to indicate that it is a class template.
</li>
<li class="listitem">
If a name refers to a function-like macro, it is specified like this:
<code class="computeroutput"><span class="identifier">MACRO</span><span class="special">()</span></code>;
that is, it is uppercase in code font and its name is followed by <code class="computeroutput"><span class="special">()</span></code> to indicate that it is a function-like
macro. Object-like macros appear without the trailing <code class="computeroutput"><span class="special">()</span></code>.
</li>
<li class="listitem">
Names that refer to <span class="emphasis"><em>concepts</em></span> in the generic programming
sense are specified in CamelCase.
</li>
</ul></div>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
In addition, notes such as this one specify non-essential information that
provides additional background or rationale.
</p></td></tr>
</table></div>
<p>
Finally, you can mentally add the following to any code fragments in this document:
</p>
<pre class="programlisting"><span class="comment">// Include all of Proto</span>
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">proto</span><span class="special">/</span><span class="identifier">proto</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
<span class="comment">// Create some namespace aliases</span>
<span class="keyword">namespace</span> <span class="identifier">mpl</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">mpl</span><span class="special">;</span>
<span class="keyword">namespace</span> <span class="identifier">fusion</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">fusion</span><span class="special">;</span>
<span class="keyword">namespace</span> <span class="identifier">proto</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">proto</span><span class="special">;</span>
<span class="comment">// Allow unqualified use of Proto's wildcard pattern</span>
<span class="keyword">using</span> <span class="identifier">proto</span><span class="special">::</span><span class="identifier">_</span><span class="special">;</span>
</pre>
</div>
<div class="footnotes">
<br><hr style="width:100; text-align:left;margin-left: 0">
<div id="ftn.boost_proto.preface.f0" class="footnote"><p><a href="#boost_proto.preface.f0" class="para"><sup class="para">[6] </sup></a>
See <a href="http://en.wikipedia.org/wiki/Expression_templates" target="_top">Expression
Templates</a>
</p></div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: October 28, 2013 at 23:53:56 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost/property_tree/xml_parser/write_xml_idp97810232.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="proto/users_guide.html"><img src="../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
|