    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: C++ as a Safer C</title>
        <link>https://members.accu.org/index.php/journals/313</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>


        <h2>Journal Articles</h2>


<div class="xar-mod-head"><span class="xar-mod-title">Overload Journal #59 - Feb 2004 + Programming Topics</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c78/">Overload</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c153/">59</a>
                    (7)
<br />

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c13/">Topics</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c65/">Programming</a>
                    (877)
<br />

                                            <a href="https://members.accu.org/index.php/journals/c153-65/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/journals/c153+65/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;C++ as a Safer C</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 02 February 2004 21:55:34 +00:00 or Mon, 02 February 2004 21:55:34 +00:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e18" id="d0e18"></a></h2>
</div>
<p>There are many features in C++ that can be used to enhance the
quality of code written with classic C design even if no object
oriented techniques are used. This article describes a technique to
protect against value overflow and out-of-bounds access of
arrays.</p>
<p>This article started with a discussion about how C projects
could use features in C++ to improve the quality of the code
without having to do any major redesign.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e24" id="d0e24"></a>Bounded
Integral Types</h2>
</div>
<p>The built-in integral types in C and C++ are very crude. They
map directly to what can be represented in hardware as bytes and
words with or without signs. There is no way to say that a number
can only have values in the range 1 to 100. The best you can do is
to use an unsigned char which typically has a value range from 0 to
255, but this does not provide any checking for overflow.</p>
<p>It is easy to create an integral type that does the range
checking as Pascal and Ada do. The implementation of BoundedInt in
listing 1 shows how this can be done with C++ templates. It takes
three parameters. The first two specify the inclusive range of
allowed values. The third parameter specifies the underlying type
to be used and uses a default type given by the <tt class=
"computeroutput">BoundedIntTraits</tt> class.</p>
<pre class="programlisting">
#include &lt;cassert&gt;

template &lt;int Lower, int Upper,
          typename INT=typename
          BoundedIntTraits&lt;Lower,Upper&gt;::Type&gt;

class BoundedInt {
public:
  // Default constructor
  BoundedInt()
#ifndef NDEBUG
    : m_initialised(false)
#endif
  {}
  // Conversion constructor
  BoundedInt(int i)
    : m_i(static_cast&lt;INT&gt;(i))
#ifndef NDEBUG
    , m_initialised(true)
#endif
  {
    // Check input value
    assert((Lower&lt;=i) &amp;&amp; (i&lt;=Upper));
  }
  // Conversion back to a builtin type
  operator INT() {
  assert(m_initialised);
  return m_i;
}

// Assignment operators
  BoundedInt &amp; operator+=(int rhs) {
    assert(m_initialised);
    // Check for overflow
    assert(m_i/2 + rhs/2 + (m_i&amp;rhs&amp;1)
      &lt;= Upper/2);
    assert(Lower/2
      &lt;= m_i/2 + rhs/2 - ((m_i^rhs)&amp;1));
    // Check result value
    assert((Lower&lt;=m_i+rhs) &amp;&amp; (m_i+rhs&lt;=Upper));
    // Perform operation
    m_i += rhs;
    return *this; 
  }

// Increment and decrement operators.
  BoundedInt &amp; operator++() {
    assert(m_initialised);
    // Check for overflow
    assert(m_i &lt; Upper);
    // Perform operation
    ++m_i;
    return *this;
  }

// Other operators ...
private:
  INT m_i;
  #ifndef NDEBUG
  bool m_initialised;
  #endif
};

<span class=
"bold"><b>Listing 1:</b></span> Definition of BoundedInt. Only the plus operator is shown here. The other arithmetic operators follow the same design.
</pre>
<p>The <tt class="computeroutput">BoundedIntTraits</tt> class is
used to find the smallest built-in type that can hold numbers of
the specified range. It uses some meta-programming to figure out
which type to use. The implementation of the <tt class=
"computeroutput">BoundedIntTraits</tt> class is shown in listing
2.</p>
<pre class="programlisting">
#include &lt;climits&gt;
// Compile time assertion:
template &lt;bool condition&gt;
struct StaticAssert;
template &lt;&gt;
struct StaticAssert&lt;true&gt; {};

