This commit is contained in:
邹晓航
2015-03-16 19:14:01 +08:00
parent 3b2d095555
commit 75a7f57ca1
3 changed files with 43 additions and 0 deletions

View File

@@ -47,6 +47,7 @@ TinySTL
* unordered_set100%
* unique_ptr100%
* shared_ptr100%
* cow_ptr100%
* STL Algorithms:
* fill100%
* fill_n100%
@@ -563,6 +564,23 @@ TinySTL
up.reset(new string("hello"));
assert(*up == "hello");
####(19):cow_ptr
cow_ptr<string> cp1(new string("zouxiaohang"));
auto cp2 = cp1, cp3 = cp1;
assert(cp1 == cp2 && cp2 == cp3);
assert(*cp1 == *cp2 && *cp2 == *cp3 && *cp3 == "zouxiaohang");
*cp2;//read
assert(cp1 == cp2 && cp2 == cp3);
assert(*cp1 == *cp2 && *cp2 == *cp3 && *cp3 == "zouxiaohang");
cp2->append(" C++");//write
assert(*cp1 == *cp3 && *cp3 == "zouxiaohang");
assert(*cp2 == "zouxiaohang C++");