Created
August 29, 2009 08:44
-
-
Save qnighy/177434 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* dvector.h | |
* | |
* #include "dvector.h" | |
* | |
* then std::vector::operator[] seems to become checking the range of index. | |
* | |
* If you aren't using default allocator, I think it may not work. | |
* | |
*/ | |
#ifndef _DVECTOR_H | |
#define _DVECTOR_H | |
#include <vector> | |
namespace std { | |
template<typename T> | |
class dvector : public std::vector<T> | |
{ | |
public: | |
dvector() : std::vector<T>() {} | |
explicit dvector(size_t n, const T& value = T()) : std::vector<T>(n,value) {} | |
dvector(const std::vector<T>& v) : std::vector<T>(v) {} | |
T& operator[](size_t n) | |
{ | |
return this->at(n); | |
} | |
}; | |
}; | |
#define vector dvector | |
#endif /* _DVECTOR_H */ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment