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: shift_left</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="./bitxor.html" class="navigation-link">Prev</a> <a href="./shift-right.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./bitxor.html" class="navigation-link">Back</a> <a href="./shift-right.html" class="navigation-link">Along</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./bitwise-operations.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </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="./metafunctions.html" class="navigation-link">Metafunctions</a> / <a href="./bitwise-operations.html" class="navigation-link">Bitwise Operations</a> / <a href="./shift-left.html" class="navigation-link">shift_left</a></td> 13</tr></table><div class="header-separator"></div> 14<div class="section" id="shift-left"> 15<h1><a class="toc-backref" href="./bitwise-operations.html#id1557">shift_left</a></h1> 16<div class="section" id="id1116"> 17<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3> 18<pre class="literal-block"> 19template< 20 typename T 21 , typename Shift 22 > 23struct <a href="./shift-left.html" class="identifier">shift_left</a> 24{ 25 typedef <em>unspecified</em> type; 26}; 27</pre> 28</div> 29<div class="section" id="id1117"> 30<h3><a class="subsection-title" href="#description" name="description">Description</a></h3> 31<p>Returns the result of bitwise <em>shift left</em> (<tt class="literal"><span class="pre"><<</span></tt>) operation on <tt class="literal"><span class="pre">T</span></tt>.</p> 32</div> 33<div class="section" id="id1118"> 34<h3><a class="subsection-title" href="#header" name="header">Header</a></h3> 35<pre class="literal-block"> 36#include <<a href="../../../../boost/mpl/shift_left.hpp" class="header">boost/mpl/shift_left.hpp</a>> 37#include <<a href="../../../../boost/mpl/bitwise.hpp" class="header">boost/mpl/bitwise.hpp</a>> 38</pre> 39</div> 40<div class="section" id="id1119"> 41<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3> 42<p><a class="reference internal" href="./numeric-metafunction.html">Numeric Metafunction</a></p> 43</div> 44<div class="section" id="id1120"> 45<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3> 46<table border="1" class="docutils table"> 47<colgroup> 48<col width="21%" /> 49<col width="42%" /> 50<col width="37%" /> 51</colgroup> 52<thead valign="bottom"> 53<tr><th class="head">Parameter</th> 54<th class="head">Requirement</th> 55<th class="head">Description</th> 56</tr> 57</thead> 58<tbody valign="top"> 59<tr><td><tt class="literal"><span class="pre">T</span></tt></td> 60<td><a class="reference internal" href="./integral-constant.html">Integral Constant</a></td> 61<td>A value to shift.</td> 62</tr> 63<tr><td><tt class="literal"><span class="pre">Shift</span></tt></td> 64<td>Unsigned <a class="reference internal" href="./integral-constant.html">Integral Constant</a></td> 65<td>A shift distance.</td> 66</tr> 67</tbody> 68</table> 69<p>[<em>Note:</em> The requirements listed in this specification 70are the ones imposed by the default implementation. See <a class="reference internal" href="./numeric-metafunction.html">Numeric Metafunction</a> concept 71for the details on how to provide an implementation for a user-defined numeric type 72that does not satisfy the <a class="reference internal" href="./integral-constant.html">Integral Constant</a> requirements. — <em>end note</em>]</p> 73</div> 74<div class="section" id="id1121"> 75<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3> 76<p>For arbitrary <a class="reference internal" href="./integral-constant.html">Integral Constant</a> <tt class="literal"><span class="pre">c</span></tt> and unsigned <a class="reference internal" href="./integral-constant.html">Integral Constant</a> <tt class="literal"><span class="pre">shift</span></tt>:</p> 77<pre class="literal-block"> 78typedef <a href="./shift-left.html" class="identifier">shift_left</a><c,shift>::type r; 79</pre> 80<table class="docutils field-list" frame="void" rules="none"> 81<col class="field-name" /> 82<col class="field-body" /> 83<tbody valign="top"> 84<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first"><a class="reference internal" href="./integral-constant.html">Integral Constant</a>.</p> 85</td> 86</tr> 87<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p> 88<pre class="last literal-block"> 89typedef <a href="./integral-c.html" class="identifier">integral_c</a>< 90 c::<a href="./value-type.html" class="identifier">value_type</a> 91 , ( c::value << shift::value ) 92 > r; 93</pre> 94</td> 95</tr> 96</tbody> 97</table> 98<!-- .......................................................................... --> 99<pre class="literal-block"> 100typedef <a href="./shift-left.html" class="identifier">shift_left</a><c,shift> r; 101</pre> 102<table class="docutils field-list" frame="void" rules="none"> 103<col class="field-name" /> 104<col class="field-body" /> 105<tbody valign="top"> 106<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first"><a class="reference internal" href="./integral-constant.html">Integral Constant</a>.</p> 107</td> 108</tr> 109<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p> 110<pre class="last literal-block"> 111struct r : <a href="./shift-left.html" class="identifier">shift_left</a><c,shift>::type {}; 112</pre> 113</td> 114</tr> 115</tbody> 116</table> 117</div> 118<div class="section" id="id1122"> 119<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3> 120<p>Amortized constant time.</p> 121</div> 122<div class="section" id="id1123"> 123<h3><a class="subsection-title" href="#example" name="example">Example</a></h3> 124<pre class="literal-block"> 125typedef <a href="./integral-c.html" class="identifier">integral_c</a><unsigned,0> u0; 126typedef <a href="./integral-c.html" class="identifier">integral_c</a><unsigned,1> u1; 127typedef <a href="./integral-c.html" class="identifier">integral_c</a><unsigned,2> u2; 128typedef <a href="./integral-c.html" class="identifier">integral_c</a><unsigned,8> u8; 129 130<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./shift-left.html" class="identifier">shift_left</a><u0,u0>::value), ==, 0 ); 131<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./shift-left.html" class="identifier">shift_left</a><u1,u0>::value), ==, 1 ); 132<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./shift-left.html" class="identifier">shift_left</a><u1,u1>::value), ==, 2 ); 133<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./shift-left.html" class="identifier">shift_left</a><u2,u1>::value), ==, 4 ); 134<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./shift-left.html" class="identifier">shift_left</a><u8,u1>::value), ==, 16 ); 135</pre> 136</div> 137<div class="section" id="id1124"> 138<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3> 139<p><a class="reference internal" href="./bitwise-operations.html">Bitwise Operations</a>, <a class="reference internal" href="./numeric-metafunction.html">Numeric Metafunction</a>, <a class="reference internal" href="./numeric-cast.html">numeric_cast</a>, <a class="reference internal" href="./shift-right.html">shift_right</a>, <a class="reference internal" href="./bitand.html">bitand_</a></p> 140<!-- Metafunctions/Bitwise Operations//shift_right --> 141</div> 142</div> 143 144<div class="footer-separator"></div> 145<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./bitxor.html" class="navigation-link">Prev</a> <a href="./shift-right.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./bitxor.html" class="navigation-link">Back</a> <a href="./shift-right.html" class="navigation-link">Along</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./bitwise-operations.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td> 146<td><div class="copyright-footer"><div class="copyright">Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams</div> 147Distributed under the Boost Software License, Version 1.0. (See accompanying 148file 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> 149</html> 150