Guest User

Untitled

a guest
Jun 25th, 2011
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #define DEBUG
  2.  
  3. #include <vector>
  4.  
  5. template<typename T, typename A = std::allocator<T> > class SafeVector : public std::vector<T, A> {
  6. public:
  7.  
  8.     typename std::vector<T, A>::reference
  9.         operator[](typename std::vector<T, A>::size_type n) {
  10.         return at(n);
  11.     }
  12.  
  13.     typename std::vector<T, A>::const_reference
  14.         operator[](typename std::vector<T, A>::size_type n) const {
  15.         return at(n);
  16.     }
  17. };
  18.  
  19. using namespace std;
  20.  
  21. #ifdef DEBUG
  22. #define vector SafeVector
  23. #endif
Advertisement
Add Comment
Please, Sign In to add comment