1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5<title>Struct template literal</title> 6<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css"> 7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 8<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> 9<link rel="up" href="../../proto/reference.html#header.boost.proto.literal_hpp" title="Header <boost/proto/literal.hpp>"> 10<link rel="prev" href="wants_basic_expr.html" title="Struct template wants_basic_expr"> 11<link rel="next" href="lit.html" title="Function lit"> 12</head> 13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 14<table cellpadding="2" width="100%"><tr> 15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td> 16<td align="center"><a href="../../../../index.html">Home</a></td> 17<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td> 18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 20<td align="center"><a href="../../../../more/index.htm">More</a></td> 21</tr></table> 22<hr> 23<div class="spirit-nav"> 24<a accesskey="p" href="wants_basic_expr.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../proto/reference.html#header.boost.proto.literal_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="lit.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 25</div> 26<div class="refentry"> 27<a name="boost.proto.literal"></a><div class="titlepage"></div> 28<div class="refnamediv"> 29<h2><span class="refentrytitle">Struct template literal</span></h2> 30<p>boost::proto::literal — A simple wrapper for a terminal, provided for ease of use.</p> 31</div> 32<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> 33<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="../../proto/reference.html#header.boost.proto.literal_hpp" title="Header <boost/proto/literal.hpp>">boost/proto/literal.hpp</a>> 34 35</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">typename</span> <a class="link" href="../../Domain.html" title="Concept Domain">Domain</a> <span class="special">=</span> <a class="link" href="default_domain.html" title="Struct default_domain">proto::default_domain</a><span class="special">></span> 36<span class="keyword">struct</span> <a class="link" href="literal.html" title="Struct template literal">literal</a> <span class="special">:</span> <span class="keyword"></span> 37 <a class="link" href="extends.html" title="Struct template extends">proto::extends</a><span class="special"><</span><a class="link" href="basic_expr.html" title="Struct template basic_expr">proto::basic_expr</a><span class="special"><</span><a class="link" href="tag/terminal.html" title="Struct terminal">proto::tag::terminal</a><span class="special">,</span> <a class="link" href="term.html" title="Struct template term">proto::term</a><span class="special"><</span> <span class="identifier">T</span> <span class="special">></span> <span class="special">></span><span class="special">,</span> <span class="identifier">proto</span><span class="special">::</span><span class="identifier">literal</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">Domain</span><span class="special">></span><span class="special">,</span> <span class="identifier">Domain</span><span class="special">></span> 38<span class="special">{</span> 39 <span class="comment">// types</span> 40 <span class="keyword">typedef</span> <a class="link" href="basic_expr.html" title="Struct template basic_expr">proto::basic_expr</a><span class="special"><</span><a class="link" href="tag/terminal.html" title="Struct terminal">proto::tag::terminal</a><span class="special">,</span> <a class="link" href="term.html" title="Struct template term">proto::term</a><span class="special"><</span> <span class="identifier">T</span> <span class="special">></span> <span class="special">></span> <a name="boost.proto.literal.X"></a><span class="identifier">X</span><span class="special">;</span> <span class="comment">// For exposition only</span> 41 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="link" href="result_of/value.html" title="Struct template value">proto::result_of::value</a><span class="special"><</span><span class="identifier">X</span><span class="special">></span><span class="special">::</span><span class="identifier">type</span> <a name="boost.proto.literal.value_type"></a><span class="identifier">value_type</span><span class="special">;</span> 42 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="link" href="result_of/value.html" title="Struct template value">proto::result_of::value</a><span class="special"><</span><span class="identifier">X</span> <span class="special">&</span><span class="special">></span><span class="special">::</span><span class="identifier">type</span> <a name="boost.proto.literal.reference"></a><span class="identifier">reference</span><span class="special">;</span> 43 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="link" href="result_of/value.html" title="Struct template value">proto::result_of::value</a><span class="special"><</span><span class="identifier">X</span> <span class="keyword">const</span> <span class="special">&</span><span class="special">></span><span class="special">::</span><span class="identifier">type</span> <a name="boost.proto.literal.const_reference"></a><span class="identifier">const_reference</span><span class="special">;</span> 44 45 <span class="comment">// <a class="link" href="literal.html#boost.proto.literalconstruct-copy-destruct">construct/copy/destruct</a></span> 46 <a class="link" href="literal.html#id-1_3_33_5_30_2_1_1_10-bb"><span class="identifier">literal</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span> 47 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> U<span class="special">></span> <a class="link" href="literal.html#id-1_3_33_5_30_2_1_1_11-bb"><span class="identifier">literal</span></a><span class="special">(</span><span class="identifier">U</span> <span class="special">&</span><span class="special">)</span><span class="special">;</span> 48 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> U<span class="special">></span> <a class="link" href="literal.html#id-1_3_33_5_30_2_1_1_12-bb"><span class="identifier">literal</span></a><span class="special">(</span><span class="identifier">U</span> <span class="keyword">const</span> <span class="special">&</span><span class="special">)</span><span class="special">;</span> 49 <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> U<span class="special">></span> <a class="link" href="literal.html#id-1_3_33_5_30_2_1_1_13-bb"><span class="identifier">literal</span></a><span class="special">(</span><a class="link" href="literal.html" title="Struct template literal">proto::literal</a><span class="special"><</span> <span class="identifier">U</span><span class="special">,</span> <span class="identifier">Domain</span> <span class="special">></span> <span class="keyword">const</span> <span class="special">&</span><span class="special">)</span><span class="special">;</span> 50 51 <span class="comment">// <a class="link" href="literal.html#id-1_3_33_5_30_2_1_1_9-bb">public member functions</a></span> 52 <span class="identifier">reference</span> <a class="link" href="literal.html#id-1_3_33_5_30_2_1_1_9_1-bb"><span class="identifier">get</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span> 53 <span class="identifier">const_reference</span> <a class="link" href="literal.html#id-1_3_33_5_30_2_1_1_9_2-bb"><span class="identifier">get</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> 54<span class="special">}</span><span class="special">;</span></pre></div> 55<div class="refsect1"> 56<a name="id-1.3.33.5.32.4.4"></a><h2>Description</h2> 57<p> 58 A simple wrapper for a terminal, provided for ease of use. In all cases, 59 <code class="computeroutput">proto::literal<X> l(x);</code> is equivalent to 60 <code class="computeroutput"><a class="link" href="terminal.html" title="Struct template terminal">proto::terminal</a><X>::type l = {x};</code>. 61 </p> 62<p> 63 The <code class="computeroutput">Domain</code> template parameter defaults to 64 <code class="computeroutput"><a class="link" href="default_domain.html" title="Struct default_domain">proto::default_domain</a></code>. 65 </p> 66<div class="refsect2"> 67<a name="id-1.3.33.5.32.4.4.4"></a><h3> 68<a name="boost.proto.literalconstruct-copy-destruct"></a><code class="computeroutput">literal</code> 69 public 70 construct/copy/destruct</h3> 71<div class="orderedlist"><ol class="orderedlist" type="1"> 72<li class="listitem"><pre class="literallayout"><a name="id-1_3_33_5_30_2_1_1_10-bb"></a><span class="identifier">literal</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre></li> 73<li class="listitem"><pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> U<span class="special">></span> <a name="id-1_3_33_5_30_2_1_1_11-bb"></a><span class="identifier">literal</span><span class="special">(</span><span class="identifier">U</span> <span class="special">&</span> u<span class="special">)</span><span class="special">;</span></pre></li> 74<li class="listitem"><pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> U<span class="special">></span> <a name="id-1_3_33_5_30_2_1_1_12-bb"></a><span class="identifier">literal</span><span class="special">(</span><span class="identifier">U</span> <span class="keyword">const</span> <span class="special">&</span> u<span class="special">)</span><span class="special">;</span></pre></li> 75<li class="listitem"><pre class="literallayout"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> U<span class="special">></span> <a name="id-1_3_33_5_30_2_1_1_13-bb"></a><span class="identifier">literal</span><span class="special">(</span><a class="link" href="literal.html" title="Struct template literal">proto::literal</a><span class="special"><</span> <span class="identifier">U</span><span class="special">,</span> <span class="identifier">Domain</span> <span class="special">></span> <span class="keyword">const</span> <span class="special">&</span> u<span class="special">)</span><span class="special">;</span></pre></li> 76</ol></div> 77</div> 78<div class="refsect2"> 79<a name="id-1.3.33.5.32.4.4.5"></a><h3> 80<a name="id-1_3_33_5_30_2_1_1_9-bb"></a><code class="computeroutput">literal</code> public member functions</h3> 81<div class="orderedlist"><ol class="orderedlist" type="1"> 82<li class="listitem"> 83<pre class="literallayout"><span class="identifier">reference</span> <a name="id-1_3_33_5_30_2_1_1_9_1-bb"></a><span class="identifier">get</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre> 84<div class="variablelist"><table border="0" class="variablelist compact"> 85<colgroup> 86<col align="left" valign="top"> 87<col> 88</colgroup> 89<tbody><tr> 90<td><p><span class="term">Returns:</span></p></td> 91<td><code class="computeroutput"><a class="link" href="value.html" title="Function value">proto::value</a>(*this)</code></td> 92</tr></tbody> 93</table></div> 94</li> 95<li class="listitem"> 96<pre class="literallayout"><span class="identifier">const_reference</span> <a name="id-1_3_33_5_30_2_1_1_9_2-bb"></a><span class="identifier">get</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre> 97<div class="variablelist"><table border="0" class="variablelist compact"> 98<colgroup> 99<col align="left" valign="top"> 100<col> 101</colgroup> 102<tbody><tr> 103<td><p><span class="term">Returns:</span></p></td> 104<td><code class="computeroutput"><a class="link" href="value.html" title="Function value">proto::value</a>(*this)</code></td> 105</tr></tbody> 106</table></div> 107</li> 108</ol></div> 109</div> 110</div> 111</div> 112<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 113<td align="left"></td> 114<td align="right"><div class="copyright-footer">Copyright © 2008 Eric Niebler<p> 115 Distributed under the Boost Software License, Version 1.0. (See accompanying 116 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>) 117 </p> 118</div></td> 119</tr></table> 120<hr> 121<div class="spirit-nav"> 122<a accesskey="p" href="wants_basic_expr.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../proto/reference.html#header.boost.proto.literal_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="lit.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 123</div> 124</body> 125</html> 126