summaryrefslogtreecommitdiff
path: root/doc/html/boost/proto/domain.html
blob: 65df27488619b7916c785575693075b3265fa7be (plain)
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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Struct template domain</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="../../proto/reference.html#header.boost.proto.domain_hpp" title="Header &lt;boost/proto/domain.hpp&gt;">
<link rel="prev" href="deep_copy_idp201107088.html" title="Function template deep_copy">
<link rel="next" href="domain/as_expr.html" title="Struct template as_expr">
</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="deep_copy_idp201107088.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../proto/reference.html#header.boost.proto.domain_hpp"><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="domain/as_expr.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.proto.domain"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Struct template domain</span></h2>
<p>boost::proto::domain &#8212; For use in defining domain tags to be used with <code class="computeroutput">
          <a class="link" href="extends.html" title="Struct template extends">proto::extends&lt;&gt;</a></code>,
          <code class="computeroutput"><a class="link" href="../../BOOST_PROTO_EXTENDS.html" title="Macro BOOST_PROTO_EXTENDS">BOOST_PROTO_EXTENDS</a>()</code> and
          <code class="computeroutput"><a class="link" href="../../BOOST_PROTO_DEFINE_OPERATORS.html" title="Macro BOOST_PROTO_DEFINE_OPERATORS">BOOST_PROTO_DEFINE_OPERATORS</a>()</code>.
          A <span class="emphasis"><em>domain</em></span> associates an expression type with a <span class="emphasis"><em>generator</em></span>,
          and optionally a <span class="emphasis"><em>grammar</em></span>. It may also have a super-domain. Expressions
          in a sub-domain are interoperable (i.e. can be combined freely with) expressions in a
          super-domain. Finally, domains control how non-Proto objects are turned into Proto
          expressions and how they are combined to form larger Proto expressions.
        </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../proto/reference.html#header.boost.proto.domain_hpp" title="Header &lt;boost/proto/domain.hpp&gt;">boost/proto/domain.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Generator <span class="special">=</span> <a class="link" href="default_generator.html" title="Struct default_generator">proto::default_generator</a><span class="special">,</span> 
         <span class="keyword">typename</span> Grammar <span class="special">=</span> <a class="link" href="_.html" title="Struct _">proto::_</a><span class="special">,</span> <span class="keyword">typename</span> Super <span class="special">=</span> <em class="replaceable"><code><span class="identifier">unspecified</span></code></em><span class="special">&gt;</span> 
