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: at_c</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="./at.html" class="navigation-link">Prev</a> <a href="./back.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./at.html" class="navigation-link">Back</a> <a href="./back.html" class="navigation-link">Along</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./intrinsic-metafunctions.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="./sequences.html" class="navigation-link">Sequences</a> / <a href="./intrinsic-metafunctions.html" class="navigation-link">Intrinsic Metafunctions</a> / <a href="./at-c.html" class="navigation-link">at_c</a></td> 13</tr></table><div class="header-separator"></div> 14<div class="section" id="at-c"> 15<h1><a class="toc-backref" href="./intrinsic-metafunctions.html#id1426">at_c</a></h1> 16<div class="section" id="id185"> 17<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3> 18<pre class="literal-block"> 19template< 20 typename Sequence 21 , long n 22 > 23struct <a href="./at-c.html" class="identifier">at_c</a> 24{ 25 typedef <em>unspecified</em> type; 26}; 27</pre> 28</div> 29<div class="section" id="id186"> 30<h3><a class="subsection-title" href="#description" name="description">Description</a></h3> 31<p>Returns a type identical to the <tt class="literal"><span class="pre">n</span></tt>th element from the beginning of 32the sequence. <tt class="literal"><span class="pre"><a href="./at-c.html" class="identifier">at_c</a><Sequence,n>::type</span></tt> is a shorcut notation for 33<tt class="literal"><span class="pre"><a href="./at.html" class="identifier">at</a><</span> <span class="pre">Sequence,</span> <span class="pre"><a href="./long.html" class="identifier">long_</a><n></span> <span class="pre">>::type</span></tt>.</p> 34</div> 35<div class="section" id="id187"> 36<h3><a class="subsection-title" href="#header" name="header">Header</a></h3> 37<pre class="literal-block"> 38#include <<a href="../../../../boost/mpl/at.hpp" class="header">boost/mpl/at.hpp</a>> 39</pre> 40</div> 41<div class="section" id="id188"> 42<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3> 43<table border="1" class="docutils table"> 44<colgroup> 45<col width="15%" /> 46<col width="36%" /> 47<col width="48%" /> 48</colgroup> 49<thead valign="bottom"> 50<tr><th class="head">Parameter</th> 51<th class="head">Requirement</th> 52<th class="head">Description</th> 53</tr> 54</thead> 55<tbody valign="top"> 56<tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td> 57<td><a class="reference internal" href="./forward-sequence.html">Forward Sequence</a></td> 58<td>A sequence to be examined.</td> 59</tr> 60<tr><td><tt class="literal"><span class="pre">n</span></tt></td> 61<td>A compile-time integral constant</td> 62<td>An offset from the beginning of the sequence 63specifying the element to be retrieved.</td> 64</tr> 65</tbody> 66</table> 67</div> 68<div class="section" id="id189"> 69<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3> 70<pre class="literal-block"> 71typedef <a href="./at-c.html" class="identifier">at_c</a><Sequence,n>::type t; 72</pre> 73<table class="docutils field-list" frame="void" rules="none"> 74<col class="field-name" /> 75<col class="field-body" /> 76<tbody valign="top"> 77<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">A type</p> 78</td> 79</tr> 80<tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><p class="first"><tt class="literal"><span class="pre">0</span> <span class="pre"><=</span> <span class="pre">n</span> <span class="pre"><</span> <span class="pre"><a href="./size.html" class="identifier">size</a><Sequence>::value</span></tt></p> 81</td> 82</tr> 83<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p> 84<pre class="last literal-block"> 85typedef <a href="./at.html" class="identifier">at</a>< Sequence, <a href="./long.html" class="identifier">long_</a><n> >::type t; 86</pre> 87</td> 88</tr> 89</tbody> 90</table> 91</div> 92<div class="section" id="id190"> 93<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3> 94<table border="1" class="docutils table"> 95<colgroup> 96<col width="47%" /> 97<col width="53%" /> 98</colgroup> 99<thead valign="bottom"> 100<tr><th class="head">Sequence archetype</th> 101<th class="head">Complexity</th> 102</tr> 103</thead> 104<tbody valign="top"> 105<tr><td><a class="reference internal" href="./forward-sequence.html">Forward Sequence</a></td> 106<td>Linear.</td> 107</tr> 108<tr><td><a class="reference internal" href="./random-access-sequence.html">Random Access Sequence</a></td> 109<td>Amortized constant time.</td> 110</tr> 111</tbody> 112</table> 113</div> 114<div class="section" id="id191"> 115<h3><a class="subsection-title" href="#example" name="example">Example</a></h3> 116<pre class="literal-block"> 117typedef <a href="./range-c.html" class="identifier">range_c</a><long,10,50> range; 118<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./at-c.html" class="identifier">at_c</a>< range,0 >::type::value), ==, 10 ); 119<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./at-c.html" class="identifier">at_c</a>< range,10 >::type::value), ==, 20 ); 120<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( (<a href="./at-c.html" class="identifier">at_c</a>< range,40 >::type::value), ==, 50 ); 121</pre> 122</div> 123<div class="section" id="id192"> 124<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3> 125<p><a class="reference internal" href="./forward-sequence.html">Forward Sequence</a>, <a class="reference internal" href="./random-access-sequence.html">Random Access Sequence</a>, <a class="reference internal" href="./at.html">at</a>, <a class="reference internal" href="./front.html">front</a>, <a class="reference internal" href="./back.html">back</a></p> 126<!-- Sequences/Intrinsic Metafunctions//back --> 127</div> 128</div> 129 130<div class="footer-separator"></div> 131<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./at.html" class="navigation-link">Prev</a> <a href="./back.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./at.html" class="navigation-link">Back</a> <a href="./back.html" class="navigation-link">Along</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./intrinsic-metafunctions.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> 132<td><div class="copyright-footer"><div class="copyright">Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams</div> 133Distributed under the Boost Software License, Version 1.0. (See accompanying 134file 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> 135</html> 136