Skip to content

Instantly share code, notes, and snippets.

@qnighy
Created August 29, 2009 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qnighy/177434 to your computer and use it in GitHub Desktop.
Save qnighy/177434 to your computer and use it in GitHub Desktop.
/**
* 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