Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
ba0b35f4
Commit
ba0b35f4
authored
Jan 21, 2017
by
Théo DELRIEU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use typename U = uncvref_t where appropriate
parent
37fd20b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
18 deletions
+18
-18
src/json.hpp
src/json.hpp
+9
-9
src/json.hpp.re2c
src/json.hpp.re2c
+9
-9
No files found.
src/json.hpp
View file @
ba0b35f4
...
@@ -3107,14 +3107,13 @@ class basic_json
...
@@ -3107,14 +3107,13 @@ class basic_json
// 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
<
U
>::
from_json
(
U
get
()
const
noexcept
(
noexcept
(
JSONSerializer
<
U
>::
from_json
(
std
::
declval
<
const
basic_json_t
&>
(),
std
::
declval
<
U
&>
())))
std
::
declval
<
const
basic_json_t
&>
(),
std
::
declval
<
U
&>
())))
->
U
{
{
static_assert
(
std
::
is_default_constructible
<
U
>::
value
and
static_assert
(
std
::
is_default_constructible
<
U
>::
value
and
std
::
is_copy_constructible
<
U
>::
value
,
std
::
is_copy_constructible
<
U
>::
value
,
"Types must be DefaultConstructible and "
"Types must be DefaultConstructible and "
"CopyConstructible when used with get"
);
"CopyConstructible when used with get"
);
U
ret
;
U
ret
;
JSONSerializer
<
U
>::
from_json
(
*
this
,
ret
);
JSONSerializer
<
U
>::
from_json
(
*
this
,
ret
);
return
ret
;
return
ret
;
...
@@ -3137,11 +3136,12 @@ class basic_json
...
@@ -3137,11 +3136,12 @@ class basic_json
*/
*/
template
<
template
<
typename
T
,
typename
T
,
detail
::
enable_if_t
<
not
std
::
is_same
<
basic_json_t
,
detail
::
uncvref_t
<
T
>
>::
value
and
typename
U
=
detail
::
uncvref_t
<
T
>,
detail
::
enable_if_t
<
not
std
::
is_same
<
basic_json_t
,
U
>::
value
and
detail
::
has_non_default_from_json
<
basic_json_t
,
detail
::
has_non_default_from_json
<
basic_json_t
,
detail
::
uncvref_t
<
T
>
>::
value
,
U
>::
value
,
int
>
=
0
>
int
>
=
0
>
detail
::
uncvref_t
<
T
>
get
()
const
noexcept
(
noexcept
(
JSONSerializer
<
T
>::
from_json
(
std
::
declval
<
const
basic_json_t
&>
())))
U
get
()
const
noexcept
(
noexcept
(
JSONSerializer
<
T
>::
from_json
(
std
::
declval
<
const
basic_json_t
&>
())))
{
{
return
JSONSerializer
<
T
>::
from_json
(
*
this
);
return
JSONSerializer
<
T
>::
from_json
(
*
this
);
}
}
...
...
src/json.hpp.re2c
View file @
ba0b35f4
...
@@ -3107,14 +3107,13 @@ class basic_json
...
@@ -3107,14 +3107,13 @@ class basic_json
// 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<U>::from_json(
U get() const noexcept(noexcept(JSONSerializer<U>::from_json(
std::declval<const basic_json_t&>(), std::declval<U&>())))
std::declval<const basic_json_t&>(), std::declval<U&>())))
-> U
{
{
static_assert(std::is_default_constructible<U>::value and
static_assert(std::is_default_constructible<U>::value and
std::is_copy_constructible<U>::value,
std::is_copy_constructible<U>::value,
"Types must be DefaultConstructible and "
"Types must be DefaultConstructible and "
"CopyConstructible when used with get");
"CopyConstructible when used with get");
U ret;
U ret;
JSONSerializer<U>::from_json(*this, ret);
JSONSerializer<U>::from_json(*this, ret);
return ret;
return ret;
...
@@ -3137,11 +3136,12 @@ class basic_json
...
@@ -3137,11 +3136,12 @@ class basic_json
*/
*/
template <
template <
typename T,
typename T,
detail::enable_if_t<not std::is_same<basic_json_t, detail::uncvref_t<T>>::value and
typename U = detail::uncvref_t<T>,
detail::enable_if_t<not std::is_same<basic_json_t, U>::value and
detail::has_non_default_from_json<basic_json_t,
detail::has_non_default_from_json<basic_json_t,
detail::uncvref_t<T>
>::value,
U
>::value,
int> = 0 >
int> = 0 >
detail::uncvref_t<T>
get() const noexcept(noexcept(JSONSerializer<T>::from_json(std::declval<const basic_json_t&>())))
U
get() const noexcept(noexcept(JSONSerializer<T>::from_json(std::declval<const basic_json_t&>())))
{
{
return JSONSerializer<T>::from_json(*this);
return JSONSerializer<T>::from_json(*this);
}
}
...
...
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