// Template for finding the smallest
// built-in type that can hold a given
// value range, based on a set of
// conditions.
template&lt; bool sign, bool negbyte,
          bool negshort, bool negint,
          bool sbyte, bool ubyte,
          bool sshort, bool ushort,
          bool sint&gt;
  struct BoundedIntType;

template&lt;&gt;
struct BoundedIntType&lt; true, true, true,
                       true, true, true,
                       true, true, true&gt; {
  typedef signed char Type;
};

template&lt; bool negbyte, bool sbyte,
          bool ubyte&gt;
struct BoundedIntType&lt; true, negbyte,
                       true, true,
                       sbyte, ubyte,
                       true, true,
                       true&gt; {
  typedef signed short Type;
};

template&lt;bool negbyte, bool negshort,
         bool sbyte, bool ubyte,
         bool sshort, bool ushort&gt;
struct BoundedIntType&lt; true, negbyte,
                       negshort, true,
                       sbyte, ubyte, sshort,
                       ushort, true&gt; {
  typedef signed int Type;
};

template &lt;bool sbyte&gt;
struct BoundedIntType&lt; false, true, true,
                       true, sbyte, true,
                       true, true,
                       true&gt; {
  typedef unsigned char Type;
};

template&lt; bool sbyte, bool ubyte,
bool sshort&gt;
struct BoundedIntType&lt; false, true, true,
                       true, sbyte, ubyte,
                       sshort, true,
                       true&gt; {
  typedef unsigned short Type;
};

template&lt; bool sbyte, bool ubyte,
          bool sshort, bool ushort,
          bool sint&gt;
struct BoundedIntType&lt; false, true, true,
                       true, sbyte, ubyte,
                       sshort, ushort,
                       sint&gt; {
  typedef unsigned int Type;
};

// The traits template provides value
// range information to the
// BoundedIntType to get the smallest
// possible type.
template &lt;int Lower, int Upper&gt;
struct BoundedIntTraits {
  StaticAssert&lt;(Lower &lt;= Upper)&gt; check;
  typedef typename
    BoundedIntType&lt;Lower &lt; 0,
    Lower &gt;= CHAR_MIN,
    Lower &gt;= SHRT_MIN,
    Lower &gt;= INT_MIN,
    Upper &lt;= CHAR_MAX,
    Upper &lt;= UCHAR_MAX,
    Upper &lt;= SHRT_MAX,
    Upper &lt;= USHRT_MAX,
    Upper &lt;= INT_MAX&gt;::Type Type;
};

