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
12b4555b
Commit
12b4555b
authored
Oct 20, 2016
by
Théo DELRIEU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use uncvref_t<T> instead of remove_cv_t<remove_reference_t<T>>>
parent
877d96c1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
15 deletions
+18
-15
json.hpp
src/json.hpp
+18
-15
No files found.
src/json.hpp
View file @
12b4555b
...
@@ -127,6 +127,9 @@ using remove_cv_t = typename std::remove_cv<T>::type;
...
@@ -127,6 +127,9 @@ using remove_cv_t = typename std::remove_cv<T>::type;
template
<
typename
T
>
template
<
typename
T
>
using
remove_reference_t
=
typename
std
::
remove_reference
<
T
>::
type
;
using
remove_reference_t
=
typename
std
::
remove_reference
<
T
>::
type
;
template
<
typename
T
>
using
uncvref_t
=
remove_cv_t
<
remove_reference_t
<
T
>>
;
// TODO update this doc
// TODO update this doc
/*!
/*!
@brief unnamed namespace with internal helper functions
@brief unnamed namespace with internal helper functions
...
@@ -1404,11 +1407,12 @@ class basic_json
...
@@ -1404,11 +1407,12 @@ class basic_json
// auto j = json{{"a", json(not_equality_comparable{})}};
// auto j = json{{"a", json(not_equality_comparable{})}};
//
//
// we can remove this constraint though, since lots of ctor are not explicit already
// we can remove this constraint though, since lots of ctor are not explicit already
template
<
typename
T
,
typename
=
enable_if_t
<
detail
::
has_json_traits
<
template
<
typename
T
,
typename
=
enable_if_t
<
remove_cv_t
<
remove_reference_t
<
T
>
>>::
value
>>
detail
::
has_json_traits
<
uncvref_t
<
T
>>::
value
>>
explicit
basic_json
(
T
&&
val
)
explicit
basic_json
(
T
&&
val
)
:
basic_json
(
json_traits
<
remove_cv_t
<
remove_reference_t
<
T
>>>::
to_json
(
:
basic_json
(
json_traits
<
uncvref_t
<
T
>>::
to_json
(
std
::
forward
<
T
>
(
val
)))
std
::
forward
<
T
>
(
val
)))
{}
{
}
/*!
/*!
@brief create a string (explicit)
@brief create a string (explicit)
...
@@ -2771,12 +2775,12 @@ class basic_json
...
@@ -2771,12 +2775,12 @@ class basic_json
// get_impl overload chosen if json_traits struct is specialized for type T
// get_impl overload chosen if json_traits struct is specialized for type T
// simply returns json_traits<T>::from_json(*this);
// simply returns json_traits<T>::from_json(*this);
template
<
typename
T
,
typename
=
enable_if_t
<
detail
::
has_json_traits
<
template
<
typename
T
,
typename
=
enable_if_t
<
remove_cv_t
<
remove_reference_t
<
T
>
>>::
value
>>
detail
::
has_json_traits
<
uncvref_t
<
T
>>::
value
>>
auto
get_impl
(
T
*
)
const
auto
get_impl
(
T
*
)
const
->
decltype
(
->
decltype
(
json_traits
<
remove_cv_t
<
remove_reference_t
<
T
>>>::
from_json
(
json_traits
<
uncvref_t
<
T
>>::
from_json
(
std
::
declval
<
basic_json
>
()))
std
::
declval
<
basic_json
>
()))
{
{
return
json_traits
<
remove_cv_t
<
remove_reference_t
<
T
>
>>::
from_json
(
*
this
);
return
json_traits
<
uncvref_t
<
T
>>::
from_json
(
*
this
);
}
}
// this one is quite atrocious
// this one is quite atrocious
...
@@ -2784,12 +2788,11 @@ class basic_json
...
@@ -2784,12 +2788,11 @@ class basic_json
// I chose to prefer the json_traits specialization if it exists, since it's a more advanced use.
// I chose to prefer the json_traits specialization if it exists, since it's a more advanced use.
// But we can of course change this behaviour
// But we can of course change this behaviour
template
<
typename
T
>
template
<
typename
T
>
auto
get_impl
(
T
*
)
const
auto
get_impl
(
T
*
)
const
->
enable_if_t
<
->
enable_if_t
<
not
detail
::
has_json_traits
<
remove_cv_t
<
T
>>::
value
,
not
detail
::
has_json_traits
<
remove_cv_t
<
T
>>::
value
,
remove_cv_t
<
remove_reference_t
<
decltype
(
uncvref_t
<
decltype
(
::
nlohmann
::
from_json
(
std
::
declval
<
basic_json
>
(),
::
nlohmann
::
from_json
(
std
::
declval
<
basic_json
>
(),
std
::
declval
<
T
&>
()),
std
::
declval
<
T
&>
()),
std
::
declval
<
T
>
())
>>
>
std
::
declval
<
T
>
())
>>
{
{
remove_cv_t
<
T
>
ret
;
remove_cv_t
<
T
>
ret
;
// I guess this output parameter is the only way to get ADL
// I guess this output parameter is the only way to get ADL
...
...
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