mirror of
https://github.com/boostorg/mpl.git
synced 2026-01-26 17:02:20 +01:00
71 lines
3.0 KiB
HTML
71 lines
3.0 KiB
HTML
<!doctype html public "-//ietf//dtd html//en">
|
|
<html><head><title>boost::mpl::Reference/range c</title>
|
|
<link rel="stylesheet" href="../mpl_wiki.css">
|
|
</head><body bgcolor="white">
|
|
<h1><a href="../Table_of_Content.html"><img src="../mpl_logo.jpg" alt="[Home]" border=0 align="right"></a>range_c</h1><h3>Synopsis</h3>
|
|
<p>
|
|
<pre>
|
|
template<
|
|
typename T
|
|
, T Start
|
|
, T Finish
|
|
>
|
|
struct range_c
|
|
{
|
|
typedef integral_c<T,Start> start;
|
|
typedef integral_c<T,Finish> finish;
|
|
};
|
|
</pre>
|
|
<p>
|
|
<h3>Description</h3>
|
|
<p>
|
|
<code>range_c</code> is a sorted <a href="../Random_Access_Sequence.html">Random Access Sequence</a> of <a href="../Integral_Constant.html">Integral Constant</a>s. It is <em>not</em> an <a href="../Extensible_Sequence.html">Extensible Sequence</a>, meaning that transformation algorithms, such as <code><a href="../Reference/push_front.html">push_front</a></code> or <code><a href="../Reference/replace.html">replace</a></code>, are not applicable to it, at least directly - you need to copy the content of the range into a more suitable sequence, when needed [<a href="#1">1</a>].
|
|
<p>
|
|
<h3>Definition</h3>
|
|
<p>
|
|
<pre>
|
|
#include "<a href="../../../../../\boost/mpl/range_c.hpp">boost/mpl/range_c.hpp</a>"
|
|
</pre>
|
|
<p>
|
|
<h3>Example</h3>
|
|
<p>
|
|
<pre>
|
|
typedef range_c<int,0,0> range0;
|
|
typedef range_c<int,0,1> range1;
|
|
typedef range_c<int,0,10> range10;
|
|
<p>
|
|
BOOST_STATIC_ASSERT(size<range0>::type::value == 0);
|
|
BOOST_STATIC_ASSERT(size<range1>::type::value == 1);
|
|
BOOST_STATIC_ASSERT(size<range10>::type::value == 10);
|
|
<p>
|
|
BOOST_STATIC_ASSERT(empty<range0>::type::value);
|
|
BOOST_STATIC_ASSERT(!empty<range1>::type::value);
|
|
BOOST_STATIC_ASSERT(!empty<range10>::type::value);
|
|
<p>
|
|
BOOST_MPL_ASSERT_IS_SAME(begin<range0>::type, end<range0>::type);
|
|
BOOST_MPL_ASSERT_NOT_SAME(begin<range1>::type, end<range1>::type);
|
|
BOOST_MPL_ASSERT_NOT_SAME(begin<range10>::type, end<range10>::type);
|
|
<p>
|
|
BOOST_STATIC_ASSERT(front<range1>::type::value == 0);
|
|
BOOST_STATIC_ASSERT(back<range1>::type::value == 0);
|
|
BOOST_STATIC_ASSERT(front<range10>::type::value == 0);
|
|
BOOST_STATIC_ASSERT(back<range10>::type::value == 9);
|
|
</pre>
|
|
<p>
|
|
<h3>Notes</h3>
|
|
<p>
|
|
[<a name="1">1</a>] In fact, the most common application of <code>range_c</code> class is to simplify the creation of sorted <code>list</code> or <code>vector</code>:
|
|
<p>
|
|
<pre>
|
|
typedef copy<
|
|
range_c<int,0,50>
|
|
, <a href="../Reference/push_back.html">push_back</a><_,_>
|
|
, vector<>
|
|
>::type numbers;
|
|
</pre><br>
|
|
<p>
|
|
<h3>See also</h3>
|
|
<p>
|
|
<a href="../Random_Access_Sequence.html">Random Access Sequence</a>, <code><a href="../Reference/vector.html">vector</a></code>, <code><a href="../Reference/vector_c.html">vector_c</a></code>, <code><a href="../Reference/list.html">list</a></code>, <code><a href="../Reference/list_c.html">list_c</a></code>
|
|
<p><hr>
|
|
<a href="../Table_of_Content.html">Table of Content</a> | <a href="../Reference.html">Reference</a><br>Last edited July 17, 2002 8:31 am</body></html> |