<span class=
"bold"><b>Listing 2:</b></span> Definition of BoundedIntTraits. The types long and unsigned long are not included to keep the listing shorter.
</pre>
<p>The checking is performed here by using the <tt class=
"computeroutput">assert()</tt> macro. Note that this checking only
happens in debug builds and not in the release builds to reduce the
overhead for this checking. Using inlining and the <tt class=
"computeroutput">assert()</tt> macro removes any overhead in
optimised release builds. With a good optimiser the resulting code
will be identical to when built-in types are used. Alternatives to
<tt class="computeroutput">assert()</tt> can of course be used such
as throwing an exception or logging a message to a file.</p>
<p>The <tt class="computeroutput">BoundedInt</tt> class is only
designed to work with value ranges that fit in an <tt class=
"computeroutput">int</tt>. To support wider ranges all methods that
take an <tt class="computeroutput">int</tt> as a parameter must
have overloaded siblings that take a <tt class=
"computeroutput">long</tt>, or even <tt class="computeroutput">long
long</tt> where supported.</p>
<p>The <tt class="computeroutput">operator+=()</tt> member must
check that the new value is within the valid range. It also has to
check that there is no overflow during addition. The method of
detecting overflow is complicated as there is no support for
detecting overflow for built-in types in C and C++. The method here
scales down all values to manageable sizes in order to do an
overflow check. Because of the scaling down, it has to keep track
of carry over data from the least significant bits to work properly
in edge cases where the value range is close to the value range of
the underlying type.</p>
<p>Other arithmetic assignment operators that <tt class=
"computeroutput">BoundedInt</tt> should support are not shown here
as they would take too much space. The design of these operators
follows the design for the plus operator.</p>
<p>There are no binary arithmetic operators defined. When a
<tt class="computeroutput">BoundedInt</tt> object is used in a
binary arithmetic operation, it will be converted to a built-in
integral type before the operation. This means that there is no
checking of the results of these operations, unless the result is
assigned to a <tt class="computeroutput">BoundedInt</tt> object.
There is a pitfall here in that overflow cannot be checked for.</p>
<pre class="programlisting">
BoundedInt&lt;-10, INT_MAX&gt; a = 10;
a += INT_MAX;     // Overflow checked
a = a + INT_MAX;  // Overflow not checked
</pre>
<p>A default constructor is available in order to mimic the
behaviour of built-in types. It does not initialise the value but
maintains a flag to indicate that this object does not have a
defined value. This flag is checked by member functions that access
or modify the value. The <tt class=
"computeroutput">m_initialised</tt> member flag is surrounded by
conditional pre-processing directives to avoid overhead in release
builds.</p>
<p>The copy constructor and copy assignment operators are not
defined as the compiler generated versions are appropriate.</p>
<p>Below are some examples from an imaginary C project implementing
a lift control with a single change to use <tt class=
"computeroutput">BoundedInt</tt>:</p>
<pre class="programlisting">
typedef BoundedInt&lt;-4, 17&gt; FloorNumber;
FloorNumber liftPosition = 0;
const FloorNumber myOfficeFloor = 10;

/* go up */
++liftPosition;

/* go up fast */
liftPosition += 4;
printf(&quot;The lift is %d floors away.\n&quot;,
abs(liftPosition-myOfficeFloor));
</pre>
<p><tt class="computeroutput">BoundedInt</tt> objects can appear in
any arbitrarily complex expression thanks to the conversion
operator. Because the conversion operator is inlined the <tt class=
"computeroutput">BoundedInt</tt> object will generate exactly the
same code as when using a built-in type.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e121" id="d0e121"></a>Bounded
Arrays</h2>
</div>
<p>A <tt class="computeroutput">BoundedInt</tt> object can be used
as a bounds checked index into arrays. Example:</p>
<pre class="programlisting">
const int SixPackSize = 6;
Bottle myBeers[SixPackSize];
BoundedInt&lt;0, SixPackSize-1&gt; ix;
for( ix = 0 ; ix &lt; SixPackSize ; ++ix ) {
  drink(myBeers[ix]);
}
</pre>
<p>If ix for some reason is changed to an invalid value, the
<tt class="computeroutput">BoundedInt</tt> class will warn about
this.</p>
<p>We can take this one step further by creating a class that only
allows element access using numbers within the allowed range.</p>
<pre class="programlisting">
template &lt;typename T, size_t Size&gt;
class BoundedArray {
public:
  T&amp; operator[](BoundedInt&lt;0,
                Size-1&gt; ix) {
    return m_data[ix];
  }
public:
  T m_data[Size];
};
</pre>
<p>Note that the member data is public to allow aggregate
initialisation. See how this is used below. The member data can be
made public without risk for misuse as the data is equally
accessible through the index operator as with direct access.</p>
<p>Whenever an element is requested using an index of any builtin
integral type, that index is converted to a <tt class=
"computeroutput">BoundedInt</tt> which checks that its value is
within the acceptable range.</p>
<p>This template takes two parameters, the type of the elements in
the array and a non-type template parameter to indicate the size of
the array. The simple example above will work as before with only a
small change to the definition of <tt class=
"computeroutput">myBeers</tt>.</p>
<pre class="programlisting">
BoundedArray&lt;Bottle, SixPackSize&gt;
  myBeers;
