Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
TinySTL
提交
d31d3df7
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 搜索 >>
提交
d31d3df7
编写于
3月 13, 2015
作者:
邹
邹晓航
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add ref
上级
3c6fa24a
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
46 addition
and
0 deletion
+46
-0
TinySTL/Detail/Ref.h
TinySTL/Detail/Ref.h
+42
-0
TinySTL/TinySTL.vcxproj
TinySTL/TinySTL.vcxproj
+1
-0
TinySTL/TinySTL.vcxproj.filters
TinySTL/TinySTL.vcxproj.filters
+3
-0
未找到文件。
TinySTL/Detail/Ref.h
0 → 100644
浏览文件 @
d31d3df7
#ifndef _REF_H_
#define _REF_H_
#include <atomic>
namespace
TinySTL
{
namespace
Detail
{
template
<
class
T
>
struct
ref_t
{
std
::
atomic
<
size_t
>
ncount_
;
T
*
data_
;
explicit
ref_t
(
size_t
n
=
0
,
T
*
p
=
nullptr
)
:
ncount_
(
n
),
data_
(
p
){}
ref_t
(
const
ref_t
&
)
=
default
;
ref_t
&
operator
=
(
const
ref_t
&
)
=
default
;
size_t
count
()
const
{
return
ncount_
.
load
();
}
T
*
get_data
()
const
{
return
data_
;
}
ref_t
&
operator
++
(){
++
ncount_
;
return
*
this
;
}
ref_t
operator
++
(
int
){
auto
t
=
*
this
;
++*
this
;
return
t
;
}
ref_t
&
operator
--
(){
--
ncount_
;
return
*
this
;
}
ref_t
operator
--
(
int
){
auto
t
=
*
this
;
--*
this
;
return
t
;
}
};
}
}
#endif
\ No newline at end of file
TinySTL/TinySTL.vcxproj
浏览文件 @
d31d3df7
...
@@ -121,6 +121,7 @@
...
@@ -121,6 +121,7 @@
<ClInclude
Include=
"Detail\Deque.impl.h"
/>
<ClInclude
Include=
"Detail\Deque.impl.h"
/>
<ClInclude
Include=
"Detail\Graph.impl.h"
/>
<ClInclude
Include=
"Detail\Graph.impl.h"
/>
<ClInclude
Include=
"Detail\List.impl.h"
/>
<ClInclude
Include=
"Detail\List.impl.h"
/>
<ClInclude
Include=
"Detail\Ref.h"
/>
<ClInclude
Include=
"Detail\Unordered_set.impl.h"
/>
<ClInclude
Include=
"Detail\Unordered_set.impl.h"
/>
<ClInclude
Include=
"Detail\Vector.impl.h"
/>
<ClInclude
Include=
"Detail\Vector.impl.h"
/>
<ClInclude
Include=
"Functional.h"
/>
<ClInclude
Include=
"Functional.h"
/>
...
...
TinySTL/TinySTL.vcxproj.filters
浏览文件 @
d31d3df7
...
@@ -263,6 +263,9 @@
...
@@ -263,6 +263,9 @@
<ClInclude
Include=
"Test\UniquePtrTest.h"
>
<ClInclude
Include=
"Test\UniquePtrTest.h"
>
<Filter>
Test
</Filter>
<Filter>
Test
</Filter>
</ClInclude>
</ClInclude>
<ClInclude
Include=
"Detail\Ref.h"
>
<Filter>
Detail
</Filter>
</ClInclude>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<None
Include=
"..\README.md"
/>
<None
Include=
"..\README.md"
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录