2002-09-16 19:25:33 +00:00
<!doctype html public "-//ietf//dtd html//en">
2003-03-12 13:29:12 +00:00
< html >< head >< title > boost::mpl::range_c</ title >
2002-09-16 19:25:33 +00:00
< link rel = "stylesheet" href = "../mpl_wiki.css" >
</ head >< body bgcolor = "white" >
2003-03-12 13:29:12 +00:00
< h1 >< a href = "../Table_of_Contents.html" >< img src = "../mpl_logo.jpg" alt = "[Home]" border = 0 align = "right" ></ a > range_c</ h1 >< h3 > Synopsis</ h3 >
2002-09-16 19:25:33 +00:00
< 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 >
2003-03-12 13:29:12 +00:00
#include "< a href = "../../../../../boost/mpl/range_c.hpp" > boost/mpl/range_c.hpp</ a > "
2002-09-16 19:25:33 +00:00
</ 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 >
2003-03-12 13:29:12 +00:00
< a href = "../Table_of_Contents.html" > Table of Contents</ a >< br > Last edited July 17, 2002 8:31 am</ body ></ html >