Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
畅游知识海洋
json
提交
8e9714fe
J
json
项目概览
畅游知识海洋
/
json
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
json
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
GitCode(gitcode.net)2024年7月9日维护升级公告
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
8e9714fe
编写于
8月 14, 2017
作者:
T
Théo DELRIEU
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add detail/json_ref.hpp
上级
a3473fda
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
69 addition
and
58 deletion
+69
-58
Makefile
Makefile
+2
-1
src/detail/json_ref.hpp
src/detail/json_ref.hpp
+66
-0
src/json.hpp
src/json.hpp
+1
-57
未找到文件。
Makefile
浏览文件 @
8e9714fe
...
...
@@ -21,7 +21,8 @@ SRCS = ${SRCDIR}/json.hpp \
${SRCDIR}
/detail/parsing/output_adapters.hpp
\
${SRCDIR}
/detail/parsing/binary_reader.hpp
\
${SRCDIR}
/detail/parsing/binary_writer.hpp
\
${SRCDIR}
/detail/serializer.hpp
${SRCDIR}
/detail/serializer.hpp
\
${SRCDIR}
/detail/json_ref.hpp
# main target
all
:
...
...
src/detail/json_ref.hpp
0 → 100644
浏览文件 @
8e9714fe
#ifndef NLOHMANN_JSON_DETAIL_JSON_REF_HPP
#define NLOHMANN_JSON_DETAIL_JSON_REF_HPP
#include <initializer_list>
#include <utility>
namespace
nlohmann
{
namespace
detail
{
template
<
typename
BasicJsonType
>
class
json_ref
{
public:
using
value_type
=
BasicJsonType
;
json_ref
(
value_type
&&
value
)
:
owned_value
(
std
::
move
(
value
)),
value_ref
(
&
owned_value
),
is_rvalue
(
true
)
{}
json_ref
(
const
value_type
&
value
)
:
value_ref
(
const_cast
<
value_type
*>
(
&
value
)),
is_rvalue
(
false
)
{}
json_ref
(
std
::
initializer_list
<
json_ref
>
init
)
:
owned_value
(
init
),
value_ref
(
&
owned_value
),
is_rvalue
(
true
)
{}
template
<
class
...
Args
>
json_ref
(
Args
&&
...
args
)
:
owned_value
(
std
::
forward
<
Args
>
(
args
)...),
value_ref
(
&
owned_value
),
is_rvalue
(
true
)
{}
// class should be movable only
json_ref
(
json_ref
&&
)
=
default
;
json_ref
(
const
json_ref
&
)
=
delete
;
json_ref
&
operator
=
(
const
json_ref
&
)
=
delete
;
value_type
moved_or_copied
()
const
{
if
(
is_rvalue
)
{
return
std
::
move
(
*
value_ref
);
}
return
*
value_ref
;
}
value_type
const
&
operator
*
()
const
{
return
*
static_cast
<
value_type
const
*>
(
value_ref
);
}
value_type
const
*
operator
->
()
const
{
return
static_cast
<
value_type
const
*>
(
value_ref
);
}
private:
mutable
value_type
owned_value
=
nullptr
;
value_type
*
value_ref
=
nullptr
;
const
bool
is_rvalue
;
};
}
}
#endif
src/json.hpp
浏览文件 @
8e9714fe
...
...
@@ -69,6 +69,7 @@ SOFTWARE.
#include "detail/parsing/binary_reader.hpp"
#include "detail/parsing/binary_writer.hpp"
#include "detail/serializer.hpp"
#include "detail/json_ref.hpp"
/*!
@brief namespace for Niels Lohmann
...
...
@@ -77,63 +78,6 @@ SOFTWARE.
*/
namespace
nlohmann
{
namespace
detail
{
template
<
typename
BasicJsonType
>
class
json_ref
{
public:
using
value_type
=
BasicJsonType
;
json_ref
(
value_type
&&
value
)
:
owned_value
(
std
::
move
(
value
)),
value_ref
(
&
owned_value
),
is_rvalue
(
true
)
{}
json_ref
(
const
value_type
&
value
)
:
value_ref
(
const_cast
<
value_type
*>
(
&
value
)),
is_rvalue
(
false
)
{}
json_ref
(
std
::
initializer_list
<
json_ref
>
init
)
:
owned_value
(
init
),
value_ref
(
&
owned_value
),
is_rvalue
(
true
)
{}
template
<
class
...
Args
>
json_ref
(
Args
&&
...
args
)
:
owned_value
(
std
::
forward
<
Args
>
(
args
)...),
value_ref
(
&
owned_value
),
is_rvalue
(
true
)
{}
// class should be movable only
json_ref
(
json_ref
&&
)
=
default
;
json_ref
(
const
json_ref
&
)
=
delete
;
json_ref
&
operator
=
(
const
json_ref
&
)
=
delete
;
value_type
moved_or_copied
()
const
{
if
(
is_rvalue
)
{
return
std
::
move
(
*
value_ref
);
}
return
*
value_ref
;
}
value_type
const
&
operator
*
()
const
{
return
*
static_cast
<
value_type
const
*>
(
value_ref
);
}
value_type
const
*
operator
->
()
const
{
return
static_cast
<
value_type
const
*>
(
value_ref
);
}
private:
mutable
value_type
owned_value
=
nullptr
;
value_type
*
value_ref
=
nullptr
;
const
bool
is_rvalue
;
};
}
// namespace detail
template
<
typename
,
typename
>
struct
adl_serializer
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录