Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
TinySTL
提交
6b85b325
T
TinySTL
项目概览
OpenDocCN
/
TinySTL
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TinySTL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6b85b325
编写于
3月 16, 2015
作者:
邹
邹晓航
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add cow_ptr test
上级
8e5f9a47
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
94 addition
and
4 deletion
+94
-4
TinySTL/Detail/COWPtr.impl.h
TinySTL/Detail/COWPtr.impl.h
+32
-0
TinySTL/Test/COWPtrTest.cpp
TinySTL/Test/COWPtrTest.cpp
+24
-0
TinySTL/Test/COWPtrTest.h
TinySTL/Test/COWPtrTest.h
+16
-0
TinySTL/TinySTL.vcxproj
TinySTL/TinySTL.vcxproj
+5
-1
TinySTL/TinySTL.vcxproj.filters
TinySTL/TinySTL.vcxproj.filters
+15
-3
TinySTL/main.cpp
TinySTL/main.cpp
+2
-0
未找到文件。
TinySTL/Detail/COWPtr.impl.h
0 → 100644
浏览文件 @
6b85b325
#ifndef _COWPTR_IMPL_H_
#define _COWPTR_IMPL_H_
namespace
TinySTL
{
template
<
class
T
>
cow_ptr
<
T
>::
cow_ptr
(
T
*
p
=
nullptr
)
:
ptr_
(
p
){}
template
<
class
T
>
template
<
class
D
>
cow_ptr
<
T
>::
cow_ptr
(
T
*
p
,
D
d
)
:
ptr_
(
p
,
d
){}
template
<
class
T
>
cow_ptr
<
T
>::
cow_ptr
(
const
cow_ptr
&
cp
){
ptr_
=
cp
.
ptr_
;
}
template
<
class
T
>
cow_ptr
<
T
>&
cow_ptr
<
T
>::
operator
=
(
const
cow_ptr
&
cp
){
if
(
this
!=
&
cp
){
ptr_
.
decrease_ref
();
ptr_
=
cp
.
ptr_
;
}
return
*
this
;
}
template
<
class
T
>
typename
cow_ptr
<
T
>::
element_type
cow_ptr
<
T
>::
operator
*
()
const
{
return
*
ptr_
;
}
template
<
class
T
>
typename
cow_ptr
<
T
>::
element_type
*
cow_ptr
<
T
>::
operator
->
()
const
{
return
ptr_
.
operator
->
();
}
}
#endif
\ No newline at end of file
TinySTL/Test/COWPtrTest.cpp
0 → 100644
浏览文件 @
6b85b325
#include "COWPtrTest.h"
#include "../String.h"
namespace
TinySTL
{
namespace
COWPtrTest
{
void
testCase1
(){
cow_ptr
<
string
>
cp1
(
new
string
(
"hello"
));
assert
(
*
cp1
==
"hello"
);
cp1
->
append
(
" world"
);
auto
cp2
=
cp1
;
assert
(
*
cp2
==
"hello world"
);
cow_ptr
<
string
>
cp3
;
cp3
=
cp1
;
assert
(
*
cp3
==
"hello world"
);
}
void
testAllCases
(){
testCase1
();
}
}
}
\ No newline at end of file
TinySTL/Test/COWPtrTest.h
0 → 100644
浏览文件 @
6b85b325
#ifndef _COWPTR_TEST_H_
#define _COWPTR_TEST_H_
#include "../COWPtr.h"
#include <cassert>
namespace
TinySTL
{
namespace
COWPtrTest
{
void
testCase1
();
void
testAllCases
();
}
}
#endif
\ No newline at end of file
TinySTL/TinySTL.vcxproj
浏览文件 @
6b85b325
...
...
@@ -82,7 +82,7 @@
<ItemGroup>
<ClCompile
Include=
"Detail\Alloc.cpp"
/>
<ClCompile
Include=
"Detail\String.cpp"
/>
<ClCompile
Include=
"Detail\T
ir
eTree.cpp"
/>
<ClCompile
Include=
"Detail\T
ri
eTree.cpp"
/>
<ClCompile
Include=
"main.cpp"
/>
<ClCompile
Include=
"Profiler\Profiler.cpp"
/>
<ClCompile
Include=
"Test\AlgorithmTest.cpp"
/>
...
...
@@ -90,6 +90,7 @@
<ClCompile
Include=
"Test\BinarySearchTreeTest.cpp"
/>
<ClCompile
Include=
"Test\BitmapTest.cpp"
/>
<ClCompile
Include=
"Test\CircularBufferTest.cpp"
/>
<ClCompile
Include=
"Test\COWPtrTest.cpp"
/>
<ClCompile
Include=
"Test\DequeTest.cpp"
/>
<ClCompile
Include=
"Test\GraphTest.cpp"
/>
<ClCompile
Include=
"Test\ListTest.cpp"
/>
...
...
@@ -115,11 +116,13 @@
<ClInclude
Include=
"Bitmap.h"
/>
<ClInclude
Include=
"CircularBuffer.h"
/>
<ClInclude
Include=
"Construct.h"
/>
<ClInclude
Include=
"COWPtr.h"
/>
<ClInclude
Include=
"Deque.h"
/>
<ClInclude
Include=
"Detail\AVLTree.impl.h"
/>
<ClInclude
Include=
"Detail\BinarySearchTree.impl.h"
/>
<ClInclude
Include=
"Detail\Bitmap.impl.h"
/>
<ClInclude
Include=
"Detail\CircularBuffer.impl.h"
/>
<ClInclude
Include=
"Detail\COWPtr.impl.h"
/>
<ClInclude
Include=
"Detail\Deque.impl.h"
/>
<ClInclude
Include=
"Detail\Graph.impl.h"
/>
<ClInclude
Include=
"Detail\List.impl.h"
/>
...
...
@@ -142,6 +145,7 @@
<ClInclude
Include=
"Test\BinarySearchTreeTest.h"
/>
<ClInclude
Include=
"Test\BitmapTest.h"
/>
<ClInclude
Include=
"Test\CircularBufferTest.h"
/>
<ClInclude
Include=
"Test\COWPtrTest.h"
/>
<ClInclude
Include=
"Test\DequeTest.h"
/>
<ClInclude
Include=
"Test\GraphTest.h"
/>
<ClInclude
Include=
"Test\ListTest.h"
/>
...
...
TinySTL/TinySTL.vcxproj.filters
浏览文件 @
6b85b325
...
...
@@ -90,9 +90,6 @@
<ClCompile
Include=
"Test\GraphTest.cpp"
>
<Filter>
Test
</Filter>
</ClCompile>
<ClCompile
Include=
"Detail\TireTree.cpp"
>
<Filter>
Detail
</Filter>
</ClCompile>
<ClCompile
Include=
"Test\TrieTreeTest.cpp"
>
<Filter>
Test
</Filter>
</ClCompile>
...
...
@@ -105,6 +102,12 @@
<ClCompile
Include=
"Test\SharedPtrTest.cpp"
>
<Filter>
Test
</Filter>
</ClCompile>
<ClCompile
Include=
"Detail\TrieTree.cpp"
>
<Filter>
Detail
</Filter>
</ClCompile>
<ClCompile
Include=
"Test\COWPtrTest.cpp"
>
<Filter>
Test
</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"TypeTraits.h"
>
...
...
@@ -278,6 +281,15 @@
<ClInclude
Include=
"Test\SharedPtrTest.h"
>
<Filter>
Test
</Filter>
</ClInclude>
<ClInclude
Include=
"COWPtr.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"Detail\COWPtr.impl.h"
>
<Filter>
Detail
</Filter>
</ClInclude>
<ClInclude
Include=
"Test\COWPtrTest.h"
>
<Filter>
Test
</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None
Include=
"..\README.md"
/>
...
...
TinySTL/main.cpp
浏览文件 @
6b85b325
...
...
@@ -8,6 +8,7 @@
#include "Test\BitmapTest.h"
#include "Test\BinarySearchTreeTest.h"
#include "Test\CircularBufferTest.h"
#include "Test\COWPtrTest.h"
#include "Test\DequeTest.h"
#include "Test\GraphTest.h"
#include "Test\ListTest.h"
...
...
@@ -32,6 +33,7 @@ int main(){
TinySTL
::
BitmapTest
::
testAllCases
();
TinySTL
::
BinarySearchTreeTest
::
testAllCases
();
TinySTL
::
CircularBufferTest
::
testAllCases
();
TinySTL
::
COWPtrTest
::
testAllCases
();
TinySTL
::
DequeTest
::
testAllCases
();
TinySTL
::
ListTest
::
testAllCases
();
TinySTL
::
GraphTest
::
testAllCases
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录