补充说明

This commit is contained in:
邹晓航
2015-03-17 09:23:59 +08:00
parent 26fc25d798
commit 16fe2265b8
3 changed files with 6 additions and 2 deletions

View File

@@ -574,7 +574,8 @@ TinySTL
assert(cp1 == cp2 && cp2 == cp3);
assert(*cp1 == *cp2 && *cp2 == *cp3 && *cp3 == "zouxiaohang");
*cp2;//read
string s = *cp2;//read
assert(s == "zouxiaohang");
assert(cp1 == cp2 && cp2 == cp3);
assert(*cp1 == *cp2 && *cp2 == *cp3 && *cp3 == "zouxiaohang");

View File

@@ -24,6 +24,7 @@ namespace TinySTL{
cow_ptr<T> *cp_;
};
}
//未能完全模拟原生指针操作,只供参考,详情见单元测试
template<class T>
class cow_ptr{
public:

View File

@@ -33,7 +33,9 @@ namespace TinySTL{
assert(cp1 == cp2 && cp2 == cp3);
assert(*cp1 == *cp2 && *cp2 == *cp3 && *cp3 == "zouxiaohang");
*cp2;//read
//cp2->capacity(); change the cow_ptr -> 由于代理类代理的类型未知(T)造成的
string s = *cp2;//read
assert(s == "zouxiaohang");
assert(cp1 == cp2 && cp2 == cp3);
assert(*cp1 == *cp2 && *cp2 == *cp3 && *cp3 == "zouxiaohang");