From 8904505102763befad85577ef3a41df02e842955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=93=E8=88=AA?= <1210603696@qq.com> Date: Tue, 23 Sep 2014 14:56:06 +0800 Subject: [PATCH] bug fix --- TinySTL/Vector.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/TinySTL/Vector.h b/TinySTL/Vector.h index a27aff4..2e5da6a 100644 --- a/TinySTL/Vector.h +++ b/TinySTL/Vector.h @@ -101,6 +101,7 @@ namespace TinySTL{ vector(const vector& v); vector(vector&& v); vector& operator = (const vector& v); + vector& operator = (vector&& v); ~vector(){ destroyAndDeallocateAll(); } @@ -219,7 +220,7 @@ namespace TinySTL{ start_ = v.start_; finish_ = v.finish_; endOfStorage_ = v.endOfStorage_; - v.clear(); + v.start_ = v.finish_ = v.endOfStorage_ = 0; } template vector& vector::operator = (const vector& v){ @@ -228,6 +229,17 @@ namespace TinySTL{ } return *this; } + template + vector& vector::operator = (vector&& v){ + if (this != &v){ + destroyAndDeallocateAll(); + start_ = v.start_; + finish_ = v.finish_; + endOfStorage_ = v.endOfStorage_; + v.start_ = v.finish_ = v.endOfStorage_ = 0; + } + return *this; + } //*************和容器的容量相关****************************** template void vector::resize(size_type n, value_type val = value_type()){