checked_iterator.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 #ifndef ACE_CHECKED_ITERATOR_H
00004 #define ACE_CHECKED_ITERATOR_H
00005 
00006 /**
00007  * @file checked_iterator.h
00008  *
00009  * @brief Checked iterator factory function.
00010  *
00011  * Some compilers (e.g. MSVC++ >= 8) issue security related
00012  * diagnostics if algorithms such as std::copy() are used in an unsafe
00013  * way.  Normally this isn't an issue if STL container iterators are
00014  * used in conjuction with the standard algorithms.  However, in cases
00015  * where application-specific iterators are use with standard
00016  * algorithms that could potentially overrun a buffer, extra care must
00017  * be taken to prevent such an overrun.  If supported, checked
00018  * iterators can be used to address the potential destination buffer
00019  * overrun.
00020  *
00021  * This header provides function templates that generate the
00022  * appropriate checked iterator.  In cases where checked iterators are
00023  * not supported, the pointer passed to the function is returned
00024  * instead.
00025  *
00026  * $Id: checked_iterator.h 80826 2008-03-04 14:51:23Z wotte $
00027  *
00028  * @internal The functions and types in this header are meant for
00029  *           internal use.  They may change at any point between
00030  *           releases.
00031  *
00032  * @author Ossama Othman
00033  */
00034 
00035 # if defined (_MSC_VER) && (_MSC_FULL_VER >= 140050000)
00036 // Checked iterators are currently only supported in MSVC++ 8 or better.
00037 #  include <iterator>
00038 # endif  /* _MSC_VER >= 1400 */
00039 
00040 # if defined (_MSC_VER) && (_MSC_FULL_VER >= 140050000)
00041 template <typename PTR>
00042 stdext::checked_array_iterator<PTR>
00043 ACE_make_checked_array_iterator (PTR buf, size_t len)
00044 {
00045   return stdext::checked_array_iterator<PTR> (buf, len);
00046 }
00047 # else
00048 template <typename PTR>
00049 PTR
00050 ACE_make_checked_array_iterator (PTR buf, size_t /* len */)
00051 {
00052   // Checked iterators are unsupported.  Just return the pointer to
00053   // the buffer itself.
00054   return buf;
00055 }
00056 # endif  /* _MSC_VER >= 1400 */
00057 
00058 #endif  /* ACE_CHECKED_ITERATOR_H */

Generated on Tue Feb 2 17:18:38 2010 for ACE by  doxygen 1.4.7