提交 892cc28c 编写于 作者: Y Yu Yang

Fix bug

上级 07bb4139
...@@ -106,9 +106,11 @@ class Vector { ...@@ -106,9 +106,11 @@ class Vector {
// std::vector iterator methods. Based on CPU data access method // std::vector iterator methods. Based on CPU data access method
size_t size() const { return size_; } size_t size() const { return size_; }
T* begin() { return size() == 0 ? &EmptyDummy() : &this->operator[](0); } T* begin() { return capacity() == 0 ? &EmptyDummy() : &this->operator[](0); }
T* end() { return size() == 0 ? &EmptyDummy() : &this->operator[](size()); } T* end() {
return capacity() == 0 ? &EmptyDummy() : &this->operator[](size());
}
T& front() { return *begin(); } T& front() { return *begin(); }
...@@ -119,11 +121,11 @@ class Vector { ...@@ -119,11 +121,11 @@ class Vector {
} }
const T* begin() const { const T* begin() const {
return size() == 0 ? &EmptyDummy() : &this->operator[](0); return capacity() == 0 ? &EmptyDummy() : &this->operator[](0);
} }
const T* end() const { const T* end() const {
return size() == 0 ? &EmptyDummy() : &this->operator[](size()); return capacity() == 0 ? &EmptyDummy() : &this->operator[](size());
} }
const T* cbegin() const { return begin(); } const T* cbegin() const { return begin(); }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册