<span class="keyword">struct</span> <a class="link" href="domain.html" title="Struct template domain">domain</a> <span class="special">:</span> <span class="keyword"></span> Generator <span class="special">{</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <span class="identifier">Grammar</span>   <a name="boost.proto.domain.proto_grammar"></a><span class="identifier">proto_grammar</span><span class="special">;</span>     
  <span class="keyword">typedef</span> <span class="identifier">Generator</span> <a name="boost.proto.domain.proto_generator"></a><span class="identifier">proto_generator</span><span class="special">;</span>   
  <span class="keyword">typedef</span> <span class="identifier">Super</span>     <a name="boost.proto.domain.proto_super_domain"></a><span class="identifier">proto_super_domain</span><span class="special">;</span>

  <span class="comment">// member classes/structs/unions</span>

  <span class="comment">// A callable unary MonomorphicFunctionObject that specifies how objects are
  // turned into Proto expressions in this domain. The resulting expression
  // object is suitable for storage in a local variable.</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> 
  <span class="keyword">struct</span> <a class="link" href="domain/as_expr.html" title="Struct template as_expr">as_expr</a> <span class="special">:</span> <span class="keyword"></span> <a class="link" href="callable.html" title="Struct callable">proto::callable</a> <span class="special">{</span>
    <span class="comment">// types</span>
    <span class="keyword">typedef</span> <em class="replaceable"><code><span class="identifier">see</span><span class="special">-</span><span class="identifier">below</span></code></em> <a class="link" href="domain/as_expr.html#boost.proto.domain.as_expr.result_type"><span class="identifier">result_type</span></a><span class="special">;</span>

    <span class="comment">// <a class="link" href="domain/as_expr.html#idp201162192-bb">public member functions</a></span>
    <span class="identifier">result_type</span> <a class="link" href="domain/as_expr.html#idp201162752-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="identifier">T</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="special">}</span><span class="special">;</span>

  <span class="comment">// A callable unary MonomorphicFunctionObject that specifies how objects are
  // turned into Proto expressions in this domain, for use in scenarios where
  // the resulting expression is intended to be made a child of another
  // expression.</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> 
  <span class="keyword">struct</span> <a class="link" href="domain/as_child.html" title="Struct template as_child">as_child</a> <span class="special">:</span> <span class="keyword"></span> <a class="link" href="callable.html" title="Struct callable">proto::callable</a> <span class="special">{</span>
    <span class="comment">// types</span>
    <span class="keyword">typedef</span> <em class="replaceable"><code><span class="identifier">see</span><span class="special">-</span><span class="identifier">below</span></code></em> <a class="link" href="domain/as_child.html#boost.proto.domain.as_child.result_type"><span class="identifier">result_type</span></a><span class="special">;</span>

    <span class="comment">// <a class="link" href="domain/as_child.html#idp201180880-bb">public member functions</a></span>
    <span class="identifier">result_type</span> <a class="link" href="domain/as_child.html#idp201181440-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="identifier">T</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="special">}</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idp362539344"></a><h2>Description</h2>
<p>
            The Generator parameter determines how new expressions in the domain are post-processed. Typically, a generator
            wraps all new expressions in a wrapper that imparts domain-specific behaviors to expressions within
            its domain. (See <code class="computeroutput"><a class="link" href="extends.html" title="Struct template extends">proto::extends&lt;&gt;</a></code>.)
          </p>
<p>
            The Grammar parameter determines whether a given expression is valid within the domain, and automatically
            disables any operator overloads which would cause an invalid expression to be created. By default,
            the Grammar parameter defaults to the wildcard, <code class="computeroutput"><a class="link" href="_.html" title="Struct _">proto::_</a>
            </code>, which makes all expressions valid within the domain.
          </p>
<p>
            The Super parameter declares the domain currently being defined to be a sub-domain of Super. An expression in
            a sub-domain can be freely combined with expressions in its super-domain (and <span class="emphasis"><em>its</em></span>
            super-domain, etc.).
          </p>
<p>
            Example: </p>
<pre class="programlisting"> <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Expr</span><span class="special">&gt;</span>
 <span class="keyword">struct</span> <span class="identifier">MyExpr</span><span class="special">;</span>

 <span class="keyword">struct</span> <span class="identifier">MyGrammar</span>
   <span class="special">:</span> <a class="link" href="or_.html" title="Struct template or_">proto::or_</a><span class="special">&lt;</span> <a class="link" href="terminal.html" title="Struct template terminal">proto::terminal</a><span class="special">&lt;</span><span class="identifier">_</span><span class="special">&gt;</span><span class="special">,</span> <a class="link" href="plus.html" title="Struct template plus">proto::plus</a><span class="special">&lt;</span><span class="identifier">MyGrammar</span><span class="special">,</span> <span class="identifier">MyGrammar</span><span class="special">&gt;</span> <span class="special">&gt;</span>
 <span class="special">{</span><span class="special">}</span><span class="special">;</span>

 <span class="comment">// Define MyDomain, in which all expressions are</span>
 <span class="comment">// wrapped in MyExpr&lt;&gt; and only expressions that</span>
 <span class="comment">// conform to MyGrammar are allowed.</span>
 <span class="keyword">struct</span> <span class="identifier">MyDomain</span>
   <span class="special">:</span> <a class="link" href="domain.html" title="Struct template domain">proto::domain</a><span class="special">&lt;</span><a class="link" href="generator.html" title="Struct template generator">proto::generator</a><span class="special">&lt;</span><span class="identifier">MyExpr</span><span class="special">&gt;</span><span class="special">,</span> <span class="identifier">MyGrammar</span><span class="special">&gt;</span>
 <span class="special">{</span><span class="special">}</span><span class="special">;</span>

 <span class="comment">// Use MyDomain to define MyExpr</span>
 <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">Expr</span><span class="special">&gt;</span>
 <span class="keyword">struct</span> <span class="identifier">MyExpr</span>
   <span class="special">:</span> <a class="link" href="extends.html" title="Struct template extends">proto::extends</a><span class="special">&lt;</span><span class="identifier">Expr</span><span class="special">,</span> <span class="identifier">MyExpr</span><span class="special">&lt;</span><span class="identifier">Expr</span><span class="special">&gt;</span><span class="special">,</span> <span class="identifier">MyDomain</span><span class="special">&gt;</span>
 <span class="special">{</span>
     <span class="comment">// ...</span>
 <span class="special">}</span><span class="special">;</span>
            </pre>
<p>
          </p>
<p>
            The <code class="computeroutput"><a class="link" href="domain/as_expr.html" title="Struct template as_expr">domain::as_expr</a>&lt;&gt;</code> and
            <code class="computeroutput"><a class="link" href="domain/as_child.html" title="Struct template as_child">domain::as_child</a>&lt;&gt;</code> member
            templates define how non-Proto objects are turned into Proto terminals and how Proto
            expressions should be processed before they are combined to form larger expressions. 
            They can be overridden in a derived domain for customization. See their descriptions to
            understand how Proto uses these two templates and what their default behavior is.
          </p>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2008 Eric Niebler<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></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="deep_copy_idp201107088.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../proto/reference.html#header.boost.proto.domain_hpp"><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="domain/as_expr.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>