</pre>
<p>This array can be initialised in the same way as a built-in
array:</p>
<pre class="programlisting">
BoundedArray&lt;Bottle, SixPackSize&gt;
  myBeers = { ... };
</pre>
<p>There is no overhead in release builds for this array class. The
index operator is inlined and there is no indirect pointer access
to the underlying array. Having the size as a template parameter
may look like we are causing code bloat if several arrays of
different sizes are used. Yes, there will be several instantiations
but because all functions are inlined and optimised away there is
no extra code that can multiply.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e160" id="d0e160"></a>Bounded
Pointers</h2>
</div>
<p>In the same way as for using checked array indices we can create
a smart pointer class that makes sure that it points to an element
inside the array. It will have to know the base address of the
array and the size to do the checking. This information is
retrieved from the array class when a pointer is created.</p>
<p>The starting point is an example with built-in pointers:</p>
<pre class="programlisting">
Bottle* p = myBeers;
for( ; p-&gt;size != 0 ; ++p ) {
  drink(*p);
}
</pre>
<p><tt class="computeroutput">myBeers</tt> is an array where the
last elements members are cleared as a termination condition. We
replace the built-in pointer <tt class="computeroutput">p</tt> with
a smart pointer:</p>
<pre class="programlisting">
BoundedPointer&lt;Bottle&gt;
  p = myBeers;
</pre>
<p>The loop in the example above remains unchanged.</p>
<p>The definition of <tt class="computeroutput">BoundedPointer</tt>
is shown in listing 3. The array base address, array size and the
initialised flag are kept as members only for debug builds to
perform the runtime checks. To avoid this overhead in release
builds the <tt class="computeroutput">m_base</tt>, <tt class=
"computeroutput">m_size</tt> and <tt class=
"computeroutput">m_initialised</tt> members are surrounded with
conditional preprocessing directives.</p>
<pre class="programlisting">
#include &lt;cstddef&gt;
#include &lt;cassert&gt;

template &lt;typename T&gt;
class BoundedPointer {
public:
  // Default constructor
  BoundedPointer()
#ifndef NDEBUG
    : m_initialised(false)
#endif
  {}
// Constructor from a built-in array
  template &lt;size_t Size&gt;
  BoundedPointer(T (&amp;arr)[Size])
    : m_p(arr)
#ifndef NDEBUG
    , m_base(arr), m_size(Size)
    , m_initialised(true)
#endif
  {}
// Constructor from a user defined array
  BoundedPointer(const T* base, size_t size)
    : m_p(const_cast&lt;T*&gt;(base))
#ifndef NDEBUG
    , m_base(m_p)
    , m_size(size)
    , m_initialised(true)
#endif
  {}
// Constructor from null
  BoundedPointer(void * value)
    : m_p(static_cast&lt;T *&gt;(value))
#ifndef NDEBUG
    , m_base(m_p), m_size(1)
    , m_initialised(true)
#endif
  {}
// Dereference operators
  T &amp; operator*() {
    assert(m_initialised);
    assert(m_p != 0);
    return *m_p;
  }
  T * operator-&gt;() {
    assert(m_initialised);
    assert(m_p != 0);
    return m_p;
  }
  T &amp; operator[](size_t ix) {
    assert(m_initialised);
    assert(m_p != 0);
    assert(m_p + ix &lt; m_base + m_size);
    return m_p[ix];
  }
// Pointer arithmetic operations
  ptrdiff_t operator-(BoundedPointer
                      const &amp; rhs) {
    // Check validity of the pointers
    assert(m_initialised);
    assert(rhs.m_initialised);
    assert(m_p != 0);
    assert(rhs.m_p != 0);
    // Ensure both pointers point to same array
    assert(m_base == rhs.m_base);
    return m_p - rhs.m_p;
  }
  BoundedPointer &amp; operator+=(ptrdiff_t rhs) {
    // Check validity of the pointer
    assert(m_initialised);
    assert(m_p != 0);
    m_p += rhs;
    assert(m_base &lt;= m_p &amp;&amp; m_p &lt; m_base + m_size);
    return *this;
  }
  BoundedPointer &amp; operator++() {
    // Check validity of the pointer
    assert(m_initialised);
    assert(m_p != 0);
    ++m_p;
    assert(m_p &lt; m_base + m_size);
    return *this;
  }
// Other arithmetic operators ...
// Comparison operators
  bool operator==(BoundedPointer const &amp; rhs) {
    // Check validity of the pointers
    assert(m_initialised);
    assert(rhs.m_initialised);
    assert(m_p != 0);
    assert(rhs.m_p != 0);
    // Make sure that both pointers point
    // to the same array
    assert(m_base == rhs.m_base);
    return m_p == rhs.m_p;
  }
// Other comparison operators ...
private:
  T * m_p;
#ifndef NDEBUG
  T * m_base;
  size_t m_size;
  bool m_initialised;
#endif
};
// Binary arithmetic operators
template &lt;typename T&gt;
inline BoundedPointer&lt;T&gt;
operator+(BoundedPointer&lt;T&gt; lhs, int rhs) {
  return lhs.operator+=(rhs);
}
template &lt;typename T&gt;
inline BoundedPointer&lt;T&gt; operator+(int lhs,
                                   BoundedPointer&lt;T&gt; rhs) {
  return rhs.operator+=(lhs);
}

