提交 39b6e637 编写于 作者: 邹晓航

make_cow

上级 16fe2265
......@@ -569,7 +569,7 @@ TinySTL
####(19):cow_ptr
cow_ptr<string> cp1(new string("zouxiaohang"));
cow_ptr<string> cp1 = make_cow<string>("zouxiaohang");
auto cp2 = cp1, cp3 = cp1;
assert(cp1 == cp2 && cp2 == cp3);
assert(*cp1 == *cp2 && *cp2 == *cp3 && *cp3 == "zouxiaohang");
......
......@@ -68,6 +68,11 @@ namespace TinySTL{
template<class _T>
friend class Detail::proxy;
};
template<class T, class... Args>
cow_ptr<T> make_cow(Args...args){
return cow_ptr<T>(new T(std::forward<Args>(args)...));
}
}
#include "Detail\COWPtr.impl.h"
......
......@@ -28,7 +28,7 @@ namespace TinySTL{
assert(cp4 == nullptr);
}
void testCase2(){
cow_ptr<string> cp1(new string("zouxiaohang"));
cow_ptr<string> cp1 = make_cow<string>("zouxiaohang");
auto cp2 = cp1, cp3 = cp1;
assert(cp1 == cp2 && cp2 == cp3);
assert(*cp1 == *cp2 && *cp2 == *cp3 && *cp3 == "zouxiaohang");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册