Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
33abccf8
Commit
33abccf8
authored
Nov 08, 2016
by
Théo DELRIEU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add template arguments for JSONSerializer
parent
7dc268ef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
json.hpp
src/json.hpp
+7
-6
No files found.
src/json.hpp
View file @
33abccf8
...
@@ -214,8 +214,9 @@ inline namespace
...
@@ -214,8 +214,9 @@ inline namespace
constexpr
auto
const
&
from_json
=
_static_const
<
detail
::
from_json_fn
>::
value
;
constexpr
auto
const
&
from_json
=
_static_const
<
detail
::
from_json_fn
>::
value
;
}
}
// default JSONSerializer template argument
// default JSONSerializer template argument
, doesn't care about template argument
// will use ADL for serialization
// will use ADL for serialization
template
<
typename
=
void
,
typename
=
void
>
struct
adl_serializer
struct
adl_serializer
{
{
template
<
typename
T
,
typename
Json
,
typename
=
enable_if_t
<
std
::
is_default_constructible
<
uncvref_t
<
T
>>::
value
>>
template
<
typename
T
,
typename
Json
,
typename
=
enable_if_t
<
std
::
is_default_constructible
<
uncvref_t
<
T
>>::
value
>>
...
@@ -328,7 +329,7 @@ template <
...
@@ -328,7 +329,7 @@ template <
class
NumberUnsignedType
=
std
::
uint64_t
,
class
NumberUnsignedType
=
std
::
uint64_t
,
class
NumberFloatType
=
double
,
class
NumberFloatType
=
double
,
template
<
typename
U
>
class
AllocatorType
=
std
::
allocator
,
template
<
typename
U
>
class
AllocatorType
=
std
::
allocator
,
class
JSONSerializer
=
adl_serializer
template
<
typename
T
,
typename
SFINAE
=
void
>
class
JSONSerializer
=
adl_serializer
>
>
class
basic_json
class
basic_json
{
{
...
@@ -1398,9 +1399,9 @@ class basic_json
...
@@ -1398,9 +1399,9 @@ class basic_json
}
}
// constructor chosen when JSONSerializer::to_json exists for type T
// constructor chosen when JSONSerializer::to_json exists for type T
template
<
typename
T
,
typename
=
decltype
(
JSONSerializer
::
to_json
(
std
::
declval
<
uncvref_t
<
T
>>
()))
>
template
<
typename
T
,
typename
=
decltype
(
JSONSerializer
<
uncvref_t
<
T
>>
::
to_json
(
std
::
declval
<
uncvref_t
<
T
>>
()))
>
explicit
basic_json
(
T
&&
val
)
explicit
basic_json
(
T
&&
val
)
:
basic_json
(
JSONSerializer
::
to_json
(
std
::
forward
<
T
>
(
val
)))
{}
:
basic_json
(
JSONSerializer
<
uncvref_t
<
T
>>
::
to_json
(
std
::
forward
<
T
>
(
val
)))
{}
/*!
/*!
@brief create a string (explicit)
@brief create a string (explicit)
...
@@ -3072,10 +3073,10 @@ class basic_json
...
@@ -3072,10 +3073,10 @@ class basic_json
}
}
template
<
typename
ValueType
,
typename
=
enable_if_t
<
std
::
is_default_constructible
<
uncvref_t
<
ValueType
>>::
value
,
float
>>
template
<
typename
ValueType
,
typename
=
enable_if_t
<
std
::
is_default_constructible
<
uncvref_t
<
ValueType
>>::
value
,
float
>>
auto
get
()
const
->
remove_reference_t
<
decltype
(
JSONSerializer
::
from_json
(
*
this
,
std
::
declval
<
ValueType
&>
()),
std
::
declval
<
ValueType
>
())
>
auto
get
()
const
->
remove_reference_t
<
decltype
(
JSONSerializer
<
uncvref_t
<
ValueType
>>
::
from_json
(
*
this
,
std
::
declval
<
ValueType
&>
()),
std
::
declval
<
ValueType
>
())
>
{
{
uncvref_t
<
ValueType
>
ret
;
uncvref_t
<
ValueType
>
ret
;
JSONSerializer
::
from_json
(
*
this
,
ret
);
JSONSerializer
<
uncvref_t
<
ValueType
>>
::
from_json
(
*
this
,
ret
);
return
ret
;
return
ret
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment