FE_vector.h
上传用户:italyroyal
上传日期:2013-05-06
资源大小:473k
文件大小:1k
- ///////////////////////////////////////////////////////////////////////////////
- // This is a part of the Feature program.
- // Version: 1.0
- // Date: February 22, 2003
- // Programmer: Oh-Wook Kwon
- // Copyright(c) 2003 Oh-Wook Kwon. All rights reserved. owkwon@ucsd.edu
- ///////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////
- // This class provides bound-checking capability to the vector container.
- // Only works in the debug mode.
- ///////////////////////////////////////////////////////////////////////////////
- #ifndef _VECTOR_DEBUG_H_
#define _VECTOR_DEBUG_H_
- #pragma warning(disable:4786)
-
#include <vector>
- using namespace std;
-
#ifdef _DEBUG
#include <assert.h>
template <typename T>
class vectorDebug__ : public vector<T> {
public:
vectorDebug__(int n=0) : vector<T>(n) {}
const T& operator[](int i) const;
T& operator[](int i);
};
template <typename T> const T& vectorDebug__<T>::operator[](int i) const
{
if(i < 0 || i >= this->size()){
int n=this->size();
fprintf(stderr, "ERROR: vector bound error (index=%d)n", n);
assert(0);
}
return ((vector<T> *)this)->operator[](i);
}
template <typename T> T& vectorDebug__<T>::operator[](int i)
{
if(i < 0 || i >= this->size()){
int n=this->size();
fprintf(stderr, "ERROR: vector bound error (index=%d)n", n);
assert(0);
}
return ((vector<T> *)this)->operator[](i);
}
#define vector vectorDebug__
#endif
#endif