📄 fe_vector.h
字号:
///////////////////////////////////////////////////////////////////////////////
// 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -