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
1d870977
Commit
1d870977
authored
Jan 15, 2017
by
Théo DELRIEU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove some boilerplate
parent
e60e458a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
22 deletions
+22
-22
json.hpp
src/json.hpp
+11
-11
json.hpp.re2c
src/json.hpp.re2c
+11
-11
No files found.
src/json.hpp
View file @
1d870977
...
@@ -3019,26 +3019,26 @@ class basic_json
...
@@ -3019,26 +3019,26 @@ class basic_json
// the latter is preferred if both are present (since it does not require a default construction of T)
// the latter is preferred if both are present (since it does not require a default construction of T)
template
<
template
<
typename
T
,
typename
T
,
typename
U
=
uncvref_t
<
T
>
,
enable_if_t
<
enable_if_t
<
not
std
::
is_same
<
basic_json_t
,
uncvref_t
<
T
>
>::
value
and
not
std
::
is_same
<
basic_json_t
,
U
>::
value
and
detail
::
has_from_json
<
basic_json_t
,
uncvref_t
<
T
>
>::
value
and
detail
::
has_from_json
<
basic_json_t
,
U
>::
value
and
not
detail
::
has_non_default_from_json
<
basic_json_t
,
not
detail
::
has_non_default_from_json
<
basic_json_t
,
uncvref_t
<
T
>
>::
value
,
U
>::
value
,
int
>
=
0
>
int
>
=
0
>
// do we really want the uncvref ? if a user call get<int &>, shouldn't we
// do we really want the uncvref ? if a user call get<int &>, shouldn't we
// static assert ?
// static assert ?
// i know there is a special behaviour for boolean_t* and such
// i know there is a special behaviour for boolean_t* and such
auto
get
()
const
noexcept
(
noexcept
(
JSONSerializer
<
uncvref_t
<
T
>
>::
from_json
(
auto
get
()
const
noexcept
(
noexcept
(
JSONSerializer
<
U
>::
from_json
(
std
::
declval
<
const
basic_json_t
&>
(),
std
::
declval
<
uncvref_t
<
T
>
&>
())))
std
::
declval
<
const
basic_json_t
&>
(),
std
::
declval
<
U
&>
())))
->
uncvref_t
<
T
>
->
U
{
{
using
type
=
uncvref_t
<
T
>
;
static_assert
(
std
::
is_default_constructible
<
U
>::
value
and
static_assert
(
std
::
is_default_constructible
<
type
>::
value
and
std
::
is_copy_constructible
<
U
>::
value
,
std
::
is_copy_constructible
<
type
>::
value
,
"Types must be DefaultConstructible and "
"Types must be DefaultConstructible and "
"CopyConstructible when used with get"
);
"CopyConstructible when used with get"
);
type
ret
;
U
ret
;
JSONSerializer
<
type
>::
from_json
(
*
this
,
ret
);
JSONSerializer
<
U
>::
from_json
(
*
this
,
ret
);
return
ret
;
return
ret
;
}
}
...
...
src/json.hpp.re2c
View file @
1d870977
...
@@ -3019,26 +3019,26 @@ class basic_json
...
@@ -3019,26 +3019,26 @@ class basic_json
// the latter is preferred if both are present (since it does not require a default construction of T)
// the latter is preferred if both are present (since it does not require a default construction of T)
template <
template <
typename T,
typename T,
typename U = uncvref_t<T>,
enable_if_t<
enable_if_t<
not std::is_same<basic_json_t,
uncvref_t<T>
>::value and
not std::is_same<basic_json_t,
U
>::value and
detail::has_from_json<basic_json_t,
uncvref_t<T>
>::value and
detail::has_from_json<basic_json_t,
U
>::value and
not detail::has_non_default_from_json<basic_json_t,
not detail::has_non_default_from_json<basic_json_t,
uncvref_t<T>
>::value,
U
>::value,
int> = 0>
int> = 0>
// do we really want the uncvref ? if a user call get<int &>, shouldn't we
// do we really want the uncvref ? if a user call get<int &>, shouldn't we
// static assert ?
// static assert ?
// i know there is a special behaviour for boolean_t* and such
// i know there is a special behaviour for boolean_t* and such
auto get() const noexcept(noexcept(JSONSerializer<
uncvref_t<T>
>::from_json(
auto get() const noexcept(noexcept(JSONSerializer<
U
>::from_json(
std::declval<const basic_json_t &>(), std::declval<
uncvref_t<T>
&>())))
std::declval<const basic_json_t &>(), std::declval<
U
&>())))
->
uncvref_t<T>
->
U
{
{
using type = uncvref_t<T>;
static_assert(std::is_default_constructible<U>::value and
static_assert(std::is_default_constructible<type>::value and
std::is_copy_constructible<U>::value,
std::is_copy_constructible<type>::value,
"Types must be DefaultConstructible and "
"Types must be DefaultConstructible and "
"CopyConstructible when used with get");
"CopyConstructible when used with get");
type
ret;
U
ret;
JSONSerializer<
type
>::from_json(*this, ret);
JSONSerializer<
U
>::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