<span class=
"bold"><b>Listing 3:</b></span> Definition of BoundedPointer.
</pre>
<p>A <tt class="computeroutput">BoundedPointer</tt> object can be
constructed from built-in arrays and from user defined array types.
The constructor for user defined array types takes two parameters
(base address and size) and is intended to be called from
conversion operators of those array classes. This conversion
operator for <tt class="computeroutput">BoundedArray</tt> looks
like this:</p>
<pre class="programlisting">
template &lt;typename T, size_t Size&gt;
class BoundedArray {
public:
  ...
  operator BoundedPointer&lt;T&gt;() {
  return BoundedPointer&lt;T&gt;(m_data,
                           Size);
  }
};
</pre>
<p>There is also a constructor that takes a <tt class=
"computeroutput">void*</tt> parameter to support assignment from
<tt class="computeroutput">NULL</tt>. A <tt class=
"computeroutput">T*</tt> parameter cannot be used as it would
conflict with the constructor for built-in arrays.</p>
<p>The <tt class="computeroutput">BoundedPointer</tt> class
supports all the operations that can be used with built-in
pointers. There are checks for incrementing and decrementing the
pointer to make sure that it does not point outside its array. As
with <tt class="computeroutput">BoundedInt</tt> there are checks to
see that the pointer is initialised when it is used.</p>
<p>All methods are inlined to avoid any overhead in release
builds.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e230" id="d0e230"></a>Usage</h2>
</div>
<p>The classes described here are designed to do the bounds
checking during unit and system testing when compiled in debug
mode. It is important to run as many test cases as possible that
exercise all boundary conditions.</p>
<p>In release builds, all you have to do is make sure that the
<tt class="computeroutput">NDEBUG</tt> macro is defined, inlining
is enabled and the optimise level is as high as possible. Then your
code will be as efficient as if built-in types were used.</p>
<p>The <tt class="computeroutput">BoundedIntTraits</tt> in listing
2 hides the chosen underlying integral type. If the ranges change
in the future, there is no need to manually change the underlying
type required for the wider range.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e245" id=
"d0e245"></a>Extensions</h2>
</div>
<p>This article describes the design of a class that wraps an array
and adds bounds checking functionality. There are many more
possible classes that can be used in this framework for different
purposes. Examples include a class that manages dynamically
allocated arrays.</p>
<p>A possible extension to the checked pointer is to keep track of
whether the array still exists. If the array goes out of scope or
is de-allocated the pointer shall be set to an invalid state. This
is straight-forward to implement but is outside the scope of this
article.</p>
<p>This article does not discuss checked iterators for STL
containers as the article was originally intended to motivate C
users to adopt C++ to improve their lives. For STL there are
already implementations that check validity of the iterators.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e254" id=
"d0e254"></a>Portability</h2>
</div>
<p>Although the code in this article has been tested with several
C++ compilers there are some difficulties using some existing
compilers.</p>
<p>If your compiler does not support partial template
specialisations you cannot use the traits class <tt class=
"computeroutput">BoundedIntTraits</tt>. You can avoid the
<tt class="computeroutput">BoundedIntTraits</tt> class by removing
it from the template parameter list of <tt class=
"computeroutput">BoundedInt</tt> and replace it with <tt class=
"computeroutput">int</tt>.</p>
<p>You will miss the feature where the underlying type of
<tt class="computeroutput">BoundedInt</tt> is automatically chosen
from the specified range and it will be <tt class=
"computeroutput">int</tt> if a type is not specified.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e281" id=
"d0e281"></a>Conclusion</h2>
</div>
<p>With the strategies shown in this article it is possible to
catch various out of bounds conditions during the testing phase at
no cost to the released code.</p>
<p>An additional benefit is that the bounds given to <tt class=
"computeroutput">BoundedInt</tt> and the array types document their
valid ranges well.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e291" id="d0e291"></a>Related
Reading</h2>
</div>
<div class="variablelist">
<dl>
<dt><span class="term">Safe and efficient data types in C++ by
Nicolas Burrus</span></dt>
<dd>
<p><a href=
"http://www.lrde.epita.fr/dload/20020925-Seminar/burrus0902_datatypes_report.pdf"
target=
"_top">http://www.lrde.epita.fr/dload/20020925-Seminar/burrus0902_datatypes_report.pdf</a></p>
</dd>
</dl>
</div>
<p>Describes classes for compile time type safety when using
different integral types. It defines safe operations for a set of
integral types. The integral types used here are only bounded by
the number of bits used in the internal representation. The
description of operations and integral promotion is interesting and
can be applied to the classes in this article.</p>
<div class="variablelist">
<dl>
<dt><span class="term">Boost Integer Library</span></dt>
<dd>
<p><a href="http://boost.org/libs/integer/index.htm" target=
"_top">http://boost.org/libs/integer/index.htm</a></p>
</dd>
</dl>
</div>
<p>Contains some helpful classes for determining types of integers
given required number of bits. Also contains other helpful classes
that can be useful in implementing a portable bounded integer and
pointer library.</p>
<div class="variablelist">
<dl>
<dt><span class="term">Boost array class in the container
library</span></dt>
<dd>
<p><a href="http://www.boost.org/libs/array/array.html" target=
"_top">http://www.boost.org/libs/array/array.html</a></p>
</dd>
</dl>
</div>
<p>A constant size array class. The design goal for this class is
to follow the STL principles.</p>
<div class="variablelist">
<dl>
<dt><span class="term">Bounds checking pointers for
GCC.</span></dt>
<dd>
<p><a href="http://gcc.gnu.org/projects/bp/main.html" target=
"_top">http://gcc.gnu.org/projects/bp/main.html</a></p>
</dd>
</dl>
</div>
<p>Additions to GCC to add bounds checking to the generated
code.</p>
<div class="variablelist">
<dl>
<dt><span class="term">Safe STL</span></dt>
<dd>
<p><a href="http://www.horstmann.com/safestl.html" target=
"_top">http://www.horstmann.com/safestl.html</a></p>
</dd>
</dl>
</div>
<p>An implementation of STL that performs various run-time checks
on iterators.</p>
<div class="variablelist">
<dl>
<dt><span class="term">CheckedInt: A Policy-Based Range-Checked
Integer by Hubert Matthews</span></dt>
<dd>
<p>Overload issue 58, December 2003</p>
</dd>
</dl>
</div>
<p>Describes how policy classes can be used to select behaviour
when a given range is exceeded.</p>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
