# range_c

### Synopsis

    template<
          typename T
        , T Start
        , T Finish
        >
    struct range_c
    {
        typedef integral_c<T,Start> start;
        typedef integral_c<T,Finish> finish;
    };

### Description

`range_c` is a sorted Random Access Sequence of Integral Constants. It is not an Extensible Sequence, meaning that transformation algorithms, such as `push_front` or `replace`, are not applicable to it, at least directly - you need to copy the content of the range into a more suitable sequence, when needed [1].

### Definition

    #include "boost/mpl/range_c.hpp"

### Example

    typedef range_c<int,0,0> range0;
    typedef range_c<int,0,1> range1;
    typedef range_c<int,0,10> range10;

    BOOST_STATIC_ASSERT(size<range0>::type::value == 0);
    BOOST_STATIC_ASSERT(size<range1>::type::value == 1);
    BOOST_STATIC_ASSERT(size<range10>::type::value == 10);

    BOOST_STATIC_ASSERT(empty<range0>::type::value);
    BOOST_STATIC_ASSERT(!empty<range1>::type::value);
    BOOST_STATIC_ASSERT(!empty<range10>::type::value);

    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);

    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);

### Notes

[1] In fact, the most common application of `range_c` class is to simplify the creation of sorted `list` or `vector`:

    typedef copy<
          range_c<int,0,50>
        , push_back<_,_>
        , vector<>
        >::type numbers;

### See also

Random Access Sequence, `vector`, `vector_c`, `list`, `list_c`

Table of Contents
Last edited July 17, 2002 8:31 am